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> SVN-Revision: 46502
This commit is contained in:
parent
ab63719eb2
commit
886764657a
1 changed files with 15 additions and 5 deletions
|
@ -101,8 +101,8 @@ static struct bh_map button_map[] = {
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------*/
|
/* -------------------------------------------------------------------------*/
|
||||||
|
|
||||||
static int bh_event_add_var(struct bh_event *event, int argv,
|
static __printf(3, 4)
|
||||||
const char *format, ...)
|
int bh_event_add_var(struct bh_event *event, int argv, const char *format, ...)
|
||||||
{
|
{
|
||||||
static char buf[128];
|
static char buf[128];
|
||||||
char *s;
|
char *s;
|
||||||
|
@ -117,8 +117,7 @@ static int bh_event_add_var(struct bh_event *event, int argv,
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
if (len >= sizeof(buf)) {
|
if (len >= sizeof(buf)) {
|
||||||
BH_ERR("buffer size too small\n");
|
WARN(1, "buffer size too small");
|
||||||
WARN_ON(1);
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,7 +383,18 @@ gpio_keys_get_devtree_pdata(struct device *dev)
|
||||||
button = &pdata->buttons[i++];
|
button = &pdata->buttons[i++];
|
||||||
|
|
||||||
button->gpio = of_get_gpio_flags(pp, 0, &flags);
|
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)) {
|
if (of_property_read_u32(pp, "linux,code", &button->code)) {
|
||||||
dev_err(dev, "Button without keycode: 0x%x\n",
|
dev_err(dev, "Button without keycode: 0x%x\n",
|
||||||
|
|
Loading…
Reference in a new issue