Re: [PATCH v2 10/10] gpio: shared: generalize most code to firmware nodes

From: Andy Shevchenko

Date: Tue Nov 17 2026 - 09:06:34 EST


On Tue, Nov 17, 2026 at 11:46:35AM +0100, Bartosz Golaszewski wrote:
> On Tue, Nov 17, 2026 at 12:23:38PM +0200, Andy Shevchenko wrote:
> > On Tue, Nov 17, 2026 at 10:50:38AM +0100, Bartosz Golaszewski wrote:
> > > On Fri, Nov 13, 2026 at 06:19:15PM +0200, Andy Shevchenko wrote:
> > > > On Fri, Nov 13, 2026 at 04:47:10PM +0100, Bartosz Golaszewski wrote:

...

> > > > > -static int gpio_shared_of_scan(void)
> > > > > +static __maybe_unused int gpio_shared_fwnode_traverse(struct fwnode_handle *curr)
> > > > > {
> > > > > - if (of_root)
> > > > > - return gpio_shared_of_traverse(of_root);
> > > > > + int ret;
> > > > > +
> > > > > + if (gpio_shared_fwnode_ignore(curr))
> > > > > + return 0;
> > > > > +
> > > > > + ret = gpio_shared_fwnode_scan_properties(curr);
> > > > > + if (ret)
> > > > > + return ret;
> > > > > +
> > > > > + fwnode_for_each_child_node_scoped(curr, child) {
> > > > > + ret = gpio_shared_fwnode_traverse(child);
> > > > > + if (ret)
> > > > > + return ret;
> > > > > + }
> > > > >
> > > > > return 0;
> > > > > }
> > > > > -#else
> > > > > +
> > > > > static int gpio_shared_of_scan(void)
> > > > > {
> > > > > +#if IS_ENABLED(CONFIG_OF)
> > > > > + if (of_root)
> > > > > + return gpio_shared_fwnode_traverse(of_fwnode_handle(of_root));
> > > > > +#endif
> > > > > +
> > > > > return 0;
> > > > > }
> > > > > -#endif /* CONFIG_OF */
> > > >
> > > > Hmm... What do you exactly get from the compiler without this uglyfication?
> > >
> > > The alternative is an empty stub for gpio_shared_of_scan() and keeping
> > > CONFIG_OF around most of the code in that file. I think it looks better
> > > this way.
> >
> > My question basically was what will go wrong if you drop that #if completely?
>
> Kernel will not link with !CONFIG_OF as of_root is defined and exported in
> drivers/of/base.c.

Wouldn't

if (IS_ENABLED(CONFIG_OF) && of_root)

be sufficient instead of ugly #if?

--
With Best Regards,
Andy Shevchenko