Message ID | b983963f1ad0400fdca2f8bf8095d25b62b0ffb0.1518704854.git.jan.kundrat@cesnet.cz (mailing list archive) |
---|---|
State | Accepted |
Commit | 7a29a505b0b6f7a0f0802cb3044ddba6cd8e1e07 |
Headers | show |
On Thu, 2018-02-15 at 15:19 +0100, Jan Kundrát wrote: > It's a bug to look at the device's bits_per_word because each transfer > can override these settings. In fact, e.g., spidev cannot specify > "global" bits_per_word and instead relies on passing that through every > ioctl. > > @@ -427,7 +427,7 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer) > struct orion_spi *orion_spi; > int cs = spi->chip_select; > > - word_len = spi->bits_per_word; > + word_len = xfer->bits_per_word ? xfer->bits_per_word : spi->bits_per_word; > count = xfer->len; __spi_validate() already does this. You can just look at xfer- >bits_per_word and it will have already been set to spi->bits_per_word if necessary. This should hold for all the xfer fields. They are validated and will incorporate the spi slave's and/or spi master's default values as necessary.
On Thu, Feb 15, 2018 at 05:27:06PM +0000, Mark Brown wrote: > The patch > > spi: orion: Respect per-transfer bits_per_word settings > > has been applied to the spi tree at > > https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git Sorry, this was applied in error (as Trent identified) - it got done later along with some other stuff as I fat fingered some scripting, dropped again.
diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c index ca52300baeb1..56e419a7ed78 100644 --- a/drivers/spi/spi-orion.c +++ b/drivers/spi/spi-orion.c @@ -427,7 +427,7 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer) struct orion_spi *orion_spi; int cs = spi->chip_select; - word_len = spi->bits_per_word; + word_len = xfer->bits_per_word ? xfer->bits_per_word : spi->bits_per_word; count = xfer->len; orion_spi = spi_master_get_devdata(spi->master);
It's a bug to look at the device's bits_per_word because each transfer can override these settings. In fact, e.g., spidev cannot specify "global" bits_per_word and instead relies on passing that through every ioctl. This code already did the right thing in orion_spi_setup_transfer, but then failed to access the HW in an appropriate way here in orion_spi_write_read. Tested by 16-bit trnasfers via spidev on an Armada 388 (Solidrun Clearfog). Signed-off-by: Jan Kundrát <jan.kundrat@cesnet.cz> --- drivers/spi/spi-orion.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)