diff options
author | Hauke Mehrtens <hauke@openwrt.org> | 2015-07-26 15:52:17 +0000 |
---|---|---|
committer | Hauke Mehrtens <hauke@openwrt.org> | 2015-07-26 15:52:17 +0000 |
commit | 4604d0a22c160241211643d691df91f4a1913267 (patch) | |
tree | 4de5917084a433dd644966acee9288430351ca33 /package | |
parent | 0d08877a5d6a60fca48db8e2e4bdc26ed21da676 (diff) | |
download | master-187ad058-4604d0a22c160241211643d691df91f4a1913267.tar.gz master-187ad058-4604d0a22c160241211643d691df91f4a1913267.tar.bz2 master-187ad058-4604d0a22c160241211643d691df91f4a1913267.zip |
gpio-button-hotplug: handle EPROBE_DEFER and other errors
of_get_gpio_flags() could return an error like EPROBE_DEFER which was
not handled before. This patch takes the code from gpio_keys_polled.c
for error handling and also improves some other unrelated small parts.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@46502 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package')
-rw-r--r-- | package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c b/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c index c997e35803..029a388d0e 100644 --- a/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c +++ b/package/kernel/gpio-button-hotplug/src/gpio-button-hotplug.c @@ -101,8 +101,8 @@ static struct bh_map button_map[] = { /* -------------------------------------------------------------------------*/ -static int bh_event_add_var(struct bh_event *event, int argv, - const char *format, ...) +static __printf(3, 4) +int bh_event_add_var(struct bh_event *event, int argv, const char *format, ...) { static char buf[128]; char *s; @@ -117,8 +117,7 @@ static int bh_event_add_var(struct bh_event *event, int argv, va_end(args); if (len >= sizeof(buf)) { - BH_ERR("buffer size too small\n"); - WARN_ON(1); + WARN(1, "buffer size too small"); return -ENOMEM; } @@ -384,7 +383,18 @@ gpio_keys_get_devtree_pdata(struct device *dev) button = &pdata->buttons[i++]; button->gpio = of_get_gpio_flags(pp, 0, &flags); - button->active_low = flags & OF_GPIO_ACTIVE_LOW; + if (button->gpio < 0) { + error = button->gpio; + if (error != -ENOENT) { + if (error != -EPROBE_DEFER) + dev_err(dev, + "Failed to get gpio flags, error: %d\n", + error); + return ERR_PTR(error); + } + } else { + button->active_low = flags & OF_GPIO_ACTIVE_LOW; + } if (of_property_read_u32(pp, "linux,code", &button->code)) { dev_err(dev, "Button without keycode: 0x%x\n", |