[PATCH v1 1/4] spi: Propagate default fwnode to the SPI controller device

Andy Shevchenko posted 4 patches 1 month ago
There is a newer version of this series
[PATCH v1 1/4] spi: Propagate default fwnode to the SPI controller device
Posted by Andy Shevchenko 1 month ago
Most of the SPI controller drivers share the parent's fwnode
by explicit assignment. Propagate the default by SPI core,
so they may drop that in the code. Only corner cases may require
a special treatment and we simply (re)assign the controller's
fwnode explicitly (as it's done right now, no changes required
for that).

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-cs42l43.c | 8 ++++++++
 drivers/spi/spi.c         | 3 +++
 2 files changed, 11 insertions(+)

diff --git a/drivers/spi/spi-cs42l43.c b/drivers/spi/spi-cs42l43.c
index 4b6b65f450a8..a4a650c8d740 100644
--- a/drivers/spi/spi-cs42l43.c
+++ b/drivers/spi/spi-cs42l43.c
@@ -371,6 +371,14 @@ static int cs42l43_spi_probe(struct platform_device *pdev)
 
 	fwnode_property_read_u32(xu_fwnode, "01fa-sidecar-instances", &nsidecars);
 
+	/*
+	 * Depending on the value of nsidecars we either create a software node
+	 * or assign an fwnode. We don't want software node to be attached to
+	 * the default one. That's why we need to clear the SPI controller fwnode
+	 * first.
+	 */
+	device_set_node(&priv->ctlr->dev, NULL);
+
 	if (nsidecars) {
 		struct software_node_ref_args args[] = {
 			SOFTWARE_NODE_REFERENCE(fwnode, 0, GPIO_ACTIVE_LOW),
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index f077ea74e299..b773c297f8b1 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -3072,6 +3072,9 @@ struct spi_controller *__spi_alloc_controller(struct device *dev,
 	else
 		ctlr->dev.class = &spi_controller_class;
 	ctlr->dev.parent = dev;
+
+	device_set_node(&ctlr->dev, dev_fwnode(dev));
+
 	pm_suspend_ignore_children(&ctlr->dev, true);
 	spi_controller_set_devdata(ctlr, (void *)ctlr + ctlr_size);
 
-- 
2.50.1
Re: [PATCH v1 1/4] spi: Propagate default fwnode to the SPI controller device
Posted by Charles Keepax 3 weeks, 6 days ago
On Thu, Jan 08, 2026 at 09:23:38PM +0100, Andy Shevchenko wrote:
> Most of the SPI controller drivers share the parent's fwnode
> by explicit assignment. Propagate the default by SPI core,
> so they may drop that in the code. Only corner cases may require
> a special treatment and we simply (re)assign the controller's
> fwnode explicitly (as it's done right now, no changes required
> for that).
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---

Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Tested-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thanks,
Charles
Re: [PATCH v1 1/4] spi: Propagate default fwnode to the SPI controller device
Posted by Andy Shevchenko 3 weeks, 6 days ago
On Mon, Jan 12, 2026 at 11:53:50AM +0000, Charles Keepax wrote:
> On Thu, Jan 08, 2026 at 09:23:38PM +0100, Andy Shevchenko wrote:
> > Most of the SPI controller drivers share the parent's fwnode
> > by explicit assignment. Propagate the default by SPI core,
> > so they may drop that in the code. Only corner cases may require
> > a special treatment and we simply (re)assign the controller's
> > fwnode explicitly (as it's done right now, no changes required
> > for that).
> 
> Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
> Tested-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thank you very much! I'm now pretty much confident about the change.

-- 
With Best Regards,
Andy Shevchenko