Skip to content

Commit a2b02e4

Browse files
peda-rbroonie
authored andcommitted
spi: mux: repair mux usage
It is not valid to cache/short out selection of the mux. mux_control_select() only locks the mux until mux_control_deselect() is called. mux_control_deselect() may put the mux in some low power state or some other user of the mux might select it for other purposes. These things are probably not happening in the original setting where this driver was developed, but it is said to be a generic SPI mux. Also, the mux framework will short out the actual low level muxing operation when/if that is possible. Fixes: e9e4054 ("spi: Add generic SPI multiplexer") Signed-off-by: Peter Rosin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent b9dd3f6 commit a2b02e4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/spi/spi-mux.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ static int spi_mux_select(struct spi_device *spi)
5151
struct spi_mux_priv *priv = spi_controller_get_devdata(spi->controller);
5252
int ret;
5353

54+
ret = mux_control_select(priv->mux, spi->chip_select);
55+
if (ret)
56+
return ret;
57+
5458
if (priv->current_cs == spi->chip_select)
5559
return 0;
5660

@@ -62,10 +66,6 @@ static int spi_mux_select(struct spi_device *spi)
6266
priv->spi->mode = spi->mode;
6367
priv->spi->bits_per_word = spi->bits_per_word;
6468

65-
ret = mux_control_select(priv->mux, spi->chip_select);
66-
if (ret)
67-
return ret;
68-
6969
priv->current_cs = spi->chip_select;
7070

7171
return 0;

0 commit comments

Comments
 (0)