Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <Anson.Huang@nxp.com>
Link: https://lore.kernel.org/r/1584082751-17047-1-git-send-email-Anson.Huang@nxp.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Anson Huang and committed by
Dmitry Torokhov
768062fd 2ecf9487

+15 -18
+15 -18
drivers/input/keyboard/imx_sc_key.c
··· 99 99 msecs_to_jiffies(REPEAT_INTERVAL)); 100 100 } 101 101 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 + 102 111 static int imx_sc_key_probe(struct platform_device *pdev) 103 112 { 104 113 struct imx_key_drv_data *priv; ··· 158 149 return error; 159 150 } 160 151 152 + error = devm_add_action_or_reset(&pdev->dev, imx_sc_key_action, &priv); 153 + if (error) 154 + return error; 155 + 161 156 priv->key_notifier.notifier_call = imx_sc_key_notify; 162 157 error = imx_scu_irq_register_notifier(&priv->key_notifier); 163 - if (error) { 164 - imx_scu_irq_group_enable(SC_IRQ_GROUP_WAKE, SC_IRQ_BUTTON, 165 - false); 158 + if (error) 166 159 dev_err(&pdev->dev, "failed to register scu notifier\n"); 167 - return error; 168 - } 169 160 170 - return 0; 171 - } 172 - 173 - static int imx_sc_key_remove(struct platform_device *pdev) 174 - { 175 - struct imx_key_drv_data *priv = platform_get_drvdata(pdev); 176 - 177 - imx_scu_irq_group_enable(SC_IRQ_GROUP_WAKE, SC_IRQ_BUTTON, false); 178 - imx_scu_irq_unregister_notifier(&priv->key_notifier); 179 - cancel_delayed_work_sync(&priv->check_work); 180 - 181 - return 0; 161 + return error; 182 162 } 183 163 184 164 static const struct of_device_id imx_sc_key_ids[] = { ··· 182 184 .of_match_table = imx_sc_key_ids, 183 185 }, 184 186 .probe = imx_sc_key_probe, 185 - .remove = imx_sc_key_remove, 186 187 }; 187 188 module_platform_driver(imx_sc_key_driver); 188 189