Skip to content

Commit 30df385

Browse files
commododtor
authored andcommitted
Input: adp5589-keys - use devm_add_action_or_reset() for register clear
The driver clears the general configuration register during the remove() hook. This should also be done in case the driver exits on error. This change move the clear of that register to the devm_add_action_or_reset() hook. Signed-off-by: Alexandru Ardelean <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 74f2c59 commit 30df385

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

drivers/input/keyboard/adp5589-keys.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,14 @@ static int adp5589_keypad_add(struct adp5589_kpad *kpad, unsigned int revid)
934934
return 0;
935935
}
936936

937+
static void adp5589_clear_config(void *data)
938+
{
939+
struct i2c_client *client = data;
940+
struct adp5589_kpad *kpad = i2c_get_clientdata(client);
941+
942+
adp5589_write(client, kpad->var->reg(ADP5589_GENERAL_CFG), 0);
943+
}
944+
937945
static int adp5589_probe(struct i2c_client *client,
938946
const struct i2c_device_id *id)
939947
{
@@ -974,6 +982,11 @@ static int adp5589_probe(struct i2c_client *client,
974982
break;
975983
}
976984

985+
error = devm_add_action_or_reset(&client->dev, adp5589_clear_config,
986+
client);
987+
if (error)
988+
return error;
989+
977990
ret = adp5589_read(client, ADP5589_5_ID);
978991
if (ret < 0)
979992
return ret;
@@ -1003,15 +1016,6 @@ static int adp5589_probe(struct i2c_client *client,
10031016
return 0;
10041017
}
10051018

1006-
static int adp5589_remove(struct i2c_client *client)
1007-
{
1008-
struct adp5589_kpad *kpad = i2c_get_clientdata(client);
1009-
1010-
adp5589_write(client, kpad->var->reg(ADP5589_GENERAL_CFG), 0);
1011-
1012-
return 0;
1013-
}
1014-
10151019
#ifdef CONFIG_PM_SLEEP
10161020
static int adp5589_suspend(struct device *dev)
10171021
{
@@ -1063,7 +1067,6 @@ static struct i2c_driver adp5589_driver = {
10631067
.pm = &adp5589_dev_pm_ops,
10641068
},
10651069
.probe = adp5589_probe,
1066-
.remove = adp5589_remove,
10671070
.id_table = adp5589_id,
10681071
};
10691072

0 commit comments

Comments
 (0)