Skip to content

Commit 768062f

Browse files
Anson-Huangdtor
authored andcommitted
Input: imx_sc_key - use devm_add_action_or_reset() to handle all cleanups
Use devm_add_action_or_reset() to handle all cleanups of failure in .probe and .remove, then .remove callback can be dropped. Signed-off-by: Anson Huang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 2ecf948 commit 768062f

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

drivers/input/keyboard/imx_sc_key.c

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ static void imx_sc_check_for_events(struct work_struct *work)
9999
msecs_to_jiffies(REPEAT_INTERVAL));
100100
}
101101

102+
static void imx_sc_key_action(void *data)
103+
{
104+
struct imx_key_drv_data *priv = data;
105+
106+
imx_scu_irq_group_enable(SC_IRQ_GROUP_WAKE, SC_IRQ_BUTTON, false);
107+
imx_scu_irq_unregister_notifier(&priv->key_notifier);
108+
cancel_delayed_work_sync(&priv->check_work);
109+
}
110+
102111
static int imx_sc_key_probe(struct platform_device *pdev)
103112
{
104113
struct imx_key_drv_data *priv;
@@ -149,27 +158,16 @@ static int imx_sc_key_probe(struct platform_device *pdev)
149158
return error;
150159
}
151160

161+
error = devm_add_action_or_reset(&pdev->dev, imx_sc_key_action, &priv);
162+
if (error)
163+
return error;
164+
152165
priv->key_notifier.notifier_call = imx_sc_key_notify;
153166
error = imx_scu_irq_register_notifier(&priv->key_notifier);
154-
if (error) {
155-
imx_scu_irq_group_enable(SC_IRQ_GROUP_WAKE, SC_IRQ_BUTTON,
156-
false);
167+
if (error)
157168
dev_err(&pdev->dev, "failed to register scu notifier\n");
158-
return error;
159-
}
160-
161-
return 0;
162-
}
163-
164-
static int imx_sc_key_remove(struct platform_device *pdev)
165-
{
166-
struct imx_key_drv_data *priv = platform_get_drvdata(pdev);
167-
168-
imx_scu_irq_group_enable(SC_IRQ_GROUP_WAKE, SC_IRQ_BUTTON, false);
169-
imx_scu_irq_unregister_notifier(&priv->key_notifier);
170-
cancel_delayed_work_sync(&priv->check_work);
171169

172-
return 0;
170+
return error;
173171
}
174172

175173
static const struct of_device_id imx_sc_key_ids[] = {
@@ -184,7 +182,6 @@ static struct platform_driver imx_sc_key_driver = {
184182
.of_match_table = imx_sc_key_ids,
185183
},
186184
.probe = imx_sc_key_probe,
187-
.remove = imx_sc_key_remove,
188185
};
189186
module_platform_driver(imx_sc_key_driver);
190187

0 commit comments

Comments
 (0)