Commit 1ffb064e authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Dmitry Torokhov

Input: egalax_ts - move to devm_* functions

The usage of devm_* functions makes code cleaner and tidier.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 0c6a6165
...@@ -166,24 +166,22 @@ static int egalax_firmware_version(struct i2c_client *client) ...@@ -166,24 +166,22 @@ static int egalax_firmware_version(struct i2c_client *client)
} }
static int egalax_ts_probe(struct i2c_client *client, static int egalax_ts_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct egalax_ts *ts; struct egalax_ts *ts;
struct input_dev *input_dev; struct input_dev *input_dev;
int ret;
int error; int error;
ts = kzalloc(sizeof(struct egalax_ts), GFP_KERNEL); ts = devm_kzalloc(&client->dev, sizeof(struct egalax_ts), GFP_KERNEL);
if (!ts) { if (!ts) {
dev_err(&client->dev, "Failed to allocate memory\n"); dev_err(&client->dev, "Failed to allocate memory\n");
return -ENOMEM; return -ENOMEM;
} }
input_dev = input_allocate_device(); input_dev = devm_input_allocate_device(&client->dev);
if (!input_dev) { if (!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_ts;
} }
ts->client = client; ts->client = client;
...@@ -193,19 +191,17 @@ static int egalax_ts_probe(struct i2c_client *client, ...@@ -193,19 +191,17 @@ static int egalax_ts_probe(struct i2c_client *client,
error = egalax_wake_up_device(client); error = egalax_wake_up_device(client);
if (error) { if (error) {
dev_err(&client->dev, "Failed to wake up the controller\n"); dev_err(&client->dev, "Failed to wake up the controller\n");
goto err_free_dev; return error;
} }
ret = egalax_firmware_version(client); error = egalax_firmware_version(client);
if (ret < 0) { if (error < 0) {
dev_err(&client->dev, "Failed to read firmware version\n"); dev_err(&client->dev, "Failed to read firmware version\n");
error = -EIO; return error;
goto err_free_dev;
} }
input_dev->name = "EETI eGalax Touch Screen"; input_dev->name = "EETI eGalax Touch Screen";
input_dev->id.bustype = BUS_I2C; input_dev->id.bustype = BUS_I2C;
input_dev->dev.parent = &client->dev;
__set_bit(EV_ABS, input_dev->evbit); __set_bit(EV_ABS, input_dev->evbit);
__set_bit(EV_KEY, input_dev->evbit); __set_bit(EV_KEY, input_dev->evbit);
...@@ -221,41 +217,21 @@ static int egalax_ts_probe(struct i2c_client *client, ...@@ -221,41 +217,21 @@ static int egalax_ts_probe(struct i2c_client *client,
input_set_drvdata(input_dev, ts); input_set_drvdata(input_dev, ts);
error = request_threaded_irq(client->irq, NULL, egalax_ts_interrupt, error = devm_request_threaded_irq(&client->dev, client->irq, NULL,
IRQF_TRIGGER_LOW | IRQF_ONESHOT, egalax_ts_interrupt,
"egalax_ts", ts); IRQF_TRIGGER_LOW | IRQF_ONESHOT,
"egalax_ts", ts);
if (error < 0) { if (error < 0) {
dev_err(&client->dev, "Failed to register interrupt\n"); dev_err(&client->dev, "Failed to register interrupt\n");
goto err_free_dev; return error;
} }
error = input_register_device(ts->input_dev); error = input_register_device(ts->input_dev);
if (error) if (error)
goto err_free_irq; return error;
i2c_set_clientdata(client, ts); i2c_set_clientdata(client, ts);
return 0; return 0;
err_free_irq:
free_irq(client->irq, ts);
err_free_dev:
input_free_device(input_dev);
err_free_ts:
kfree(ts);
return error;
}
static int egalax_ts_remove(struct i2c_client *client)
{
struct egalax_ts *ts = i2c_get_clientdata(client);
free_irq(client->irq, ts);
input_unregister_device(ts->input_dev);
kfree(ts);
return 0;
} }
static const struct i2c_device_id egalax_ts_id[] = { static const struct i2c_device_id egalax_ts_id[] = {
...@@ -301,7 +277,6 @@ static struct i2c_driver egalax_ts_driver = { ...@@ -301,7 +277,6 @@ static struct i2c_driver egalax_ts_driver = {
}, },
.id_table = egalax_ts_id, .id_table = egalax_ts_id,
.probe = egalax_ts_probe, .probe = egalax_ts_probe,
.remove = egalax_ts_remove,
}; };
module_i2c_driver(egalax_ts_driver); module_i2c_driver(egalax_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