diff options
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r-- | drivers/spi/spi.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index ec395a6baf9c..9da0bc5a036c 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -2143,8 +2143,17 @@ int spi_register_controller(struct spi_controller *ctlr) | |||
2143 | */ | 2143 | */ |
2144 | if (ctlr->num_chipselect == 0) | 2144 | if (ctlr->num_chipselect == 0) |
2145 | return -EINVAL; | 2145 | return -EINVAL; |
2146 | /* allocate dynamic bus number using Linux idr */ | 2146 | if (ctlr->bus_num >= 0) { |
2147 | if ((ctlr->bus_num < 0) && ctlr->dev.of_node) { | 2147 | /* devices with a fixed bus num must check-in with the num */ |
2148 | mutex_lock(&board_lock); | ||
2149 | id = idr_alloc(&spi_master_idr, ctlr, ctlr->bus_num, | ||
2150 | ctlr->bus_num + 1, GFP_KERNEL); | ||
2151 | mutex_unlock(&board_lock); | ||
2152 | if (WARN(id < 0, "couldn't get idr")) | ||
2153 | return id == -ENOSPC ? -EBUSY : id; | ||
2154 | ctlr->bus_num = id; | ||
2155 | } else if (ctlr->dev.of_node) { | ||
2156 | /* allocate dynamic bus number using Linux idr */ | ||
2148 | id = of_alias_get_id(ctlr->dev.of_node, "spi"); | 2157 | id = of_alias_get_id(ctlr->dev.of_node, "spi"); |
2149 | if (id >= 0) { | 2158 | if (id >= 0) { |
2150 | ctlr->bus_num = id; | 2159 | ctlr->bus_num = id; |