Commit 20447664 authored by Nick Dyer's avatar Nick Dyer Committed by Dmitry Torokhov

Input: atmel_mxt_ts - improve device tree parsing

Use function rather than loop, define np to reduce wrapping.
Signed-off-by: default avatarNick Dyer <nick.dyer@itdev.co.uk>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 50fabb02
...@@ -2409,19 +2409,18 @@ static void mxt_input_close(struct input_dev *dev) ...@@ -2409,19 +2409,18 @@ static void mxt_input_close(struct input_dev *dev)
static const struct mxt_platform_data *mxt_parse_dt(struct i2c_client *client) static const struct mxt_platform_data *mxt_parse_dt(struct i2c_client *client)
{ {
struct mxt_platform_data *pdata; struct mxt_platform_data *pdata;
struct device_node *np = client->dev.of_node;
u32 *keymap; u32 *keymap;
u32 keycode; int proplen, ret;
int proplen, i, ret;
if (!client->dev.of_node) if (!np)
return ERR_PTR(-ENOENT); return ERR_PTR(-ENOENT);
pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata) if (!pdata)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
if (of_find_property(client->dev.of_node, "linux,gpio-keymap", if (of_find_property(np, "linux,gpio-keymap", &proplen)) {
&proplen)) {
pdata->t19_num_keys = proplen / sizeof(u32); pdata->t19_num_keys = proplen / sizeof(u32);
keymap = devm_kzalloc(&client->dev, keymap = devm_kzalloc(&client->dev,
...@@ -2430,14 +2429,11 @@ static const struct mxt_platform_data *mxt_parse_dt(struct i2c_client *client) ...@@ -2430,14 +2429,11 @@ static const struct mxt_platform_data *mxt_parse_dt(struct i2c_client *client)
if (!keymap) if (!keymap)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
for (i = 0; i < pdata->t19_num_keys; i++) { ret = of_property_read_u32_array(np, "linux,gpio-keymap",
ret = of_property_read_u32_index(client->dev.of_node, keymap, pdata->t19_num_keys);
"linux,gpio-keymap", i, &keycode); if (ret)
if (ret) dev_warn(&client->dev,
keycode = KEY_RESERVED; "Couldn't read linux,gpio-keymap: %d\n", ret);
keymap[i] = keycode;
}
pdata->t19_keymap = keymap; pdata->t19_keymap = keymap;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment