aboutsummaryrefslogtreecommitdiff
path: root/hw/arm/omap1.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2015-03-23 15:29:27 +0000
committerKevin Wolf <kwolf@redhat.com>2015-04-28 15:36:08 +0200
commitbd2a88840e2496e29442f333c8fdd6491e831a35 (patch)
tree95ced0dfbbd8ac39d8e73b55a414398dccb106ad /hw/arm/omap1.c
parent786a4ea82ec9c87e3a895cf41081029b285a5fe5 (diff)
Convert ffs() != 0 callers to ctz32()
There are a number of ffs(3) callers that do roughly: bit = ffs(val); if (bit) { do_something(bit - 1); } This pattern can be converted to ctz32() like this: zeroes = ctz32(val); if (zeroes != 32) { do_something(zeroes); } Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 1427124571-28598-6-git-send-email-stefanha@redhat.com Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw/arm/omap1.c')
-rw-r--r--hw/arm/omap1.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c
index 91ffb589e5..de2b289257 100644
--- a/hw/arm/omap1.c
+++ b/hw/arm/omap1.c
@@ -2004,8 +2004,7 @@ static void omap_mpuio_write(void *opaque, hwaddr addr,
case 0x04: /* OUTPUT_REG */
diff = (s->outputs ^ value) & ~s->dir;
s->outputs = value;
- while ((ln = ffs(diff))) {
- ln --;
+ while ((ln = ctz32(diff)) != 32) {
if (s->handler[ln])
qemu_set_irq(s->handler[ln], (value >> ln) & 1);
diff &= ~(1 << ln);
@@ -2017,8 +2016,7 @@ static void omap_mpuio_write(void *opaque, hwaddr addr,
s->dir = value;
value = s->outputs & ~s->dir;
- while ((ln = ffs(diff))) {
- ln --;
+ while ((ln = ctz32(diff)) != 32) {
if (s->handler[ln])
qemu_set_irq(s->handler[ln], (value >> ln) & 1);
diff &= ~(1 << ln);