From owner-freebsd-arm@FreeBSD.ORG Sun Apr 7 09:20:00 2013 Return-Path: Delivered-To: freebsd-arm@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id D55F538A for ; Sun, 7 Apr 2013 09:20:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id B6F841F78; Sun, 7 Apr 2013 09:20:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.6/8.14.6) with ESMTP id r379K0r1025014; Sun, 7 Apr 2013 09:20:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.6/8.14.6/Submit) id r379K0r9025013; Sun, 7 Apr 2013 09:20:00 GMT (envelope-from gnats) Resent-Date: Sun, 7 Apr 2013 09:20:00 GMT Resent-Message-Id: <201304070920.r379K0r9025013@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-arm@FreeBSD.org Resent-Cc: Ian Lepore Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Christoph Mallon Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 0DFB3355 for ; Sun, 7 Apr 2013 09:17:24 +0000 (UTC) (envelope-from christoph.mallon@gmx.de) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by mx1.freebsd.org (Postfix) with ESMTP id B06641F5C for ; Sun, 7 Apr 2013 09:17:23 +0000 (UTC) Received: from mailout-de.gmx.net ([10.1.76.2]) by mrigmx.server.lan (mrigmx001) with ESMTP (Nemesis) id 0Lsdt9-1UZefI3l5F-012LQf for ; Sun, 07 Apr 2013 11:17:21 +0200 Received: (qmail invoked by alias); 07 Apr 2013 09:17:21 -0000 Received: from p5B13371A.dip.t-dialin.net (EHLO rotluchs.lokal) [91.19.55.26] by mail.gmx.net (mp002) with SMTP; 07 Apr 2013 11:17:21 +0200 Received: from tron by rotluchs.lokal with local (Exim 4.80.1 (FreeBSD)) (envelope-from ) id 1UOliy-000NZ9-6D; Sun, 07 Apr 2013 11:17:20 +0200 Message-Id: Date: Sun, 07 Apr 2013 11:17:20 +0200 From: Christoph Mallon To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.114 X-GNATS-Notify: Ian Lepore Subject: arm/177685: [kernel] [patch] Correct return type and usage of at91_pio_gpio_get() Cc: Christoph Mallon X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Christoph Mallon List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Apr 2013 09:20:00 -0000 >Number: 177685 >Category: arm >Synopsis: [kernel] [patch] Correct return type and usage of at91_pio_gpio_get() >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-arm >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Apr 07 09:20:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Christoph Mallon >Release: >Organization: >Environment: >Description: at91_pio_gpio_get() returns a bitset instead of just 0/1 since r248910. But the return type (uint8_t) is too narrow for the mask. In particular the only callers of the function tests bit 24, so it always gets 0 now. The second patch just removes redundant parentheses in at91_pio_gpio_get(). ian@ is X-GNATS-Notified. >How-To-Repeat: >Fix: Please apply the patch. --- 0001-at91-Adjust-the-return-type-of-at91_pio_gpio_get.patch begins here --- >From 0c3af531b9648725a237610443533106b6cf1e91 Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Sun, 7 Apr 2013 10:59:56 +0200 Subject: [PATCH 1/2] at91: Adjust the return type of at91_pio_gpio_get(). It returns the masked set of bits, which requires uint32_t, now. This fixes its only caller, which always got 0, because it tested bit 24 and the function returned only an uint8_t. --- sys/arm/at91/at91_pio.c | 2 +- sys/arm/at91/at91_piovar.h | 2 +- sys/dev/usb/controller/at91dci_atmelarm.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/arm/at91/at91_pio.c b/sys/arm/at91/at91_pio.c index c2998b5..fef089b 100644 --- a/sys/arm/at91/at91_pio.c +++ b/sys/arm/at91/at91_pio.c @@ -554,7 +554,7 @@ at91_pio_gpio_clear(uint32_t pio, uint32_t data_mask) PIO[PIO_CODR / 4] = data_mask; } -uint8_t +uint32_t at91_pio_gpio_get(uint32_t pio, uint32_t data_mask) { uint32_t *PIO = (uint32_t *)(AT91_BASE + pio); diff --git a/sys/arm/at91/at91_piovar.h b/sys/arm/at91/at91_piovar.h index 0608f16..d2b912d 100644 --- a/sys/arm/at91/at91_piovar.h +++ b/sys/arm/at91/at91_piovar.h @@ -39,7 +39,7 @@ void at91_pio_gpio_output(uint32_t pio, uint32_t output_enable_mask, void at91_pio_gpio_high_z(uint32_t pio, uint32_t high_z_mask, int enable); void at91_pio_gpio_set(uint32_t pio, uint32_t data_mask); void at91_pio_gpio_clear(uint32_t pio, uint32_t data_mask); -uint8_t at91_pio_gpio_get(uint32_t pio, uint32_t data_mask); +uint32_t at91_pio_gpio_get(uint32_t pio, uint32_t data_mask); void at91_pio_gpio_set_deglitch(uint32_t pio, uint32_t data_mask, int use_deglitch); void at91_pio_gpio_set_interrupt(uint32_t pio, uint32_t data_mask, diff --git a/sys/dev/usb/controller/at91dci_atmelarm.c b/sys/dev/usb/controller/at91dci_atmelarm.c index 678ad48..7f94ed7 100644 --- a/sys/dev/usb/controller/at91dci_atmelarm.c +++ b/sys/dev/usb/controller/at91dci_atmelarm.c @@ -91,7 +91,7 @@ at91_vbus_poll(struct at91_udp_softc *sc) { uint8_t vbus_val; - vbus_val = at91_pio_gpio_get(VBUS_BASE, VBUS_MASK); + vbus_val = at91_pio_gpio_get(VBUS_BASE, VBUS_MASK) != 0; at91dci_vbus_interrupt(&sc->sc_dci, vbus_val); callout_reset(&sc->sc_vbus, hz, (void *)&at91_vbus_poll, sc); -- 1.8.2 --- 0001-at91-Adjust-the-return-type-of-at91_pio_gpio_get.patch ends here --- --- dummy1 begins here --- dummy file, because GNATS damages every other file --- dummy1 ends here --- --- 0002-at91-Remove-redundant-parentheses.patch begins here --- >From fa9d855770e7f2a5e8886b7be85dce92a61b33ef Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Sun, 7 Apr 2013 11:02:15 +0200 Subject: [PATCH 2/2] at91: Remove redundant parentheses. --- sys/arm/at91/at91_pio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/arm/at91/at91_pio.c b/sys/arm/at91/at91_pio.c index fef089b..2a50707 100644 --- a/sys/arm/at91/at91_pio.c +++ b/sys/arm/at91/at91_pio.c @@ -559,7 +559,7 @@ at91_pio_gpio_get(uint32_t pio, uint32_t data_mask) { uint32_t *PIO = (uint32_t *)(AT91_BASE + pio); - return ((PIO[PIO_PDSR / 4] & data_mask)); + return (PIO[PIO_PDSR / 4] & data_mask); } void -- 1.8.2 --- 0002-at91-Remove-redundant-parentheses.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: