Commit d33c4aa3 authored by Fabio Estevam's avatar Fabio Estevam Committed by Dmitry Torokhov

Input: max11801_ts - convert to devm

Converting to devm functions can make the code smaller and cleaner.
Signed-off-by: default avatarFabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent c9eb303b
...@@ -181,12 +181,11 @@ static int max11801_ts_probe(struct i2c_client *client, ...@@ -181,12 +181,11 @@ static int max11801_ts_probe(struct i2c_client *client,
struct input_dev *input_dev; struct input_dev *input_dev;
int error; int error;
data = kzalloc(sizeof(struct max11801_data), GFP_KERNEL); data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
input_dev = input_allocate_device(); input_dev = devm_input_allocate_device(&client->dev);
if (!data || !input_dev) { if (!data || !input_dev) {
dev_err(&client->dev, "Failed to allocate memory\n"); dev_err(&client->dev, "Failed to allocate memory\n");
error = -ENOMEM; return -ENOMEM;
goto err_free_mem;
} }
data->client = client; data->client = client;
...@@ -205,38 +204,21 @@ static int max11801_ts_probe(struct i2c_client *client, ...@@ -205,38 +204,21 @@ static int max11801_ts_probe(struct i2c_client *client,
max11801_ts_phy_init(data); max11801_ts_phy_init(data);
error = request_threaded_irq(client->irq, NULL, max11801_ts_interrupt, error = devm_request_threaded_irq(&client->dev, client->irq, NULL,
IRQF_TRIGGER_LOW | IRQF_ONESHOT, max11801_ts_interrupt,
"max11801_ts", data); IRQF_TRIGGER_LOW | IRQF_ONESHOT,
"max11801_ts", data);
if (error) { if (error) {
dev_err(&client->dev, "Failed to register interrupt\n"); dev_err(&client->dev, "Failed to register interrupt\n");
goto err_free_mem; return error;
} }
error = input_register_device(data->input_dev); error = input_register_device(data->input_dev);
if (error) if (error)
goto err_free_irq; return error;
i2c_set_clientdata(client, data); i2c_set_clientdata(client, data);
return 0; return 0;
err_free_irq:
free_irq(client->irq, data);
err_free_mem:
input_free_device(input_dev);
kfree(data);
return error;
}
static int max11801_ts_remove(struct i2c_client *client)
{
struct max11801_data *data = i2c_get_clientdata(client);
free_irq(client->irq, data);
input_unregister_device(data->input_dev);
kfree(data);
return 0;
} }
static const struct i2c_device_id max11801_ts_id[] = { static const struct i2c_device_id max11801_ts_id[] = {
...@@ -252,7 +234,6 @@ static struct i2c_driver max11801_ts_driver = { ...@@ -252,7 +234,6 @@ static struct i2c_driver max11801_ts_driver = {
}, },
.id_table = max11801_ts_id, .id_table = max11801_ts_id,
.probe = max11801_ts_probe, .probe = max11801_ts_probe,
.remove = max11801_ts_remove,
}; };
module_i2c_driver(max11801_ts_driver); module_i2c_driver(max11801_ts_driver);
......
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