Skip to content

Commit 2c1b7bb

Browse files
Amit Kumar Mahapatrabroonie
authored andcommitted
spi: Fix SPI slave probe failure
While adding a SPI device, the SPI core ensures that multiple logical CS doesn't map to the same physical CS. For example, spi->chip_select[0] != spi->chip_select[1] and so forth. However, unlike the SPI master, the SPI slave doesn't have the list of chip selects, this leads to probe failure when the SPI controller is configured as slave. Update the __spi_add_device() function to perform this check only if the SPI controller is configured as master. Fixes: 4d8ff6b ("spi: Add multi-cs memories support in SPI core") Signed-off-by: Amit Kumar Mahapatra <amit.kumar-mahapatra@amd.com> Link: https://msgid.link/r/20240617153052.26636-1-amit.kumar-mahapatra@amd.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent d6a711a commit 2c1b7bb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/spi/spi.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -689,10 +689,12 @@ static int __spi_add_device(struct spi_device *spi)
689689
* Make sure that multiple logical CS doesn't map to the same physical CS.
690690
* For example, spi->chip_select[0] != spi->chip_select[1] and so on.
691691
*/
692-
for (idx = 0; idx < SPI_CS_CNT_MAX; idx++) {
693-
status = spi_dev_check_cs(dev, spi, idx, spi, idx + 1);
694-
if (status)
695-
return status;
692+
if (!spi_controller_is_target(ctlr)) {
693+
for (idx = 0; idx < SPI_CS_CNT_MAX; idx++) {
694+
status = spi_dev_check_cs(dev, spi, idx, spi, idx + 1);
695+
if (status)
696+
return status;
697+
}
696698
}
697699

698700
/* Set the bus ID string */

0 commit comments

Comments
 (0)