* [PATCH] power: reset: at91: Use devm_clk_get_enabled() in three probe functions
@ 2026-11-24 8:50 Markus Elfring
2026-11-24 14:35 ` kernel test robot
0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2026-11-24 8:50 UTC (permalink / raw)
To: linux-pm, linux-arm-kernel, Alexandre Belloni, Claudiu Beznea,
Nicolas Ferre, Sebastian Reichel
Cc: LKML, kernel-janitors, Andy Shevchenko, Christophe Jaillet,
Florian Fainelli, Frank Li, Philipp Zabel
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 24 Nov 2026 09:23:44 +0100
* Reuse existing functionality from devm_clk_get_enabled() instead of
keeping duplicate source code.
* Delete a clk_disable_unprepare() call on error handling paths
and in the implementation of three remove functions.
* Omit the label “clk_disable”.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/power/reset/at91-poweroff.c | 20 +++----------------
drivers/power/reset/at91-reset.c | 17 +++-------------
drivers/power/reset/at91-sama5d2_shdwc.c | 25 +++++-------------------
3 files changed, 11 insertions(+), 51 deletions(-)
diff --git a/drivers/power/reset/at91-poweroff.c b/drivers/power/reset/at91-poweroff.c
index 7bc779055cf3..ffbaba309917 100644
--- a/drivers/power/reset/at91-poweroff.c
+++ b/drivers/power/reset/at91-poweroff.c
@@ -159,16 +159,10 @@ static int at91_poweroff_probe(struct platform_device *pdev)
if (IS_ERR(at91_shdwc.shdwc_base))
return PTR_ERR(at91_shdwc.shdwc_base);
- at91_shdwc.sclk = devm_clk_get(&pdev->dev, NULL);
+ at91_shdwc.sclk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(at91_shdwc.sclk))
return PTR_ERR(at91_shdwc.sclk);
- ret = clk_prepare_enable(at91_shdwc.sclk);
- if (ret) {
- dev_err(&pdev->dev, "Could not enable slow clock\n");
- return ret;
- }
-
at91_wakeup_status(pdev);
if (pdev->dev.of_node)
@@ -179,10 +173,8 @@ static int at91_poweroff_probe(struct platform_device *pdev)
at91_shdwc.mpddrc_base = of_iomap(np, 0);
of_node_put(np);
- if (!at91_shdwc.mpddrc_base) {
- ret = -ENOMEM;
- goto clk_disable;
- }
+ if (!at91_shdwc.mpddrc_base)
+ return -ENOMEM;
ddr_type = readl(at91_shdwc.mpddrc_base + AT91_DDRSDRC_MDR) &
AT91_DDRSDRC_MD;
@@ -196,10 +188,6 @@ static int at91_poweroff_probe(struct platform_device *pdev)
pm_power_off = at91_poweroff;
return 0;
-
-clk_disable:
- clk_disable_unprepare(at91_shdwc.sclk);
- return ret;
}
static void at91_poweroff_remove(struct platform_device *pdev)
@@ -209,8 +197,6 @@ static void at91_poweroff_remove(struct platform_device *pdev)
if (at91_shdwc.mpddrc_base)
iounmap(at91_shdwc.mpddrc_base);
-
- clk_disable_unprepare(at91_shdwc.sclk);
}
static const struct of_device_id at91_poweroff_of_match[] = {
diff --git a/drivers/power/reset/at91-reset.c b/drivers/power/reset/at91-reset.c
index a9ad43217f48..bcf77a5162f1 100644
--- a/drivers/power/reset/at91-reset.c
+++ b/drivers/power/reset/at91-reset.c
@@ -374,21 +374,15 @@ static int at91_reset_probe(struct platform_device *pdev)
reset->nb.notifier_call = at91_reset;
reset->nb.priority = 192;
- reset->sclk = devm_clk_get(&pdev->dev, NULL);
+ reset->sclk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(reset->sclk))
return PTR_ERR(reset->sclk);
- ret = clk_prepare_enable(reset->sclk);
- if (ret) {
- dev_err(&pdev->dev, "Could not enable slow clock\n");
- return ret;
- }
-
platform_set_drvdata(pdev, reset);
ret = at91_rcdev_init(reset, pdev);
if (ret)
- goto disable_clk;
+ return ret;
if (of_device_is_compatible(pdev->dev.of_node, "microchip,sam9x60-rstc")) {
u32 val = readl(reset->rstc_base + AT91_RSTC_MR);
@@ -399,7 +393,7 @@ static int at91_reset_probe(struct platform_device *pdev)
ret = register_restart_handler(&reset->nb);
if (ret)
- goto disable_clk;
+ return ret;
ret = device_create_file(&pdev->dev, &dev_attr_power_on_reason);
if (ret) {
@@ -410,10 +404,6 @@ static int at91_reset_probe(struct platform_device *pdev)
dev_info(&pdev->dev, "Starting after %s\n", at91_reset_reason(reset));
return 0;
-
-disable_clk:
- clk_disable_unprepare(reset->sclk);
- return ret;
}
static void at91_reset_remove(struct platform_device *pdev)
@@ -421,7 +411,6 @@ static void at91_reset_remove(struct platform_device *pdev)
struct at91_reset *reset = platform_get_drvdata(pdev);
unregister_restart_handler(&reset->nb);
- clk_disable_unprepare(reset->sclk);
}
static struct platform_driver at91_reset_driver = {
diff --git a/drivers/power/reset/at91-sama5d2_shdwc.c b/drivers/power/reset/at91-sama5d2_shdwc.c
index 589599cca076..cab94ef5a8a0 100644
--- a/drivers/power/reset/at91-sama5d2_shdwc.c
+++ b/drivers/power/reset/at91-sama5d2_shdwc.c
@@ -357,33 +357,23 @@ static int at91_shdwc_probe(struct platform_device *pdev)
match = of_match_node(at91_shdwc_of_match, pdev->dev.of_node);
at91_shdwc->rcfg = match->data;
- at91_shdwc->sclk = devm_clk_get(&pdev->dev, NULL);
+ at91_shdwc->sclk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(at91_shdwc->sclk))
return PTR_ERR(at91_shdwc->sclk);
- ret = clk_prepare_enable(at91_shdwc->sclk);
- if (ret) {
- dev_err(&pdev->dev, "Could not enable slow clock\n");
- return ret;
- }
-
at91_wakeup_status(pdev);
at91_shdwc_dt_configure(pdev);
np = of_find_matching_node(NULL, at91_pmc_ids);
- if (!np) {
- ret = -ENODEV;
- goto clk_disable;
- }
+ if (!np)
+ return -ENODEV;
at91_shdwc->pmc_base = of_iomap(np, 0);
of_node_put(np);
- if (!at91_shdwc->pmc_base) {
- ret = -ENOMEM;
- goto clk_disable;
- }
+ if (!at91_shdwc->pmc_base)
+ return -ENOMEM;
if (at91_shdwc->rcfg->ddrc.type_mask) {
np = of_find_compatible_node(NULL, NULL,
@@ -417,9 +407,6 @@ static int at91_shdwc_probe(struct platform_device *pdev)
unmap:
iounmap(at91_shdwc->pmc_base);
-clk_disable:
- clk_disable_unprepare(at91_shdwc->sclk);
-
return ret;
}
@@ -437,8 +424,6 @@ static void at91_shdwc_remove(struct platform_device *pdev)
if (shdw->mpddrc_base)
iounmap(shdw->mpddrc_base);
iounmap(shdw->pmc_base);
-
- clk_disable_unprepare(shdw->sclk);
}
static struct platform_driver at91_shdwc_driver = {
--
2.56.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] power: reset: at91: Use devm_clk_get_enabled() in three probe functions
2026-11-24 8:50 [PATCH] power: reset: at91: Use devm_clk_get_enabled() in three probe functions Markus Elfring
@ 2026-11-24 14:35 ` kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2026-11-24 14:35 UTC (permalink / raw)
To: Markus Elfring, linux-pm, linux-arm-kernel, Alexandre Belloni,
Claudiu Beznea, Nicolas Ferre, Sebastian Reichel
Cc: llvm, oe-kbuild-all, LKML, kernel-janitors, Andy Shevchenko,
Christophe Jaillet, Florian Fainelli, Frank Li, Philipp Zabel
Hi Markus,
kernel test robot noticed the following build warnings:
[auto build test WARNING on sre-power-supply/for-next]
[also build test WARNING on amd-pstate/linux-next amd-pstate/bleeding-edge clk/clk-next soc/for-next nferre-at91/at91-next linus/master v7.4-rc4 next-20261123]
[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/Markus-Elfring/power-reset-at91-Use-devm_clk_get_enabled-in-three-probe-functions/20261124-095011
base: https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next
patch link: https://lore.kernel.org/r/de6c1040-c4d1-4703-9932-b3b668801c72%40web.de
patch subject: [PATCH] power: reset: at91: Use devm_clk_get_enabled() in three probe functions
config: arm-defconfig (https://download.01.org/0day-ci/archive/20261124/20261124222203.k0pVspdI-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 2012344e5da8e03ea4b8283ecd6fad6e13f09d64)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261124/20261124222203.k0pVspdI-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/20261124222203.k0pVspdI-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/power/reset/at91-poweroff.c:156:6: warning: unused variable 'ret' [-Wunused-variable]
156 | int ret;
| ^~~
1 warning generated.
vim +/ret +156 drivers/power/reset/at91-poweroff.c
ae499f0fadaf28b Maxime Ripard 2014-07-03 151
099806de68b75a0 Uwe Kleine-König 2023-11-04 152 static int at91_poweroff_probe(struct platform_device *pdev)
ae499f0fadaf28b Maxime Ripard 2014-07-03 153 {
0b0408745e7ff24 Alexandre Belloni 2016-10-25 154 struct device_node *np;
0b0408745e7ff24 Alexandre Belloni 2016-10-25 155 u32 ddr_type;
064380a12e12412 Alexandre Belloni 2015-08-11 @156 int ret;
ae499f0fadaf28b Maxime Ripard 2014-07-03 157
0b64a0e53cc7875 Yangtao Li 2023-07-04 158 at91_shdwc.shdwc_base = devm_platform_ioremap_resource(pdev, 0);
caa6e150f8fbcf4 Claudiu Beznea 2018-12-06 159 if (IS_ERR(at91_shdwc.shdwc_base))
caa6e150f8fbcf4 Claudiu Beznea 2018-12-06 160 return PTR_ERR(at91_shdwc.shdwc_base);
ae499f0fadaf28b Maxime Ripard 2014-07-03 161
e51202a7ed9dff5 Markus Elfring 2026-11-24 162 at91_shdwc.sclk = devm_clk_get_enabled(&pdev->dev, NULL);
caa6e150f8fbcf4 Claudiu Beznea 2018-12-06 163 if (IS_ERR(at91_shdwc.sclk))
caa6e150f8fbcf4 Claudiu Beznea 2018-12-06 164 return PTR_ERR(at91_shdwc.sclk);
064380a12e12412 Alexandre Belloni 2015-08-11 165
062836db01f9826 Ladislav Michl 2018-03-16 166 at91_wakeup_status(pdev);
ae499f0fadaf28b Maxime Ripard 2014-07-03 167
ae499f0fadaf28b Maxime Ripard 2014-07-03 168 if (pdev->dev.of_node)
ae499f0fadaf28b Maxime Ripard 2014-07-03 169 at91_poweroff_dt_set_wakeup_mode(pdev);
ae499f0fadaf28b Maxime Ripard 2014-07-03 170
0b0408745e7ff24 Alexandre Belloni 2016-10-25 171 np = of_find_compatible_node(NULL, NULL, "atmel,sama5d3-ddramc");
996463fdb8cdec4 Claudiu Beznea 2018-11-05 172 if (np) {
caa6e150f8fbcf4 Claudiu Beznea 2018-12-06 173 at91_shdwc.mpddrc_base = of_iomap(np, 0);
0b0408745e7ff24 Alexandre Belloni 2016-10-25 174 of_node_put(np);
0b0408745e7ff24 Alexandre Belloni 2016-10-25 175
e51202a7ed9dff5 Markus Elfring 2026-11-24 176 if (!at91_shdwc.mpddrc_base)
e51202a7ed9dff5 Markus Elfring 2026-11-24 177 return -ENOMEM;
0b0408745e7ff24 Alexandre Belloni 2016-10-25 178
caa6e150f8fbcf4 Claudiu Beznea 2018-12-06 179 ddr_type = readl(at91_shdwc.mpddrc_base + AT91_DDRSDRC_MDR) &
996463fdb8cdec4 Claudiu Beznea 2018-11-05 180 AT91_DDRSDRC_MD;
996463fdb8cdec4 Claudiu Beznea 2018-11-05 181 if (ddr_type != AT91_DDRSDRC_MD_LPDDR2 &&
996463fdb8cdec4 Claudiu Beznea 2018-11-05 182 ddr_type != AT91_DDRSDRC_MD_LPDDR3) {
caa6e150f8fbcf4 Claudiu Beznea 2018-12-06 183 iounmap(at91_shdwc.mpddrc_base);
caa6e150f8fbcf4 Claudiu Beznea 2018-12-06 184 at91_shdwc.mpddrc_base = NULL;
996463fdb8cdec4 Claudiu Beznea 2018-11-05 185 }
996463fdb8cdec4 Claudiu Beznea 2018-11-05 186 }
996463fdb8cdec4 Claudiu Beznea 2018-11-05 187
996463fdb8cdec4 Claudiu Beznea 2018-11-05 188 pm_power_off = at91_poweroff;
0b0408745e7ff24 Alexandre Belloni 2016-10-25 189
ae499f0fadaf28b Maxime Ripard 2014-07-03 190 return 0;
ae499f0fadaf28b Maxime Ripard 2014-07-03 191 }
ae499f0fadaf28b Maxime Ripard 2014-07-03 192
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-24 21:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 8:50 [PATCH] power: reset: at91: Use devm_clk_get_enabled() in three probe functions Markus Elfring
2026-11-24 14:35 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox