]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
comedi vmk80xx: simplify rinsn output calculation
authorJ. Ali Harlow <ali@avrc.city.ac.uk>
Wed, 18 May 2011 18:18:53 +0000 (19:18 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 18 May 2011 21:32:06 +0000 (14:32 -0700)
vmk80xx_di_rinsn() and vmk80xx_do_rinsn() extract the required channel
data by inconsistent and overly-complex algorithms. Simplify them both.

Signed-off-by: J. Ali Harlow <ali@avrc.city.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/comedi/drivers/vmk80xx.c

index 01cfb7695f7c695d8d7777ea831e2aa4a3060233..c86c8664101b69de101a3cbd8135bbfabfb6118e 100644 (file)
@@ -747,7 +747,7 @@ static int vmk80xx_di_rinsn(struct comedi_device *cdev,
                else
                        inp = rx_buf[reg];
 
-               data[n] = ((inp & (1 << chan)) > 0);
+               data[n] = (inp >> chan) & 1;
        }
 
        up(&dev->limit_sem);
@@ -812,7 +812,6 @@ static int vmk80xx_do_rinsn(struct comedi_device *cdev,
        struct vmk80xx_usb *dev = cdev->private;
        int chan;
        int reg;
-       int mask;
        int n;
 
        dbgvm("vmk80xx: %s\n", __func__);
@@ -825,7 +824,6 @@ static int vmk80xx_do_rinsn(struct comedi_device *cdev,
        chan = CR_CHAN(insn->chanspec);
 
        reg = VMK8061_DO_REG;
-       mask = 1 << chan;
 
        dev->usb_tx_buf[0] = VMK8061_CMD_RD_DO;
 
@@ -833,7 +831,7 @@ static int vmk80xx_do_rinsn(struct comedi_device *cdev,
                if (vmk80xx_read_packet(dev))
                        break;
 
-               data[n] = (dev->usb_rx_buf[reg] & mask) >> chan;
+               data[n] = (dev->usb_rx_buf[reg] >> chan) & 1;
        }
 
        up(&dev->limit_sem);