[PATCH] pmdomain: mediatek: Use devm_platform_get_and_ioremap_resource() in init_scp()

Geert Uytterhoeven geert at linux-m68k.org
Mon Feb 5 11:01:17 PST 2024


Hi Markus,

On Mon, Feb 5, 2024 at 6:28 PM Markus Elfring <Markus.Elfring at web.de> wrote:
> >> +++ b/drivers/pmdomain/mediatek/mtk-scpsys.c
> >> @@ -441,8 +441,7 @@ static struct scp *init_scp(struct platform_device *pdev,
> >>
> >>         scp->dev = &pdev->dev;
> >>
> >> -       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >> -       scp->base = devm_ioremap_resource(&pdev->dev, res);
> >> +       scp->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
> >
> > Given res is further unused, please use devm_platform_ioremap_resource()
> > instead, and remove the local variable res.
>
> I got another idea after looking at the implementation of the function
> “devm_platform_get_and_ioremap_resource” once more.
> https://elixir.bootlin.com/linux/v6.8-rc3/source/drivers/base/platform.c#L87
>
> It seems that it is supported to pass a null pointer for the last parameter
> (while this possibility is not mentioned in the interface description so far).
> How do you think about to benefit from such a design option any more
> (instead of the determination of a corresponding platform device)?

Yes, you can pass a NULL pointer as the last parameter.
And as this is very common, the wrapper devm_platform_ioremap_resource()
exists.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

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



More information about the Linux-mediatek mailing list