Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 07 Apr 2013 11:17:20 +0200
From:      Christoph Mallon <christoph.mallon@gmx.de>
To:        FreeBSD-gnats-submit@freebsd.org
Cc:        Christoph Mallon <christoph.mallon@gmx.de>
Subject:   arm/177685: [kernel] [patch] Correct return type and usage of at91_pio_gpio_get()
Message-ID:  <E1UOliy-000NZ9-6D@rotluchs.lokal>
Resent-Message-ID: <201304070920.r379K0r9025013@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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 <christoph.mallon@gmx.de>
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 <christoph.mallon@gmx.de>
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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1UOliy-000NZ9-6D>