[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1485532554-2520-1-git-send-email-thrust73@gmail.com>
Date: Fri, 27 Jan 2017 23:55:54 +0800
From: Cheah Kok Cheong <thrust73@...il.com>
To: abbotti@....co.uk, hsweeten@...ionengravers.com,
gregkh@...uxfoundation.org
Cc: devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org,
Cheah Kok Cheong <thrust73@...il.com>
Subject: [PATCH] Staging: comedi: drivers: comedi_test: Set max input value for auto config
Currently user can input any value for amplitude and period.
This patch set a sane max value for auto-configuration mode.
For manual configuration mode, it is assumed this is taken care of
by the COMEDI userspace tool since there's no limit set here from
day one in the staging tree. If otherwise then maybe this can be
looked at separately.
Signed-off-by: Cheah Kok Cheong <thrust73@...il.com>
---
Note: This patch is dependent upon an earlier pending patch.
[Staging: comedi: drivers: comedi_test: Add auto-configuration
capability]
drivers/staging/comedi/drivers/comedi_test.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c
index 92b3a4f1..4e18e2c 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -715,6 +715,14 @@ static int waveform_attach(struct comedi_device *dev,
static int waveform_auto_attach(struct comedi_device *dev,
unsigned long context_unused)
{
+ /* limit max input voltage to 300V [typical oscilloscope max value] */
+ if (set_amplitude > 300000000)
+ set_amplitude = 300000000;
+
+ /* limit max input period [= 1 hertz] to avoid too low freq */
+ if (set_period > 1000000)
+ set_period = 1000000;
+
int amplitude = set_amplitude;
int period = set_period;
--
2.7.4
Powered by blists - more mailing lists