[06/18] power: reset: brcm-kona-reset: Use devm_register_sys_off_handler(RESTART)

Message ID 20240201180102.70395-7-afd@ti.com
State New
Headers
Series Remove pm_power_off use in drivers/power/reset |

Commit Message

Andrew Davis Feb. 1, 2024, 6 p.m. UTC
  Use device life-cycle managed register function to simplify probe.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/power/reset/brcm-kona-reset.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
  

Comments

kernel test robot Feb. 2, 2024, 3:42 p.m. UTC | #1
Hi Andrew,

kernel test robot noticed the following build warnings:

[auto build test WARNING on sre-power-supply/for-next]
[also build test WARNING on mani-mhi/mhi-next soc/for-next linus/master v6.8-rc2 next-20240202]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Andrew-Davis/power-reset-atc260x-poweroff-Use-devm_register_sys_off_handler-RESTART/20240202-020809
base:   https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next
patch link:    https://lore.kernel.org/r/20240201180102.70395-7-afd%40ti.com
patch subject: [PATCH 06/18] power: reset: brcm-kona-reset: Use devm_register_sys_off_handler(RESTART)
config: arm-randconfig-r121-20240202 (https://download.01.org/0day-ci/archive/20240202/202402022349.daHRuWLB-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20240202/202402022349.daHRuWLB-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202402022349.daHRuWLB-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> drivers/power/reset/brcm-kona-reset.c:18:45: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void [noderef] __iomem *kona_reset_base @@     got void *cb_data @@
   drivers/power/reset/brcm-kona-reset.c:18:45: sparse:     expected void [noderef] __iomem *kona_reset_base
   drivers/power/reset/brcm-kona-reset.c:18:45: sparse:     got void *cb_data
>> drivers/power/reset/brcm-kona-reset.c:43:46: sparse: sparse: incorrect type in argument 5 (different address spaces) @@     expected void *cb_data @@     got void [noderef] __iomem *[assigned] kona_reset_base @@
   drivers/power/reset/brcm-kona-reset.c:43:46: sparse:     expected void *cb_data
   drivers/power/reset/brcm-kona-reset.c:43:46: sparse:     got void [noderef] __iomem *[assigned] kona_reset_base

vim +18 drivers/power/reset/brcm-kona-reset.c

    15	
    16	static int kona_reset_handler(struct sys_off_data *data)
    17	{
  > 18		void __iomem *kona_reset_base = data->cb_data;
    19	
    20		/*
    21		 * A soft reset is triggered by writing a 0 to bit 0 of the soft reset
    22		 * register. To write to that register we must first write the password
    23		 * and the enable bit in the write access enable register.
    24		 */
    25		writel((RSTMGR_WR_PASSWORD << RSTMGR_WR_PASSWORD_SHIFT) |
    26			RSTMGR_WR_ACCESS_ENABLE,
    27			kona_reset_base + RSTMGR_REG_WR_ACCESS_OFFSET);
    28		writel(0, kona_reset_base + RSTMGR_REG_CHIP_SOFT_RST_OFFSET);
    29	
    30		return NOTIFY_DONE;
    31	}
    32	
    33	static int kona_reset_probe(struct platform_device *pdev)
    34	{
    35		void __iomem *kona_reset_base;
    36	
    37		kona_reset_base = devm_platform_ioremap_resource(pdev, 0);
    38		if (IS_ERR(kona_reset_base))
    39			return PTR_ERR(kona_reset_base);
    40	
    41		return devm_register_sys_off_handler(&pdev->dev, SYS_OFF_MODE_RESTART,
    42						     128, kona_reset_handler,
  > 43						     kona_reset_base);
    44	}
    45
  

Patch

diff --git a/drivers/power/reset/brcm-kona-reset.c b/drivers/power/reset/brcm-kona-reset.c
index d05728b1db097..4bb956c8f24f8 100644
--- a/drivers/power/reset/brcm-kona-reset.c
+++ b/drivers/power/reset/brcm-kona-reset.c
@@ -13,11 +13,10 @@ 
 #define RSTMGR_WR_PASSWORD_SHIFT	8
 #define RSTMGR_WR_ACCESS_ENABLE		1
 
-static void __iomem *kona_reset_base;
-
-static int kona_reset_handler(struct notifier_block *this,
-				unsigned long mode, void *cmd)
+static int kona_reset_handler(struct sys_off_data *data)
 {
+	void __iomem *kona_reset_base = data->cb_data;
+
 	/*
 	 * A soft reset is triggered by writing a 0 to bit 0 of the soft reset
 	 * register. To write to that register we must first write the password
@@ -31,18 +30,17 @@  static int kona_reset_handler(struct notifier_block *this,
 	return NOTIFY_DONE;
 }
 
-static struct notifier_block kona_reset_nb = {
-	.notifier_call = kona_reset_handler,
-	.priority = 128,
-};
-
 static int kona_reset_probe(struct platform_device *pdev)
 {
+	void __iomem *kona_reset_base;
+
 	kona_reset_base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(kona_reset_base))
 		return PTR_ERR(kona_reset_base);
 
-	return register_restart_handler(&kona_reset_nb);
+	return devm_register_sys_off_handler(&pdev->dev, SYS_OFF_MODE_RESTART,
+					     128, kona_reset_handler,
+					     kona_reset_base);
 }
 
 static const struct of_device_id of_match[] = {