gpio: fix null pointer exception when there is no oftree
In a system with oftree support enabled but with no oftree the
of_gpiochip_scan_hogs() would fail due to device_node equals NULL.

Check device_node and return with 0 in this situation, as this
mirrors what would have happened before we added support for gpio-hogs.

Use IS_ENABLED(CONFIG_OFDEVICE) to teach compiler to leave
out the of_* specific functions if not needed.

Fixes: 37e6bee7 ("gpiolib: Add support for GPIO "hog" nodes")
Signed-off-by: Alexander Kurz <akurz@blala.de>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
1 parent cd7d446 commit ea1bb5616b362adceec5df87dfb39d5973062afc
@Sam Ravnborg Sam Ravnborg authored on 3 Jul 2017
Lucas Stach committed on 14 Jul 2017
Showing 1 changed file
View
drivers/gpio/gpiolib.c