aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard/gpio_keys.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/keyboard/gpio_keys.c')
-rw-r--r--drivers/input/keyboard/gpio_keys.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 67df91af8424..ed1ed469d085 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -461,8 +461,7 @@ static int gpio_keys_get_devtree_pdata(struct device *dev,
461 struct device_node *node, *pp; 461 struct device_node *node, *pp;
462 int i; 462 int i;
463 struct gpio_keys_button *buttons; 463 struct gpio_keys_button *buttons;
464 const u32 *reg; 464 u32 reg;
465 int len;
466 465
467 node = dev->of_node; 466 node = dev->of_node;
468 if (node == NULL) 467 if (node == NULL)
@@ -470,7 +469,7 @@ static int gpio_keys_get_devtree_pdata(struct device *dev,
470 469
471 memset(pdata, 0, sizeof *pdata); 470 memset(pdata, 0, sizeof *pdata);
472 471
473 pdata->rep = !!of_get_property(node, "autorepeat", &len); 472 pdata->rep = !!of_get_property(node, "autorepeat", NULL);
474 473
475 /* First count the subnodes */ 474 /* First count the subnodes */
476 pdata->nbuttons = 0; 475 pdata->nbuttons = 0;
@@ -498,22 +497,25 @@ static int gpio_keys_get_devtree_pdata(struct device *dev,
498 buttons[i].gpio = of_get_gpio_flags(pp, 0, &flags); 497 buttons[i].gpio = of_get_gpio_flags(pp, 0, &flags);
499 buttons[i].active_low = flags & OF_GPIO_ACTIVE_LOW; 498 buttons[i].active_low = flags & OF_GPIO_ACTIVE_LOW;
500 499
501 reg = of_get_property(pp, "linux,code", &len); 500 if (of_property_read_u32(pp, "linux,code", &reg)) {
502 if (!reg) {
503 dev_err(dev, "Button without keycode: 0x%x\n", buttons[i].gpio); 501 dev_err(dev, "Button without keycode: 0x%x\n", buttons[i].gpio);
504 goto out_fail; 502 goto out_fail;
505 } 503 }
506 buttons[i].code = be32_to_cpup(reg); 504 buttons[i].code = reg;
507 505
508 buttons[i].desc = of_get_property(pp, "label", &len); 506 buttons[i].desc = of_get_property(pp, "label", NULL);
509 507
510 reg = of_get_property(pp, "linux,input-type", &len); 508 if (of_property_read_u32(pp, "linux,input-type", &reg) == 0)
511 buttons[i].type = reg ? be32_to_cpup(reg) : EV_KEY; 509 buttons[i].type = reg;
510 else
511 buttons[i].type = EV_KEY;
512 512
513 buttons[i].wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL); 513 buttons[i].wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL);
514 514
515 reg = of_get_property(pp, "debounce-interval", &len); 515 if (of_property_read_u32(pp, "debounce-interval", &reg) == 0)
516 buttons[i].debounce_interval = reg ? be32_to_cpup(reg) : 5; 516 buttons[i].debounce_interval = reg;
517 else
518 buttons[i].debounce_interval = 5;
517 519
518 i++; 520 i++;
519 } 521 }