When probing spi bus masters from devicetree they got a bus_num of -1. This works with a single bus master only since all bus masters had the same bus_num. Detect this and dynamically assign a valid bus_num. Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> --- drivers/spi/spi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index d273050..f035cc2 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -214,6 +214,7 @@ static LIST_HEAD(spi_master_list); */ int spi_register_master(struct spi_master *master) { + static int dyn_bus_id = (1 << 15) - 1; int status = -ENODEV; debug("%s: %s:%d\n", __func__, master->dev->name, master->dev->id); @@ -224,6 +225,10 @@ int spi_register_master(struct spi_master *master) if (master->num_chipselect == 0) return -EINVAL; + /* convention: dynamically assigned bus IDs count down from the max */ + if (master->bus_num < 0) + master->bus_num = dyn_bus_id--; + list_add_tail(&master->list, &spi_master_list); spi_of_register_slaves(master); -- 1.8.4.rc3 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox