From: Stefan Hajnoczi Date: Mon, 23 Mar 2015 15:29:25 +0000 (+0000) Subject: uninorth: convert ffs(3) to ctz32() X-Git-Tag: v2.4.0-rc0~158^2~71 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=5863d374a32c98a7adb4c5e49d62de3cdc16d2ea;p=users%2Fdwmw2%2Fqemu.git uninorth: 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: Alexander Graf Signed-off-by: Stefan Hajnoczi Message-id: 1427124571-28598-4-git-send-email-stefanha@redhat.com Signed-off-by: Kevin Wolf --- diff --git a/hw/pci-host/uninorth.c b/hw/pci-host/uninorth.c index 53f2b59ae8..f0144eb7b0 100644 --- a/hw/pci-host/uninorth.c +++ b/hw/pci-host/uninorth.c @@ -92,7 +92,10 @@ static uint32_t unin_get_config_reg(uint32_t reg, uint32_t addr) uint32_t slot, func; /* Grab CFA0 style values */ - slot = ffs(reg & 0xfffff800) - 1; + slot = ctz32(reg & 0xfffff800); + if (slot == 32) { + slot = -1; /* XXX: should this be 0? */ + } func = (reg >> 8) & 7; /* ... and then convert them to x86 format */