Commit fd91a5f0 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: tsc2007 - convert to use devres-managed resources

This simplifies error handling path and allows us get rid of
tsc2007_remove().
Tested-by: default avatarDenis Carikli <denis@eukrea.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent f261d465
...@@ -365,6 +365,14 @@ static int tsc2007_probe_pdev(struct i2c_client *client, struct tsc2007 *ts, ...@@ -365,6 +365,14 @@ static int tsc2007_probe_pdev(struct i2c_client *client, struct tsc2007 *ts,
return 0; return 0;
} }
static void tsc2007_call_exit_platform_hw(void *data)
{
struct device *dev = data;
const struct tsc2007_platform_data *pdata = dev_get_platdata(dev);
pdata->exit_platform_hw();
}
static int tsc2007_probe(struct i2c_client *client, static int tsc2007_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
...@@ -388,11 +396,9 @@ static int tsc2007_probe(struct i2c_client *client, ...@@ -388,11 +396,9 @@ static int tsc2007_probe(struct i2c_client *client,
if (err) if (err)
return err; return err;
input_dev = input_allocate_device(); input_dev = devm_input_allocate_device(&client->dev);
if (!input_dev) { if (!input_dev)
err = -ENOMEM; return -ENOMEM;
goto err_free_input;
};
i2c_set_clientdata(client, ts); i2c_set_clientdata(client, ts);
...@@ -421,45 +427,41 @@ static int tsc2007_probe(struct i2c_client *client, ...@@ -421,45 +427,41 @@ static int tsc2007_probe(struct i2c_client *client,
input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT, input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT,
ts->fuzzz, 0); ts->fuzzz, 0);
if (pdata && pdata->init_platform_hw) if (pdata) {
if (pdata->exit_platform_hw) {
err = devm_add_action(&client->dev,
tsc2007_call_exit_platform_hw,
&client->dev);
if (err) {
dev_err(&client->dev,
"Failed to register exit_platform_hw action, %d\n",
err);
return err;
}
}
if (pdata->init_platform_hw)
pdata->init_platform_hw(); pdata->init_platform_hw();
}
err = request_threaded_irq(ts->irq, tsc2007_hard_irq, tsc2007_soft_irq, err = devm_request_threaded_irq(&client->dev, ts->irq,
IRQF_ONESHOT, client->dev.driver->name, ts); tsc2007_hard_irq, tsc2007_soft_irq,
if (err < 0) { IRQF_ONESHOT,
dev_err(&client->dev, "irq %d busy?\n", ts->irq); client->dev.driver->name, ts);
goto err_free_input; if (err) {
dev_err(&client->dev, "Failed to request irq %d: %d\n",
ts->irq, err);
return err;
} }
tsc2007_stop(ts); tsc2007_stop(ts);
err = input_register_device(input_dev); err = input_register_device(input_dev);
if (err) if (err) {
goto err_free_irq; dev_err(&client->dev,
"Failed to register input device: %d\n", err);
return 0;
err_free_irq:
free_irq(ts->irq, ts);
if (pdata && pdata->exit_platform_hw)
pdata->exit_platform_hw();
err_free_input:
input_free_device(input_dev);
return err; return err;
} }
static int tsc2007_remove(struct i2c_client *client)
{
const struct tsc2007_platform_data *pdata = dev_get_platdata(&client->dev);
struct tsc2007 *ts = i2c_get_clientdata(client);
free_irq(ts->irq, ts);
if (pdata && pdata->exit_platform_hw)
pdata->exit_platform_hw();
input_unregister_device(ts->input);
kfree(ts);
return 0; return 0;
} }
...@@ -487,7 +489,6 @@ static struct i2c_driver tsc2007_driver = { ...@@ -487,7 +489,6 @@ static struct i2c_driver tsc2007_driver = {
}, },
.id_table = tsc2007_idtable, .id_table = tsc2007_idtable,
.probe = tsc2007_probe, .probe = tsc2007_probe,
.remove = tsc2007_remove,
}; };
module_i2c_driver(tsc2007_driver); module_i2c_driver(tsc2007_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