diff mbox series

[v5,3/4] spi: Update swnode based SPI devices to use the fwnode name

Message ID 20240411090628.2436389-4-ckeepax@opensource.cirrus.com
State Superseded
Headers show
Series Add bridged amplifiers to cs42l43 | expand

Commit Message

Charles Keepax April 11, 2024, 9:06 a.m. UTC
Update the name for software node based SPI devices to use the fwnode
name as the device name. This is helpful since swnode devices are
usually added within the kernel, and the kernel often then requires a
predictable name such that it can refer back to the device.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---

No changes since v4.

Thanks,
Charles

 drivers/spi/spi.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Andy Shevchenko April 11, 2024, 6:07 p.m. UTC | #1
On Thu, Apr 11, 2024 at 8:04 PM Charles Keepax
<ckeepax@opensource.cirrus.com> wrote:
> On Thu, Apr 11, 2024 at 04:33:05PM +0300, Andy Shevchenko wrote:
> > On Thu, Apr 11, 2024 at 12:06 PM Charles Keepax
> > <ckeepax@opensource.cirrus.com> wrote:

...

> > Thinking more about this, maybe even the ACPI case also can be combined?
> > See for the details
> >
> > 87526603c892 ("irqdomain: Get rid of special treatment for ACPI in
> > __irq_domain_add()")
> > 9ed78b05f998 ("irqdomain: Allow software nodes for IRQ domain creation")
>
> Maybe, I am not super confident that acpi_dev_name will always
> return the same thing as fwnode_get_name and I don't really want
> to risk renaming everything on the ACPI side.

Scratch this. They are completely different.
diff mbox series

Patch

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 05b33901eaa9..bcc9d3ab7cd9 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -606,6 +606,11 @@  static void spi_dev_set_name(struct spi_device *spi)
 		return;
 	}
 
+	if (is_software_node(fwnode)) {
+		dev_set_name(dev, "spi-%s", fwnode_get_name(fwnode));
+		return;
+	}
+
 	dev_set_name(&spi->dev, "%s.%u", dev_name(&spi->controller->dev),
 		     spi_get_chipselect(spi, 0));
 }