[PATCH 24/53] staging: comedi: usbdux: tidy up receive_dux_commands()

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

 



For aesthetic reasons, pass the comedi_device pointer to this function
instead of the private data pointer. Rename the local variable used
for the private data pointer to the comedi "norm".

Add a local variable for the usb_device pointer to tidy up the
usb_bulk_msg() call.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/usbdux.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c
index d2a3a1a..5980b8e 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -860,25 +860,24 @@ static int send_dux_commands(struct comedi_device *dev, int cmd_type)
 			    &nsent, BULK_TIMEOUT);
 }
 
-static int receive_dux_commands(struct usbdux_private *this_usbduxsub, int command)
+static int receive_dux_commands(struct comedi_device *dev, int command)
 {
-	int result = (-EFAULT);
+	struct usbdux_private *devpriv = dev->private;
+	struct usb_device *usb = devpriv->usbdev;
+	int ret;
 	int nrec;
 	int i;
 
 	for (i = 0; i < RETRIES; i++) {
-		result = usb_bulk_msg(this_usbduxsub->usbdev,
-				      usb_rcvbulkpipe(this_usbduxsub->usbdev,
-						      COMMAND_IN_EP),
-				      this_usbduxsub->insn_buffer, SIZEINSNBUF,
+		ret = usb_bulk_msg(usb, usb_rcvbulkpipe(usb, COMMAND_IN_EP),
+				      devpriv->insn_buffer, SIZEINSNBUF,
 				      &nrec, BULK_TIMEOUT);
-		if (result < 0)
-			return result;
-		if (le16_to_cpu(this_usbduxsub->insn_buffer[0]) == command)
-			return result;
+		if (ret < 0)
+			return ret;
+		if (le16_to_cpu(devpriv->insn_buffer[0]) == command)
+			return ret;
 	}
-	/* this is only reached if the data has been requested a couple of
-	 * times */
+	/* command not received */
 	return -EFAULT;
 }
 
@@ -1037,7 +1036,7 @@ static int usbdux_ai_insn_read(struct comedi_device *dev,
 	}
 
 	for (i = 0; i < insn->n; i++) {
-		err = receive_dux_commands(this_usbduxsub, SENDSINGLEAD);
+		err = receive_dux_commands(dev, SENDSINGLEAD);
 		if (err < 0) {
 			up(&this_usbduxsub->sem);
 			return 0;
@@ -1362,7 +1361,7 @@ static int usbdux_dio_insn_bits(struct comedi_device *dev,
 		up(&this_usbduxsub->sem);
 		return err;
 	}
-	err = receive_dux_commands(this_usbduxsub, SENDDIOBITSCOMMAND);
+	err = receive_dux_commands(dev, SENDDIOBITSCOMMAND);
 	if (err < 0) {
 		up(&this_usbduxsub->sem);
 		return err;
@@ -1392,7 +1391,7 @@ static int usbdux_counter_read(struct comedi_device *dev,
 		return err;
 	}
 
-	err = receive_dux_commands(this_usbduxsub, READCOUNTERCOMMAND);
+	err = receive_dux_commands(dev, READCOUNTERCOMMAND);
 	if (err < 0) {
 		up(&this_usbduxsub->sem);
 		return err;
-- 
1.8.3.2

_______________________________________________
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