summaryrefslogtreecommitdiffstats
path: root/hw
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2015-03-23 15:29:24 +0000
committerKevin Wolf <kwolf@redhat.com>2015-04-28 15:36:08 +0200
commitad5f5fdca83cccd1a4c269b1fd8ba2fce8d1ba26 (patch)
tree37ac44a4f5bfc7c341a0d4e25f97b5c88ac703d1 /hw
parent588ef9d411339012fc3c94bfad8911e9d0a517a2 (diff)
downloadhqemu-ad5f5fdca83cccd1a4c269b1fd8ba2fce8d1ba26.zip
hqemu-ad5f5fdca83cccd1a4c269b1fd8ba2fce8d1ba26.tar.gz
hw/arm/nseries: convert ffs(3) to ctz32()
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 <balrog@zabor.org> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 1427124571-28598-3-git-send-email-stefanha@redhat.com Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/arm/nseries.c5
1 files changed, 4 insertions, 1 deletions
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;
}
OpenPOWER on IntegriCloud