input: keyboard: imx_sc_key: Use devm_add_action_or_reset() to handle all cleanups
Subsystems (3)
PATCH 1/1 input: keyboard: 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]>
--- drivers/input/keyboard/imx_sc_key.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-)
drivers/input/keyboard/imx_sc_key.c +15 -18
@@ -96,6 +96,15 @@ static void imx_sc_check_for_events(struct work_struct *work) msecs_to_jiffies(REPEAT_INTERVAL)); } +static void imx_sc_key_action (void *data) +{ +struct imx_key_drv_data *priv = data; + +imx_scu_irq_group_enable (SC_IRQ_GROUP_WAKE ,SC_IRQ_BUTTON , false); +imx_scu_irq_unregister_notifier (&priv->key_notifier); +cancel_delayed_work_sync (&priv->check_work); +} +static int imx_sc_key_probe (struct platform_device *pdev) {struct imx_key_drv_data *priv;
@@ -146,27 +155,16 @@ static int imx_sc_key_probe(struct platform_device *pdev)return error; } + error =devm_add_action_or_reset (&pdev->dev, imx_sc_key_action, &priv); +if (error) +return error; + priv->key_notifier.notifier_call = imx_sc_key_notify; error =imx_scu_irq_register_notifier (&priv->key_notifier); -if (error) { -imx_scu_irq_group_enable (SC_IRQ_GROUP_WAKE ,SC_IRQ_BUTTON , - false); +if (error)dev_err (&pdev->dev,"failed to register scu notifier\n" ); -return error; - } - -return 0 ; -} - -static int imx_sc_key_remove (struct platform_device *pdev) -{ -struct imx_key_drv_data *priv =platform_get_drvdata (pdev); - -imx_scu_irq_group_enable (SC_IRQ_GROUP_WAKE ,SC_IRQ_BUTTON , false); -imx_scu_irq_unregister_notifier (&priv->key_notifier); -cancel_delayed_work_sync (&priv->check_work); -return 0 ; +return error; }static const struct of_device_id imx_sc_key_ids[] = {
@@ -181,7 +179,6 @@ static struct platform_driver imx_sc_key_driver = { .of_match_table = imx_sc_key_ids, }, .probe = imx_sc_key_probe, - .remove = imx_sc_key_remove, };module_platform_driver (imx_sc_key_driver);
Signature · 1 line
2.7.4
Gentle ping...
Quoted 79 lines
Subject: [PATCH] input: keyboard:
imx_sc_key: Usedevm_add_action_or_reset()to handle all cleanupsUse
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]>--- drivers/input/keyboard/imx_sc_key.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-)drivers/input/keyboard/imx_sc_key.c +14
-16@@ -96,6 +96,15 @@ static void imx_sc_check_for_events(struct work_struct *work) msecs_to_jiffies(REPEAT_INTERVAL)); } +static void imx_sc_key_action (void *data) { +struct imx_key_drv_data *priv = data; + +imx_scu_irq_group_enable (SC_IRQ_GROUP_WAKE ,SC_IRQ_BUTTON , false); +imx_scu_irq_unregister_notifier (&priv->key_notifier); +cancel_delayed_work_sync (&priv->check_work); +} +static int imx_sc_key_probe (struct platform_device *pdev) {struct imx_key_drv_data *priv;@@ -146,27 +155,16 @@ static int imx_sc_key_probe(struct platform_device *pdev)return error; } + error =devm_add_action_or_reset (&pdev->dev, imx_sc_key_action, &priv); +if (error) +return error; + priv->key_notifier.notifier_call = imx_sc_key_notify; error =imx_scu_irq_register_notifier (&priv->key_notifier); -if (error) { -imx_scu_irq_group_enable (SC_IRQ_GROUP_WAKE ,SC_IRQ_BUTTON , - false); + if (error)dev_err (&pdev->dev,"failed to register scu notifier\n" ); -return error; - } - -return 0 ; -} - -static int imx_sc_key_remove(struct platform_device *pdev) -{ -struct imx_key_drv_data *priv =platform_get_drvdata (pdev); - -imx_scu_irq_group_enable (SC_IRQ_GROUP_WAKE ,SC_IRQ_BUTTON , false); -imx_scu_irq_unregister_notifier (&priv->key_notifier); -cancel_delayed_work_sync (&priv->check_work); -return 0 ; +return error; } static const struct of_device_id imx_sc_key_ids[] = { @@ -181,7 +179,6 @@static struct
platform_driverimx_sc_key_driver= {drivers/input/keyboard/imx_sc_key.c +0
-2.of_match_table = imx_sc_key_ids, }, .probe = imx_sc_key_probe, - .remove = imx_sc_key_remove, };module_platform_driver (imx_sc_key_driver); --2.7.4
Quoted 4 lines · Anson Huang
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]>
Applied, thank you.
Signature · 1 line
Dmitry