Message ID | 20240424111647.81286-1-heikki.keranen@bittium.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [v2] spi: mux: Fix master controller settings after mux select | expand |
On Wed, Apr 24, 2024 at 2:18 PM Heikki Keranen <heikki.keranen@bittium.com> wrote: > > In some cases SPI child devices behind spi-mux require different > settings like: max_speed_hz, mode and bits_per_word. > > Typically the slave device driver puts the settings in place and calls > spi_setup() once during probe and assumes they stay in place for all > following spi transfers. > > However spi-mux forwarded spi_setup() -call to SPI master driver only > when slave driver calls spi_setup(). If second slave device was > accessed meanwhile and that driver called spi_setup(), the > settings did not change back to the first spi device. > In case of wrong max_speed_hz this caused spi trasfers to fail. SPI transfers > This commit adds spi_setup() call after mux is changed. This way > the right device specific parameters are set to the master driver. > > The fix has been tested by using custom hardware and debugging > spi master driver speed settings. ... > --- > Changes in v2: > - fixed Co-authored-by -> Co-developed-by > - added Signed-off-by for co-developer > both suggested by Andy Shevchenko, thanks! As I said this was already applied and AFAIK Mark won't rebase, that's why I gave you advice for the future contributions. But thanks for following!
On Wed, Apr 24, 2024 at 02:16:47PM +0300, Heikki Keranen wrote: > In some cases SPI child devices behind spi-mux require different > settings like: max_speed_hz, mode and bits_per_word. Please do not submit new versions of already applied patches, please submit incremental updates to the existing code. Modifying existing commits creates problems for other users building on top of those commits so it's best practice to only change pubished git commits if absolutely essential.
diff --git a/drivers/spi/spi-mux.c b/drivers/spi/spi-mux.c index bd988f53753e..5d72e3d59df8 100644 --- a/drivers/spi/spi-mux.c +++ b/drivers/spi/spi-mux.c @@ -68,6 +68,8 @@ static int spi_mux_select(struct spi_device *spi) priv->current_cs = spi_get_chipselect(spi, 0); + spi_setup(priv->spi); + return 0; }