From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MQDoJ-0005Zx-WF for qemu-devel@nongnu.org; Mon, 13 Jul 2009 01:10:44 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MQDoE-0005V1-88 for qemu-devel@nongnu.org; Mon, 13 Jul 2009 01:10:42 -0400 Received: from [199.232.76.173] (port=49431 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MQDoD-0005Ua-NI for qemu-devel@nongnu.org; Mon, 13 Jul 2009 01:10:37 -0400 Received: from smtp.srv.ualberta.ca ([129.128.5.19]:64327 helo=mail6.srv.ualberta.ca) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MQDoD-0003L9-4o for qemu-devel@nongnu.org; Mon, 13 Jul 2009 01:10:37 -0400 From: Logan Gunthorpe Date: Sun, 12 Jul 2009 23:10:20 -0600 Message-Id: <1247461821-20621-3-git-send-email-logang@ece.ualberta.ca> In-Reply-To: <1247461821-20621-1-git-send-email-logang@ece.ualberta.ca> References: <1247461821-20621-1-git-send-email-logang@ece.ualberta.ca> Subject: [Qemu-devel] [PATCH 2/3] Fixes two bugs with the Stelaris ADC. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Logan Gunthorpe - The adc gets double-triggered because the stelaris_adc_trigger function does not ignore calls when the level is low. - In the stelaris_adc_fifo_read function there is a slight bug that fails to set the empty flag when the tail pointer overflows back to zero. --- hw/stellaris.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/hw/stellaris.c b/hw/stellaris.c index 5f44bff..4fadeec 100644 --- a/hw/stellaris.c +++ b/hw/stellaris.c @@ -934,7 +934,7 @@ static uint32_t stellaris_adc_fifo_read(stellaris_adc_state *s, int n) } else { s->fifo[n].state = (s->fifo[n].state & ~0xf) | ((tail + 1) & 0xf); s->fifo[n].state &= ~STELLARIS_ADC_FIFO_FULL; - if (tail + 1 == ((s->fifo[n].state >> 4) & 0xf)) + if (((tail + 1) & 0xf) == ((s->fifo[n].state >> 4) & 0xf)) s->fifo[n].state |= STELLARIS_ADC_FIFO_EMPTY; } return s->fifo[n].data[tail]; @@ -976,6 +976,8 @@ static void stellaris_adc_trigger(void *opaque, int irq, int level) stellaris_adc_state *s = (stellaris_adc_state *)opaque; int n; + if (!level) return; + for (n = 0; n < 4; n++) { if ((s->actss & (1 << n)) == 0) { continue; -- 1.5.6.5