From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yn70q-0007KB-2H for qemu-devel@nongnu.org; Tue, 28 Apr 2015 11:01:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yn70k-0001lY-1b for qemu-devel@nongnu.org; Tue, 28 Apr 2015 11:01:27 -0400 From: Kevin Wolf Date: Tue, 28 Apr 2015 16:59:47 +0200 Message-Id: <1430233258-31807-6-git-send-email-kwolf@redhat.com> In-Reply-To: <1430233258-31807-1-git-send-email-kwolf@redhat.com> References: <1430233258-31807-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 05/76] uninorth: convert ffs(3) to ctz32() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Stefan Hajnoczi 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 --- hw/pci-host/uninorth.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/pci-host/uninorth.c b/hw/pci-host/uninorth.c index 53f2b59..f0144eb 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 */ -- 1.8.3.1