Commit 93afb1d6 authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Benson Leung

Input: atmel_mxt_ts - switch from OF to generic device properties

Instead of using OF-specific APIs to fecth device properties, let's switch
to generic device properties API. This will allow us to use device
properties on legacy ChromeOS devices and get rid of platform data down
the road.
Acked-by: default avatarNick Dyer <nick@shmanahar.org>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: default avatarBenson Leung <bleung@chromium.org>
parent d80808e1
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/property.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
#include <media/v4l2-device.h> #include <media/v4l2-device.h>
#include <media/v4l2-ioctl.h> #include <media/v4l2-ioctl.h>
...@@ -2922,47 +2923,52 @@ static void mxt_input_close(struct input_dev *dev) ...@@ -2922,47 +2923,52 @@ static void mxt_input_close(struct input_dev *dev)
mxt_stop(data); mxt_stop(data);
} }
#ifdef CONFIG_OF static const struct mxt_platform_data *
static const struct mxt_platform_data *mxt_parse_dt(struct i2c_client *client) mxt_parse_device_properties(struct i2c_client *client)
{ {
static const char keymap_property[] = "linux,gpio-keymap";
struct mxt_platform_data *pdata; struct mxt_platform_data *pdata;
struct device_node *np = client->dev.of_node;
u32 *keymap; u32 *keymap;
int proplen, ret; int n_keys;
int error;
if (!np)
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(np, "linux,gpio-keymap", &proplen)) { if (device_property_present(&client->dev, keymap_property)) {
pdata->t19_num_keys = proplen / sizeof(u32); n_keys = device_property_read_u32_array(&client->dev,
keymap_property,
NULL, 0);
if (n_keys <= 0) {
error = n_keys < 0 ? n_keys : -EINVAL;
dev_err(&client->dev,
"invalid/malformed '%s' property: %d\n",
keymap_property, error);
return ERR_PTR(error);
}
keymap = devm_kzalloc(&client->dev, keymap = devm_kmalloc_array(&client->dev, n_keys, sizeof(u32),
pdata->t19_num_keys * sizeof(keymap[0]),
GFP_KERNEL); GFP_KERNEL);
if (!keymap) if (!keymap)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
ret = of_property_read_u32_array(np, "linux,gpio-keymap", error = device_property_read_u32_array(&client->dev,
keymap, pdata->t19_num_keys); keymap_property,
if (ret) keymap, n_keys);
dev_warn(&client->dev, if (error) {
"Couldn't read linux,gpio-keymap: %d\n", ret); dev_err(&client->dev,
"failed to parse '%s' property: %d\n",
keymap_property, error);
return ERR_PTR(error);
}
pdata->t19_keymap = keymap; pdata->t19_keymap = keymap;
pdata->t19_num_keys = n_keys;
} }
return pdata; return pdata;
} }
#else
static const struct mxt_platform_data *mxt_parse_dt(struct i2c_client *client)
{
return ERR_PTR(-ENOENT);
}
#endif
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
...@@ -3096,16 +3102,11 @@ mxt_get_platform_data(struct i2c_client *client) ...@@ -3096,16 +3102,11 @@ mxt_get_platform_data(struct i2c_client *client)
if (pdata) if (pdata)
return pdata; return pdata;
pdata = mxt_parse_dt(client);
if (!IS_ERR(pdata) || PTR_ERR(pdata) != -ENOENT)
return pdata;
pdata = mxt_parse_acpi(client); pdata = mxt_parse_acpi(client);
if (!IS_ERR(pdata) || PTR_ERR(pdata) != -ENOENT) if (!IS_ERR(pdata) || PTR_ERR(pdata) != -ENOENT)
return pdata; return pdata;
dev_err(&client->dev, "No platform data specified\n"); return mxt_parse_device_properties(client);
return ERR_PTR(-EINVAL);
} }
static const struct dmi_system_id chromebook_T9_suspend_dmi[] = { static const struct dmi_system_id chromebook_T9_suspend_dmi[] = {
......
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