summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorWu, Josh <Josh.wu@atmel.com>2014-05-07 16:50:45 +0800
committerAndreas Bießmann <andreas.devel@googlemail.com>2014-05-27 00:10:45 +0200
commit7d82d897722f57389ebe15924f47fab452cc3a19 (patch)
tree73206e6aa46e6e1d32ecb51f050a3507505ca555 /drivers
parent495275925192edb0c5bd6cb1e3b6f85162ffd06b (diff)
gpio: at91: add sanity check for the NULL pointer
We need check the NULL pointer as at91_pio_get_port() may return NULL. Also print a error message when at91_pio_get_port() failed otherwise we cannot notice the failure. Signed-off-by: Josh Wu <josh.wu@atmel.com> Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpio/at91_gpio.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/gpio/at91_gpio.c b/drivers/gpio/at91_gpio.c
index 0b70071871..6517af1628 100644
--- a/drivers/gpio/at91_gpio.c
+++ b/drivers/gpio/at91_gpio.c
@@ -34,6 +34,7 @@ static struct at91_port *at91_pio_get_port(unsigned port)
#endif
#endif
default:
+ printf("Error: at91_gpio: Fail to get PIO base!\n");
return NULL;
}
}
@@ -200,7 +201,7 @@ int at91_set_pio_output(unsigned port, u32 pin, int value)
struct at91_port *at91_port = at91_pio_get_port(port);
u32 mask;
- if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
+ if (at91_port && (port < ATMEL_PIO_PORTS) && (pin < 32)) {
mask = 1 << pin;
writel(mask, &at91_port->idr);
writel(mask, &at91_port->pudr);