lkml.org 
[lkml]   [2022]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 5/6] gpiolib: consolidate GPIO lookups
On Fri, Nov 04, 2022 at 09:56:57PM -0700, Dmitry Torokhov wrote:
> On Fri, Nov 04, 2022 at 11:06:58PM +0200, Andy Shevchenko wrote:
> > On Fri, Nov 04, 2022 at 11:52:26AM -0700, Dmitry Torokhov wrote:
> > > On Fri, Nov 04, 2022 at 07:17:27PM +0200, Andy Shevchenko wrote:
> > > > On Thu, Nov 03, 2022 at 11:10:15PM -0700, Dmitry Torokhov wrote:

...

> > > > > + desc = gpiod_find_by_fwnode(fwnode, consumer, con_id, idx,
> > > > > + &flags, &lookupflags);
> >
> > Looking into drivers/base/property.c makes me realize that you might need to
> > test for error pointer as well.
> >
> > Perhaps something like
> >
> > if (IS_ERR_OR_NULL(fwnode))
> > return ERR_PTR(-ENOENT);
> >
> > in the gpiod_find_by_fwnode() needs to be added. Can you check this?
>
> No, only fwnode->secondary pointer can be PTR_ERR()-encoded.
>
> From comment to set_primary_fwnode() in drivers/base/core.c
>
> * Valid fwnode cases are:
> * - primary --> secondary --> -ENODEV
> * - primary --> NULL
> * - secondary --> -ENODEV
> * - NULL
>
> I do not believe we should be concerned about someone passing secondary
> pointers from fwnodes directly into gpiolib.

It's not only about secondary vs. primary notation, some of fwnode API calls
may return error pointer and hence entire stack should be prepared for that.

See 002752af7b89 ("device property: Allow error pointer to be passed to
fwnode APIs") as an example.

--
With Best Regards,
Andy Shevchenko


\
 
 \ /
  Last update: 2022-11-07 11:45    [W:0.111 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site