diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2011-09-09 14:09:50 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-09-21 01:46:32 -0400 |
commit | cca84699a079a91b0a0cb4f2da8548e56859376a (patch) | |
tree | cbce1c7311de1f9a739e489101ab19a4555f3d09 /drivers/input/keyboard/gpio_keys.c | |
parent | c3a01ba9e45f01c6505a41efb33c420a0c959eb3 (diff) |
Input: gpio_keys - use of_property_read_u32()
Use the of_property_read_u32() helper function to retrieve u32 values
from the device tree. Also do not pass the len parameter to
of_get_property if it isn't checked afterwards.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/keyboard/gpio_keys.c')
-rw-r--r-- | drivers/input/keyboard/gpio_keys.c | 24 |
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", ®)) { |
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", ®) == 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", ®) == 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 | } |