[PATCH 24/30] staging: comedi: usbdux: simplify initializing the ao urb transfer_buffer

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

 



Remove the ugly casting of datap to the ao urb->transfer_buffer. The format
of the data in the buffer is simply.

  [0] = # of channels to update (s->async->cmd.chanlist.len)
  [1] = lsb of value for 1st channel to update
  [2] = msb of value for 1st channel to update
  [3] = 1st channel to update (depvriv->dac_commands[0])

If more than 1 channel is to be updated they are simply added to the buffer:

  [4] = lsb of value for 2st channel to update
  [5] = msb of value for 2st channel to update
  [6] = 1st channel to update (depvriv->dac_commands[1])

etc.

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

diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c
index 1399305..cb94964 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -425,8 +425,10 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb)
 	struct comedi_device *dev = urb->context;
 	struct comedi_subdevice *s = dev->write_subdev;
 	struct usbdux_private *devpriv = dev->private;
-	int i, ret;
 	int8_t *datap;
+	int len;
+	int ret;
+	int i;
 
 	switch (urb->status) {
 	case 0:
@@ -484,9 +486,11 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb)
 				return;
 			}
 		}
+
 		/* transmit data to the USB bus */
-		((uint8_t *) (urb->transfer_buffer))[0] =
-		    s->async->cmd.chanlist_len;
+		datap = urb->transfer_buffer;
+		len = s->async->cmd.chanlist_len;
+		*datap++ = len;
 		for (i = 0; i < s->async->cmd.chanlist_len; i++) {
 			unsigned int chan = devpriv->dac_commands[i];
 			short val;
@@ -498,12 +502,9 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb)
 						     COMEDI_CB_OVERFLOW);
 			}
 			/* pointer to the DA */
-			datap =
-			    (&(((int8_t *) urb->transfer_buffer)[i * 3 + 1]));
-			/* get the data from comedi */
-			datap[0] = val;
-			datap[1] = val >> 8;
-			datap[2] = chan;
+			*datap++ = val & 0xff;
+			*datap++ = (val >> 8) & 0xff;
+			*datap++ = chan;
 			devpriv->ao_readback[chan] = val;
 
 			s->async->events |= COMEDI_CB_BLOCK;
-- 
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