Commit 2b6aa9e7 authored by Yangtao Li's avatar Yangtao Li Committed by Dmitry Torokhov

Input: lm8333 - convert to use devm_* api

Use devm_* api to simplify code, this makes it unnecessary to explicitly
release resources.
Signed-off-by: default avatarYangtao Li <frank.li@vivo.com>
Link: https://lore.kernel.org/r/20230714080611.81302-1-frank.li@vivo.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent bf93349b
...@@ -142,18 +142,18 @@ static int lm8333_probe(struct i2c_client *client) ...@@ -142,18 +142,18 @@ static int lm8333_probe(struct i2c_client *client)
return -EINVAL; return -EINVAL;
} }
lm8333 = kzalloc(sizeof(*lm8333), GFP_KERNEL); lm8333 = devm_kzalloc(&client->dev, sizeof(*lm8333), GFP_KERNEL);
input = input_allocate_device(); if (!lm8333)
if (!lm8333 || !input) { return -ENOMEM;
err = -ENOMEM;
goto free_mem; input = devm_input_allocate_device(&client->dev);
} if (!input)
return -ENOMEM;
lm8333->client = client; lm8333->client = client;
lm8333->input = input; lm8333->input = input;
input->name = client->name; input->name = client->name;
input->dev.parent = &client->dev;
input->id.bustype = BUS_I2C; input->id.bustype = BUS_I2C;
input_set_capability(input, EV_MSC, MSC_SCAN); input_set_capability(input, EV_MSC, MSC_SCAN);
...@@ -162,7 +162,7 @@ static int lm8333_probe(struct i2c_client *client) ...@@ -162,7 +162,7 @@ static int lm8333_probe(struct i2c_client *client)
LM8333_NUM_ROWS, LM8333_NUM_COLS, LM8333_NUM_ROWS, LM8333_NUM_COLS,
lm8333->keycodes, input); lm8333->keycodes, input);
if (err) if (err)
goto free_mem; return err;
if (pdata->debounce_time) { if (pdata->debounce_time) {
err = lm8333_write8(lm8333, LM8333_DEBOUNCE, err = lm8333_write8(lm8333, LM8333_DEBOUNCE,
...@@ -178,34 +178,19 @@ static int lm8333_probe(struct i2c_client *client) ...@@ -178,34 +178,19 @@ static int lm8333_probe(struct i2c_client *client)
dev_warn(&client->dev, "Unable to set active time\n"); dev_warn(&client->dev, "Unable to set active time\n");
} }
err = request_threaded_irq(client->irq, NULL, lm8333_irq_thread, err = devm_request_threaded_irq(&client->dev, client->irq,
IRQF_TRIGGER_FALLING | IRQF_ONESHOT, NULL, lm8333_irq_thread,
"lm8333", lm8333); IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
"lm8333", lm8333);
if (err) if (err)
goto free_mem; return err;
err = input_register_device(input); err = input_register_device(input);
if (err) if (err)
goto free_irq; return err;
i2c_set_clientdata(client, lm8333); i2c_set_clientdata(client, lm8333);
return 0; return 0;
free_irq:
free_irq(client->irq, lm8333);
free_mem:
input_free_device(input);
kfree(lm8333);
return err;
}
static void lm8333_remove(struct i2c_client *client)
{
struct lm8333 *lm8333 = i2c_get_clientdata(client);
free_irq(client->irq, lm8333);
input_unregister_device(lm8333->input);
kfree(lm8333);
} }
static const struct i2c_device_id lm8333_id[] = { static const struct i2c_device_id lm8333_id[] = {
...@@ -219,7 +204,6 @@ static struct i2c_driver lm8333_driver = { ...@@ -219,7 +204,6 @@ static struct i2c_driver lm8333_driver = {
.name = "lm8333", .name = "lm8333",
}, },
.probe = lm8333_probe, .probe = lm8333_probe,
.remove = lm8333_remove,
.id_table = lm8333_id, .id_table = lm8333_id,
}; };
module_i2c_driver(lm8333_driver); module_i2c_driver(lm8333_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