Re: [PATCH 03/10] spi: switch to using class_find_device_by_fwnode()

From: Dmitry Torokhov

Date: Mon Mar 23 2026 - 14:54:29 EST


On Mon, Mar 23, 2026 at 05:16:04PM +0000, Mark Brown wrote:
> On Sun, Mar 22, 2026 at 06:54:21PM -0700, Dmitry Torokhov wrote:
> > In preparation to class_find_device_by_of_node() going away switch to
> > using class_find_device_by_fwnode().
>
> > struct spi_controller *of_find_spi_controller_by_node(struct device_node *node)
> > {
> > + struct fwnode_handle *fwnode = of_fwnode_handle(node);
> > struct device *dev;
> >
> > - dev = class_find_device_by_of_node(&spi_controller_class, node);
> > + dev = class_find_device_by_fwnode(&spi_controller_class, fwnode);
> > if (!dev && IS_ENABLED(CONFIG_SPI_SLAVE))
> > - dev = class_find_device_by_of_node(&spi_target_class, node);
> > + dev = class_find_device_by_fwnode(&spi_target_class, fwnode);
> > if (!dev)
> > return NULL;
>
> Actually, no - this just looks weird. We're in the middle of an OF
> specific function but we're having to jump up to fwnode for no apparent
> reason. If we actually decide to get rid of the OF specific function
> then I guess but I'm really not convinced this is an improvement in
> isolation.

Yes, I want to remove OF-specific APIs from the driver core. I also have
drafts for bus_find_device_by_fwnode and others.

I can make a followup series introducing spi_find_controller_by_fwnode()
and removing this OF-specific variant.

Thanks.

--
Dmitry