[PATCH] Staging: comedi: drivers: comedi_test: Set max input value for auto config

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
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

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux