[PATCH] drm: vc4: Use of_property_present()

Dave Stevenson dave.stevenson at raspberrypi.com
Wed Sep 4 11:18:07 UTC 2024


Hi Rob

On Tue, 3 Sept 2024 at 20:19, Rob Herring <robh at kernel.org> wrote:
>
> On Wed, Jul 31, 2024 at 2:13 PM Rob Herring (Arm) <robh at kernel.org> wrote:
> >
> > Use of_property_present() to test for property presence rather than
> > of_find_property(). This is part of a larger effort to remove callers
> > of of_find_property() and similar functions. of_find_property() leaks
> > the DT struct property and data pointers which is a problem for
> > dynamically allocated nodes which may be freed.
> >
> > Signed-off-by: Rob Herring (Arm) <robh at kernel.org>
> > ---
> >  drivers/gpu/drm/vc4/vc4_hdmi.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
>
> Ping!

Sorry, this fell through the cracks.

> >
> > diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
> > index d57c4a5948c8..049de06460d5 100644
> > --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
> > +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
> > @@ -2211,7 +2211,7 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi)
> >         struct device *dev = &vc4_hdmi->pdev->dev;
> >         struct platform_device *codec_pdev;
> >         const __be32 *addr;
> > -       int index, len;
> > +       int index;
> >         int ret;
> >
> >         /*
> > @@ -2234,7 +2234,7 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi)
> >         BUILD_BUG_ON(offsetof(struct vc4_hdmi_audio, card) != 0);
> >         BUILD_BUG_ON(offsetof(struct vc4_hdmi, audio) != 0);
> >
> > -       if (!of_find_property(dev->of_node, "dmas", &len) || !len) {
> > +       if (!of_property_present(dev->of_node, "dmas")) {

The existing conditional is true if the property is not present or is 0 length.
Your new one is only true if the property isn't present, so it isn't the same.

Is there a more appropriate of_ call to return the length of the property?

Thanks
  Dave

> >                 dev_warn(dev,
> >                          "'dmas' DT property is missing or empty, no HDMI audio\n");
> >                 return 0;
> > --
> > 2.43.0
> >


More information about the dri-devel mailing list