On Wed, Jan 29, 2025 at 8:18 AM Dave Stevenson <
dave.steven...@raspberrypi.com> wrote:

> Hi Anusha
>
> On Tue, 28 Jan 2025 at 22:33, Anusha Srivatsa <asriv...@redhat.com> wrote:
> >
> > Replace platform_get_resource_byname + devm_ioremap_resource
> > with just devm_platform_ioremap_resource()
> >
> > Used Coccinelle to do this change. SmPl patch:
> > //rule s/(devm_)platform_get_resource_byname +
> > //(devm_)ioremap/devm_platform_ioremap_resource.
> > @rule_3@
> > identifier res;
> > expression ioremap;
> > identifier pdev;
> > constant mem;
> > expression name;
> > @@
> > -struct resource *res;
> > ...
> > -res = platform_get_resource_byname(pdev,mem,name);
> > <...
> > -if (!res) {
> > -...
> > -}
> > ...>
> > -ioremap = devm_ioremap(...);
> > +ioremap = devm_platform_ioremap_resource_byname(pdev,name);
> >
> > Cc: Maxime Ripard <mrip...@kernel.org>
> > Cc: Dave Stevenson <dave.steven...@raspberrypi.com>
> > Cc: "Maíra Canal" <mca...@igalia.com>
> > Signed-off-by: Anusha Srivatsa <asriv...@redhat.com>
> > ---
> >  drivers/gpu/drm/vc4/vc4_hdmi.c | 9 ++-------
> >  1 file changed, 2 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c
> b/drivers/gpu/drm/vc4/vc4_hdmi.c
> > index
> 47d9ada98430634cfd8c1e21c2a4d00d501bab7e..e22733f8159aa4b247a915e24a236f620bae932c
> 100644
> > --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
> > +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
> > @@ -2951,15 +2951,10 @@ static int vc5_hdmi_init_resources(struct
> drm_device *drm,
> >  {
> >         struct platform_device *pdev = vc4_hdmi->pdev;
> >         struct device *dev = &pdev->dev;
> > -       struct resource *res;
> >         int ret;
> >
> > -       res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hdmi");
> > -       if (!res)
> > -               return -ENODEV;
> > -
> > -       vc4_hdmi->hdmicore_regs = devm_ioremap(dev, res->start,
> > -                                              resource_size(res));
> > +       vc4_hdmi->hdmicore_regs =
> devm_platform_ioremap_resource_byname(pdev,
> > +
>  "hdmi");
>
> Whilst I totally agree with this change, why was only one of the 8
> instances of this pattern within this function updated? Is that a
> limitation in your script?
>
> https://github.com/torvalds/linux/blob/master/drivers/gpu/drm/vc4/vc4_hdmi.c#L2957-L3020
>
>
Yes! looks like it is. My script is missing one set of ellipses which makes
it apply the rule only to the first appearance of the pattern. Will rectify
this. Thanks!!

Anusha

>   Dave
>
> >         if (!vc4_hdmi->hdmicore_regs)
> >                 return -ENOMEM;
> >
> >
> > --
> > 2.47.0
> >
>
>

Reply via email to