Skip to content

Commit

Permalink
spi: altera: Change to dynamic allocation of spi id
Browse files Browse the repository at this point in the history
[ Upstream commit f09f6df ]

The spi-altera driver has two flavors: platform and dfl. I'm seeing
a case where I have both device types in the same machine, and they
are conflicting on the SPI ID:

... kernel: couldn't get idr
... kernel: WARNING: CPU: 28 PID: 912 at drivers/spi/spi.c:2920 spi_register_controller.cold+0x84/0xc0a

Both the platform and dfl drivers use the parent's driver ID as the SPI
ID. In the error case, the parent devices are dfl_dev.4 and
subdev_spi_altera.4.auto. When the second spi-master is created, the
failure occurs because the SPI ID of 4 has already been allocated.

Change the ID allocation to dynamic (by initializing bus_num to -1) to
avoid duplicate SPI IDs.

Signed-off-by: Russ Weight <russell.h.weight@intel.com>
Link: https://lore.kernel.org/r/20211019002401.24041-1-russell.h.weight@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Russ Weight authored and gregkh committed Nov 17, 2021
1 parent 4916836 commit dc93fe4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/spi/spi-altera-dfl.c
Expand Up @@ -140,7 +140,7 @@ static int dfl_spi_altera_probe(struct dfl_device *dfl_dev)
if (!master)
return -ENOMEM;

master->bus_num = dfl_dev->id;
master->bus_num = -1;

hw = spi_master_get_devdata(master);

Expand Down
2 changes: 1 addition & 1 deletion drivers/spi/spi-altera-platform.c
Expand Up @@ -48,7 +48,7 @@ static int altera_spi_probe(struct platform_device *pdev)
return err;

/* setup the master state. */
master->bus_num = pdev->id;
master->bus_num = -1;

if (pdata) {
if (pdata->num_chipselect > ALTERA_SPI_MAX_CS) {
Expand Down

0 comments on commit dc93fe4

Please sign in to comment.