Re: [PATCH 4/9] device property: provide fwnode_property_get_names()

From: Bartosz Golaszewski

Date: Mon Nov 09 2026 - 06:21:51 EST


On Wed, Nov 04, 2026 at 11:17:37PM +0200, Andy Shevchenko wrote:
>
> > +{
> > + int ret1, ret2 = -ENXIO, n1, n2, i, j, count;
> > + char **prim = NULL, **sec = NULL, **merged;
> > +
> > + if (IS_ERR_OR_NULL(fwnode))
> > + return -EINVAL;
> > +
> > + ret1 = fwnode_call_int_op(fwnode, property_get_names, &prim);
> > + if (!IS_ERR_OR_NULL(fwnode->secondary))
> > + ret2 = fwnode_call_int_op(fwnode->secondary, property_get_names, &sec);
> > +
> > + if (ret1 == -ENXIO && ret2 == -ENXIO)
> > + return -ENXIO;
> > +
> > + n1 = max(ret1, 0);
> > + n2 = max(ret2, 0);
> > +
> > + CLASS(strarray, prim_props)(prim, n1);
> > + CLASS(strarray, sec_props)(sec, n2);
> > +
> > + if (ret1 < 0 && ret1 != -ENXIO)
> > + return ret1;
> > +
> > + if (ret2 < 0 && ret2 != -ENXIO)
> > + return ret2;
>
> > + if (n1 == 0 && n2 == 0)
> > + return 0;
>
> Shouldn't these checks be before any CLASS()? Otherwise seems strange to me.
>

Actually, not ok for this: we create these classes in order to
automatically free the string arrays when returning so we must create
them before the checks. The above check for double -ENXIO doesn't need
it because no string array could have been created.

Bart