[PATCH 3/7] spi: Get bus_num from devicetree

Sascha Hauer s.hauer at pengutronix.de
Mon Oct 28 08:01:36 EDT 2013


Get the bus_num from devicetree if a "spi" alias exists.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/spi/spi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index f035cc2..b9397ad 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -225,6 +225,9 @@ int spi_register_master(struct spi_master *master)
 	if (master->num_chipselect == 0)
 		return -EINVAL;
 
+	if ((master->bus_num < 0) && master->dev->device_node)
+		master->bus_num = of_alias_get_id(master->dev->device_node, "spi");
+
 	/* convention:  dynamically assigned bus IDs count down from the max */
 	if (master->bus_num < 0)
 		master->bus_num = dyn_bus_id--;
-- 
1.8.4.rc3




More information about the barebox mailing list