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

Markus Elfring Markus.Elfring at web.de
Mon Feb 5 09:28:31 PST 2024


>> +++ 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)?

Regards,
Markus



More information about the Linux-mediatek mailing list