From 57540cd86cae9d42649e59028a489506063c2f0f Mon Sep 17 00:00:00 2001 From: Henry Bruce Date: Fri, 14 Nov 2014 16:32:55 -0800 Subject: [PATCH] gpio.c: check that real gpio did initialise correctly On platforms without muxing perform a little more checking when the 'real' linux/sysfs gpio is opened. We don't expect this to fail but on platforms where the linux gpios can be changed depending on pinctrl/bios configuration this might not always be the case. Signed-off-by: Henry Bruce Signed-off-by: Brendan Le Foll --- src/gpio/gpio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gpio/gpio.c b/src/gpio/gpio.c index d202aac..4231d28 100644 --- a/src/gpio/gpio.c +++ b/src/gpio/gpio.c @@ -75,6 +75,10 @@ mraa_gpio_init(int pin) } mraa_gpio_context r = mraa_gpio_init_raw(plat->pins[pin].gpio.pinmap); + if (r == NULL) { + syslog(LOG_CRIT, "gpio: mraa_setup_gpio(%d) returned error %d", pin, r); + return NULL; + } r->phy_pin = pin; if (advance_func->gpio_init_post != NULL) { -- 2.7.4