From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ya4IS-0001ON-Um for qemu-devel@nongnu.org; Mon, 23 Mar 2015 11:29:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ya4IO-00080V-42 for qemu-devel@nongnu.org; Mon, 23 Mar 2015 11:29:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39218) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ya4IN-00080O-TM for qemu-devel@nongnu.org; Mon, 23 Mar 2015 11:29:40 -0400 From: Stefan Hajnoczi Date: Mon, 23 Mar 2015 15:29:24 +0000 Message-Id: <1427124571-28598-3-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 2/9] hw/arm/nseries: 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 , Andrzej Zaborowski , 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: Andrzej Zaborowski Signed-off-by: Stefan Hajnoczi --- 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