提交 cca84699 编写于 作者: T Tobias Klauser 提交者: Dmitry Torokhov

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: NTobias Klauser <tklauser@distanz.ch>
Signed-off-by: NDmitry Torokhov <dtor@mail.ru>
上级 c3a01ba9
...@@ -461,8 +461,7 @@ static int gpio_keys_get_devtree_pdata(struct device *dev, ...@@ -461,8 +461,7 @@ static int gpio_keys_get_devtree_pdata(struct device *dev,
struct device_node *node, *pp; struct device_node *node, *pp;
int i; int i;
struct gpio_keys_button *buttons; struct gpio_keys_button *buttons;
const u32 *reg; u32 reg;
int len;
node = dev->of_node; node = dev->of_node;
if (node == NULL) if (node == NULL)
...@@ -470,7 +469,7 @@ static int gpio_keys_get_devtree_pdata(struct device *dev, ...@@ -470,7 +469,7 @@ static int gpio_keys_get_devtree_pdata(struct device *dev,
memset(pdata, 0, sizeof *pdata); memset(pdata, 0, sizeof *pdata);
pdata->rep = !!of_get_property(node, "autorepeat", &len); pdata->rep = !!of_get_property(node, "autorepeat", NULL);
/* First count the subnodes */ /* First count the subnodes */
pdata->nbuttons = 0; pdata->nbuttons = 0;
...@@ -498,22 +497,25 @@ static int gpio_keys_get_devtree_pdata(struct device *dev, ...@@ -498,22 +497,25 @@ static int gpio_keys_get_devtree_pdata(struct device *dev,
buttons[i].gpio = of_get_gpio_flags(pp, 0, &flags); buttons[i].gpio = of_get_gpio_flags(pp, 0, &flags);
buttons[i].active_low = flags & OF_GPIO_ACTIVE_LOW; buttons[i].active_low = flags & OF_GPIO_ACTIVE_LOW;
reg = of_get_property(pp, "linux,code", &len); if (of_property_read_u32(pp, "linux,code", &reg)) {
if (!reg) {
dev_err(dev, "Button without keycode: 0x%x\n", buttons[i].gpio); dev_err(dev, "Button without keycode: 0x%x\n", buttons[i].gpio);
goto out_fail; goto out_fail;
} }
buttons[i].code = be32_to_cpup(reg); buttons[i].code = reg;
buttons[i].desc = of_get_property(pp, "label", &len); buttons[i].desc = of_get_property(pp, "label", NULL);
reg = of_get_property(pp, "linux,input-type", &len); if (of_property_read_u32(pp, "linux,input-type", &reg) == 0)
buttons[i].type = reg ? be32_to_cpup(reg) : EV_KEY; buttons[i].type = reg;
else
buttons[i].type = EV_KEY;
buttons[i].wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL); buttons[i].wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL);
reg = of_get_property(pp, "debounce-interval", &len); if (of_property_read_u32(pp, "debounce-interval", &reg) == 0)
buttons[i].debounce_interval = reg ? be32_to_cpup(reg) : 5; buttons[i].debounce_interval = reg;
else
buttons[i].debounce_interval = 5;
i++; i++;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册