Bug 177685 - [kernel] [patch] Correct return type and usage of at91_pio_gpio_get()
Summary: [kernel] [patch] Correct return type and usage of at91_pio_gpio_get()
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: arm (show other bugs)
Version: 1.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-arm (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-07 10:20 UTC by Christoph Mallon
Modified: 2014-02-08 23:19 UTC (History)
1 user (show)

See Also:


Attachments
0001-at91-Adjust-the-return-type-of-at91_pio_gpio_get.patch (2.23 KB, patch)
2013-04-07 10:20 UTC, Christoph Mallon
no flags Details | Diff
0002-at91-Remove-redundant-parentheses.patch (684 bytes, patch)
2013-04-07 10:20 UTC, Christoph Mallon
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Mallon 2013-04-07 10:20:00 UTC
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.

Fix: Please apply the patch.

dummy file, because GNATS damages every other file
--- dummy1 ends here ---
Comment 1 dfilter service freebsd_committer freebsd_triage 2013-04-07 14:04:11 UTC
Author: hselasky
Date: Sun Apr  7 13:03:57 2013
New Revision: 249232
URL: http://svnweb.freebsd.org/changeset/base/249232

Log:
  Fix regression issue after r248910.
  
  PR:		arm/177685
  Submitted by:	Christoph Mallon <christoph.mallon@gmx.de>

Modified:
  head/sys/arm/at91/at91_pio.c
  head/sys/arm/at91/at91_piovar.h
  head/sys/dev/usb/controller/at91dci_atmelarm.c

Modified: head/sys/arm/at91/at91_pio.c
==============================================================================
--- head/sys/arm/at91/at91_pio.c	Sun Apr  7 11:05:38 2013	(r249231)
+++ head/sys/arm/at91/at91_pio.c	Sun Apr  7 13:03:57 2013	(r249232)
@@ -554,12 +554,12 @@ at91_pio_gpio_clear(uint32_t pio, uint32
 	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);
 
-	return ((PIO[PIO_PDSR / 4] & data_mask));
+	return (PIO[PIO_PDSR / 4] & data_mask);
 }
 
 void

Modified: head/sys/arm/at91/at91_piovar.h
==============================================================================
--- head/sys/arm/at91/at91_piovar.h	Sun Apr  7 11:05:38 2013	(r249231)
+++ head/sys/arm/at91/at91_piovar.h	Sun Apr  7 13:03:57 2013	(r249232)
@@ -39,7 +39,7 @@ void at91_pio_gpio_output(uint32_t pio, 
 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,

Modified: head/sys/dev/usb/controller/at91dci_atmelarm.c
==============================================================================
--- head/sys/dev/usb/controller/at91dci_atmelarm.c	Sun Apr  7 11:05:38 2013	(r249231)
+++ head/sys/dev/usb/controller/at91dci_atmelarm.c	Sun Apr  7 13:03:57 2013	(r249232)
@@ -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);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 2 Christian Brueffer freebsd_committer freebsd_triage 2014-02-08 23:18:38 UTC
State Changed
From-To: open->closed

The changes were committed by hps in r249232 (April 2013). 
Thanks for the submission!