From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ya4IS-0001Nj-G7 for qemu-devel@nongnu.org; Mon, 23 Mar 2015 11:29:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ya4IR-00081f-Lo for qemu-devel@nongnu.org; Mon, 23 Mar 2015 11:29:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39236) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ya4IR-00081L-FM for qemu-devel@nongnu.org; Mon, 23 Mar 2015 11:29:43 -0400 From: Stefan Hajnoczi Date: Mon, 23 Mar 2015 15:29:25 +0000 Message-Id: <1427124571-28598-4-git-send-email-stefanha@redhat.com> In-Reply-To: <1427124571-28598-1-git-send-email-stefanha@redhat.com> References: <1427124571-28598-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH v3 3/9] uninorth: convert ffs(3) to ctz32() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Alexander Graf , Markus Armbruster , Stefan Hajnoczi , Paolo Bonzini 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 --- 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 */ -- 2.1.0