Skip to contentSkip to conversation

rtc: msm6242: use devm_platform_ioremap_resource()

PATCH In review Rosen Penev 3 participants 3 messages Jul 28 – Aug 4 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: msm6242: use devm_platform_ioremap_resource()

Replace the open-coded platform_get_resource() plus devm_ioremap() sequence with a single devm_platform_ioremap_resource() call, which folds the resource lookup and mapping into one step and returns an ERR_PTR on failure, checked with IS_ERR() and propagated via PTR_ERR().

The rtc-msm6242 platform device (arch/m68k/amiga/platform.c) provides a single IORESOURCE_MEM window (0x00dc0000-0x00dcffff). It shares that resource definition with rtc-rp5c01, but the two are registered under the mutually exclusive A2000_CLK and A3000_CLK hardware flags, so only one RTC device exists on a given machine. The region reservation now performed by devm_platform_ioremap_resource() therefore introduces no conflict.

Assisted-by opencode:hy3-free
---
 drivers/rtc/rtc-msm6242.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/rtc/rtc-msm6242.c +6 -7
index 80e364baac53..6f28d9c2278f 100644
@@ -188,21 +188,20 @@ static const struct rtc_class_ops msm6242_rtc_ops = {
 
 static int __init msm6242_rtc_probe(struct platform_device *pdev)
 {
-	struct resource *res;
 	struct msm6242_priv *priv;
 	struct rtc_device *rtc;
+	void __iomem *regs;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -ENODEV;
+	regs = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(regs))
+		return PTR_ERR(regs);
 
 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
-	priv->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res));
-	if (!priv->regs)
-		return -ENOMEM;
+	priv->regs = regs;
+
 	platform_set_drvdata(pdev, priv);
 
 	rtc = devm_rtc_device_register(&pdev->dev, "rtc-msm6242",
Signature · 1 line
2.55.0
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 13 lines

Replace the open-coded platform_get_resource() plus devm_ioremap() sequence with a single devm_platform_ioremap_resource() call, which folds the resource lookup and mapping into one step and returns an ERR_PTR on failure, checked with IS_ERR() and propagated via PTR_ERR().

The rtc-msm6242 platform device (arch/m68k/amiga/platform.c) provides a single IORESOURCE_MEM window (0x00dc0000-0x00dcffff). It shares that resource definition with rtc-rp5c01, but the two are registered under the mutually exclusive A2000_CLK and A3000_CLK hardware flags, so only one RTC device exists on a given machine. The region reservation now performed by devm_platform_ioremap_resource() therefore introduces no conflict.

Quoted 2 lines
Assisted-by opencode:hy3-free

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Rosen Penev

CC linux-m68k

Quoted 4 lines · Rosen Penev

Replace the open-coded platform_get_resource() plus devm_ioremap() sequence with a single devm_platform_ioremap_resource() call, which folds the resource lookup and mapping into one step and returns an ERR_PTR on failure, checked with IS_ERR() and propagated via PTR_ERR().

Thanks for your patch!

Quoted 7 lines

The rtc-msm6242 platform device (arch/m68k/amiga/platform.c) provides a single IORESOURCE_MEM window (0x00dc0000-0x00dcffff). It shares that resource definition with rtc-rp5c01, but the two are registered under the mutually exclusive A2000_CLK and A3000_CLK hardware flags, so only one RTC device exists on a given machine. The region reservation now performed by devm_platform_ioremap_resource() therefore introduces no conflict.

Any patches adding seemingly safe region reservations need testing on actual hardware.

Quoted 23 lines
Assisted-by opencode:hy3-free
drivers/rtc/rtc-msm6242.c +4 -4
@@ -188,21 +188,20 @@ static const struct rtc_class_ops msm6242_rtc_ops = {
 
 static int __init msm6242_rtc_probe(struct platform_device *pdev)
 {
-       struct resource *res;
        struct msm6242_priv *priv;
        struct rtc_device *rtc;
+       void __iomem *regs;
 
-       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!res)
-               return -ENODEV;
+       regs = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(regs))
+               return PTR_ERR(regs);
 
        priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
        if (!priv)

drivers/rtc/rtc-msm6242.c static const struct rtc_class_ops msm6242_rtc_ops = { · line 207

Quoted 10 lines
drivers/rtc/rtc-msm6242.c +2 -3
                return -ENOMEM;
 
-       priv->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res));
-       if (!priv->regs)
-               return -ENOMEM;
+       priv->regs = regs;
+
        platform_set_drvdata(pdev, priv);
 
        rtc = devm_rtc_device_register(&pdev->dev, "rtc-msm6242",

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds