lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1305742736-19434-3-git-send-email-ali@avrc.city.ac.uk>
Date:	Wed, 18 May 2011 19:18:53 +0100
From:	"J. Ali Harlow" <ali@...c.city.ac.uk>
To:	Greg Kroah-Hartman <greg@...ah.com>
Cc:	devel@...uxdriverproject.org, Manuel Gebele <forensixs@....de>,
	linux-kernel@...r.kernel.org
Subject: [PATCH 3/6] comedi vmk80xx: simplify rinsn output calculation

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@...c.city.ac.uk>
---
 drivers/staging/comedi/drivers/vmk80xx.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/vmk80xx.c b/drivers/staging/comedi/drivers/vmk80xx.c
index 01cfb76..c86c866 100644
--- a/drivers/staging/comedi/drivers/vmk80xx.c
+++ b/drivers/staging/comedi/drivers/vmk80xx.c
@@ -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);
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ