qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH v3 2/9] hw/arm/nseries: convert ffs(3) to ctz32()


From: Stefan Hajnoczi
Subject: [Qemu-devel] [PATCH v3 2/9] hw/arm/nseries: convert ffs(3) to ctz32()
Date: Mon, 23 Mar 2015 15:29:24 +0000

It is not clear from the code how a 0 parameter should be handled by the
hardware.  Keep the same behavior as ffs(0) - 1 == -1.

Cc: Andrzej Zaborowski <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
 hw/arm/nseries.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
index 2a5406d..d243159 100644
--- a/hw/arm/nseries.c
+++ b/hw/arm/nseries.c
@@ -579,7 +579,10 @@ static uint32_t mipid_txrx(void *opaque, uint32_t cmd, int 
len)
 
     case 0x26: /* GAMSET */
         if (!s->pm) {
-            s->gamma = ffs(s->param[0] & 0xf) - 1;
+            s->gamma = ctz32(s->param[0] & 0xf);
+            if (s->gamma == 32) {
+                s->gamma = -1; /* XXX: should this be 0? */
+            }
         } else if (s->pm < 0) {
             s->pm = 1;
         }
-- 
2.1.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]