[Intel-gfx] [PATCH 3/9] drm/connector: Add drm_connector_find_by_fwnode() function (v2)
Andy Shevchenko
andy.shevchenko at gmail.com
Tue May 4 12:35:27 UTC 2021
On Tue, May 4, 2021 at 2:53 PM Hans de Goede <hdegoede at redhat.com> wrote:
> On 5/4/21 10:00 AM, Andy Shevchenko wrote:
> > On Monday, May 3, 2021, Hans de Goede <hdegoede at redhat.com <mailto:hdegoede at redhat.com>> wrote:
...
> > +struct drm_connector *drm_connector_find_by_fwnode(struct fwnode_handle *fwnode)
> > +{
> > + struct drm_connector *connector, *found = ERR_PTR(-ENODEV);
> > +
> > + if (!fwnode)
> > + return ERR_PTR(-ENODEV);
> > +
> > + mutex_lock(&connector_list_lock);
> > +
> > + list_for_each_entry(connector, &connector_list, global_connector_list_entry) {
> > + if (connector->fwnode == fwnode ||
> > + (connector->fwnode && connector->fwnode->secondary == fwnode)) {
> > + drm_connector_get(connector);
> > + found = connector;
> > + break;
> > + }
> > + }
> > +
> > + mutex_unlock(&connector_list_lock);
> > +
> > + return found;
> >
> > If I am not mistaken you can replace this with
> >
> > return list_entry_is_head();
> >
> > call and remove additional Boolean variable.
>
> Found is not a boolean, it is a pointer to the found connector (or ERR_PTR(-ENODEV)).
Ah, perhaps giving a better name? `match` ?
And to the initial topic, it's either an additional variable or
additional branch in this case. I think additional branch (taking into
account the length of the line or amount of lines) doesn't buy us
anything.
> > +}
--
With Best Regards,
Andy Shevchenko
More information about the Intel-gfx
mailing list