9
0
Fork 0

spi: Get bus_num from devicetree

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

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2013-10-28 12:10:36 +01:00
parent fb40dd5157
commit 2fa5f06958
1 changed files with 3 additions and 0 deletions

View File

@ -226,6 +226,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--;