diff mbox series

[03/13] spi: do not attempt to register DT nodes without @ in name

Message ID 20240109-axi-spi-engine-series-3-v1-3-e42c6a986580@baylibre.com (mailing list archive)
State New, archived
Headers show
Series spi: axi-spi-engine: add offload support | expand

Commit Message

David Lechner Jan. 10, 2024, 7:49 p.m. UTC
In the DT bindings for SPI devices, it is specified that peripheral
nodes have the @ character in the node name. A SPI controller may need
to create bindings with child nodes that are not peripherals. For
example, the AXI SPI Engine bindings will use an "offloads" child node
to describe what is connected to the offload interfaces of the SPI
controller.

Without this change, the SPI controller would attempt to register all
child nodes as SPI devices. After this change, only nodes with '@' in
the name will be registered as SPI devices.

Signed-off-by: David Lechner <dlechner@baylibre.com>
---
 drivers/spi/spi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Mark Brown Jan. 10, 2024, 9:37 p.m. UTC | #1
On Wed, Jan 10, 2024 at 01:49:44PM -0600, David Lechner wrote:

> In the DT bindings for SPI devices, it is specified that peripheral
> nodes have the @ character in the node name. A SPI controller may need
> to create bindings with child nodes that are not peripherals. For
> example, the AXI SPI Engine bindings will use an "offloads" child node
> to describe what is connected to the offload interfaces of the SPI
> controller.

Have you done any auditing to ensure that this rule is followed?
diff mbox series

Patch

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index f1d66b5d5491..5be5e654284c 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -2379,7 +2379,9 @@  static void of_register_spi_devices(struct spi_controller *ctlr)
 	struct device_node *nc;
 
 	for_each_available_child_of_node(ctlr->dev.of_node, nc) {
-		if (of_node_test_and_set_flag(nc, OF_POPULATED))
+		/* Only nodes with '@' in the name are peripheral nodes. */
+		if (of_node_test_and_set_flag(nc, OF_POPULATED) ||
+		    !strchr(kbasename(nc->full_name), '@'))
 			continue;
 		spi = of_register_spi_device(ctlr, nc);
 		if (IS_ERR(spi)) {