pinctrl: qcom: switch to devm_register_sys_off_handler()
authorDmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Tue, 13 May 2025 18:38:58 +0000 (21:38 +0300)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 20 May 2025 21:41:29 +0000 (23:41 +0200)
Error-handling paths in msm_pinctrl_probe() don't call
a function required to unroll restart handler registration,
unregister_restart_handler(). Instead of adding calls to this function,
switch the msm pinctrl code into using devm_register_sys_off_handler().

Fixes: cf1fc1876289 ("pinctrl: qcom: use restart_notifier mechanism for ps_hold")
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Link: https://lore.kernel.org/20250513-pinctrl-msm-fix-v2-2-249999af0fc1@oss.qualcomm.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/qcom/pinctrl-msm.c

index 82f0cc4..0eb8163 100644 (file)
@@ -44,7 +44,6 @@
  * @pctrl:          pinctrl handle.
  * @chip:           gpiochip handle.
  * @desc:           pin controller descriptor
- * @restart_nb:     restart notifier block.
  * @irq:            parent irq for the TLMM irq_chip.
  * @intr_target_use_scm: route irq to application cpu using scm calls
  * @lock:           Spinlock to protect register resources as well
@@ -64,7 +63,6 @@ struct msm_pinctrl {
        struct pinctrl_dev *pctrl;
        struct gpio_chip chip;
        struct pinctrl_desc desc;
-       struct notifier_block restart_nb;
 
        int irq;
 
@@ -1471,10 +1469,9 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)
        return 0;
 }
 
-static int msm_ps_hold_restart(struct notifier_block *nb, unsigned long action,
-                              void *data)
+static int msm_ps_hold_restart(struct sys_off_data *data)
 {
-       struct msm_pinctrl *pctrl = container_of(nb, struct msm_pinctrl, restart_nb);
+       struct msm_pinctrl *pctrl = data->cb_data;
 
        writel(0, pctrl->regs[0] + PS_HOLD_OFFSET);
        mdelay(1000);
@@ -1485,7 +1482,11 @@ static struct msm_pinctrl *poweroff_pctrl;
 
 static void msm_ps_hold_poweroff(void)
 {
-       msm_ps_hold_restart(&poweroff_pctrl->restart_nb, 0, NULL);
+       struct sys_off_data data = {
+               .cb_data = poweroff_pctrl,
+       };
+
+       msm_ps_hold_restart(&data);
 }
 
 static void msm_pinctrl_setup_pm_reset(struct msm_pinctrl *pctrl)
@@ -1495,9 +1496,11 @@ static void msm_pinctrl_setup_pm_reset(struct msm_pinctrl *pctrl)
 
        for (i = 0; i < pctrl->soc->nfunctions; i++)
                if (!strcmp(func[i].name, "ps_hold")) {
-                       pctrl->restart_nb.notifier_call = msm_ps_hold_restart;
-                       pctrl->restart_nb.priority = 128;
-                       if (register_restart_handler(&pctrl->restart_nb))
+                       if (devm_register_sys_off_handler(pctrl->dev,
+                                                         SYS_OFF_MODE_RESTART,
+                                                         128,
+                                                         msm_ps_hold_restart,
+                                                         pctrl))
                                dev_err(pctrl->dev,
                                        "failed to setup restart handler.\n");
                        poweroff_pctrl = pctrl;
@@ -1599,8 +1602,6 @@ void msm_pinctrl_remove(struct platform_device *pdev)
        struct msm_pinctrl *pctrl = platform_get_drvdata(pdev);
 
        gpiochip_remove(&pctrl->chip);
-
-       unregister_restart_handler(&pctrl->restart_nb);
 }
 EXPORT_SYMBOL(msm_pinctrl_remove);