[PATCH 32/38] staging: comedi: amplc_pci230: chanlist is valid after Step 1 of (*do_cmdtest)

H Hartley Sweeten hsweeten at visionengravers.com
Tue May 27 17:31:08 UTC 2014


THe comedi core ensures that the chanlist will be valid for any async operation
other than Step 1 of the (*do_cmdtest) to get the trigger source masks.

Remove the unnecessary checks.

Signed-off-by: H Hartley Sweeten <hsweeten at visionengravers.com>
Cc: Ian Abbott <abbotti at mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
---
 drivers/staging/comedi/drivers/amplc_pci230.c | 33 +++++++++++----------------
 1 file changed, 13 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c
index 3895bc7..c87260c 100644
--- a/drivers/staging/comedi/drivers/amplc_pci230.c
+++ b/drivers/staging/comedi/drivers/amplc_pci230.c
@@ -1511,16 +1511,12 @@ static int pci230_ao_cancel(struct comedi_device *dev,
 
 static int pci230_ai_check_scan_period(struct comedi_cmd *cmd)
 {
-	unsigned int min_scan_period, chanlist_len;
+	unsigned int min_scan_period;
 	int err = 0;
 
-	chanlist_len = cmd->chanlist_len;
-	if (cmd->chanlist_len == 0)
-		chanlist_len = 1;
-
-	min_scan_period = chanlist_len * cmd->convert_arg;
-	if ((min_scan_period < chanlist_len)
-	    || (min_scan_period < cmd->convert_arg)) {
+	min_scan_period = cmd->chanlist_len * cmd->convert_arg;
+	if ((min_scan_period < cmd->chanlist_len) ||
+	    (min_scan_period < cmd->convert_arg)) {
 		/* Arithmetic overflow. */
 		min_scan_period = UINT_MAX;
 		err++;
@@ -1703,19 +1699,16 @@ static int pci230_ai_cmdtest(struct comedi_device *dev,
 		unsigned int max_speed_ai;
 
 		if (devpriv->hwver == 0) {
-			/* PCI230 or PCI260.  Max speed depends whether
-			 * single-ended or pseudo-differential. */
-			if (cmd->chanlist && (cmd->chanlist_len > 0)) {
-				/* Peek analogue reference of first channel. */
-				if (CR_AREF(cmd->chanlist[0]) == AREF_DIFF)
-					max_speed_ai = MAX_SPEED_AI_DIFF;
-				else
-					max_speed_ai = MAX_SPEED_AI_SE;
-
-			} else {
-				/* No channel list.  Assume single-ended. */
+			/*
+			 * PCI230 or PCI260.  Max speed depends whether
+			 * single-ended or pseudo-differential.
+			 *
+			 * Peek analogue reference of first channel.
+			 */
+			if (CR_AREF(cmd->chanlist[0]) == AREF_DIFF)
+				max_speed_ai = MAX_SPEED_AI_DIFF;
+			else
 				max_speed_ai = MAX_SPEED_AI_SE;
-			}
 		} else {
 			/* PCI230+ or PCI260+. */
 			max_speed_ai = MAX_SPEED_AI_PLUS;
-- 
1.9.2



More information about the devel mailing list