spi: make sure all transfer has bits_per_word set
Subsystems (3)
Laxman Dewangan
maintainerPATCH 1/1 spi: make sure all transfer has bits_per_word set
When spi client does the spi transfer and does not sets the bits_per_word for each transfer then set it as default of spi device in spi core before calling low level transfer.
Removing the similar code from spi-tegra20-slink driver as it is not required.
---
When reviewing the change
[PATCH] spi: tegra: add spi driver for SLINK controller
it was suggested by Mark and Stephen that we should move the bits_per_word setting to the core as it almost exist in all driver. Creating this patch for doing this.
Creating teh patch
drivers/spi/spi-tegra20-slink.c | 3 +-- drivers/spi/spi.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 3 deletions(-)
drivers/spi/spi-tegra20-slink.c +1 -2
@@ -727,8 +727,7 @@ static int tegra_slink_start_transfer_one(struct spi_device *spi,unsigned long command;unsigned long command2; - bits_per_word = t->bits_per_word ? t->bits_per_word : - spi->bits_per_word; + bits_per_word = t->bits_per_word; speed = t->speed_hz ? t->speed_hz : spi->max_speed_hz;if (!speed) speed = tspi->spi_max_frequency;
drivers/spi/spi.c +10 -1
@@ -1193,6 +1193,7 @@ EXPORT_SYMBOL_GPL(spi_setup);static int __spi_async (struct spi_device *spi,struct spi_message *message) {struct spi_master *master = spi->master; +struct spi_transfer *xfer;/* Half-duplex links include original MicroWire, and ones with * only one data pin like SPI_3WIRE (switches direction) or where
@@ -1201,7 +1202,6 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message)*/ if ((master->flags &SPI_MASTER_HALF_DUPLEX ) || (spi->mode &SPI_3WIRE )) { -struct spi_transfer *xfer;unsigned flags = master->flags;list_for_each_entry (xfer, &message->transfers, transfer_list) {
@@ -1214,6 +1214,15 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message) } } +/** +* Set transfer bits_per_word as spi device default if it is not +* set for this transfer. +*/ +list_for_each_entry (xfer, &message->transfers, transfer_list) { +if (!xfer->bits_per_word) + xfer->bits_per_word = spi->bits_per_word; + } + message->spi = spi; message->status = -EINPROGRESS ;return master->transfer (spi, message);
Signature · 8 lines
1.7.1.1 ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_nov
Mark Brown
AppliedQuoted 6 lines · Laxman Dewangan
When spi client does the spi transfer and does not sets the
bits_per_wordfor each transfer then set it as default of spi device in spi core before calling low level transfer.Removing the similar code from spi-tegra20-slink driver as it is not required.
Applied, thanks.
Hi,
Quoted 3 lines · Laxman Dewangan
When spi client does the spi transfer and does not sets the
bits_per_wordfor each transfer then set it as default of spi device in spi core before calling low level transfer.
I like that (not that it counts ... )!
Quoted 2 lines
Removing the similar code from spi-tegra20-slink driver as it is not required.
Not sure if this should be part of *this* patch.
Also spi-tegra20-slink isn't the only one fixing up the bits_per_word for transfers, so it would be nice if you could remove it from the other drivers, too.
In a future patch, maybe even do the same with speed_hz?
Regards
Jonas
Quoted 12 lines · Jonas Gorski
Hi,
Quoted 3 lines · Laxman Dewangan
When spi client does the spi transfer and does not sets the
bits_per_wordfor each transfer then set it as default of spi device in spi core before calling low level transfer.I like that (not that it counts ... )!
Quoted 2 lines
Removing the similar code from spi-tegra20-slink driver as it is not required.
Quoted 6 lines
Not sure if this should be part of *this* patch.
Also spi-tegra20-slink isn't the only one fixing up thebits_per_wordfor transfers, so it would be nice if you could remove it from the other drivers, too.In a future patch, maybe even do the same with
speed_hz?
That sounds reasonable. Could you craft one up and see how it looks?
Thanks,
g.
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
Laxman Dewangan
maintainerQuoted 7 lines · Grant Likely
Quoted 6 lines · Jonas Gorski
Hi,
Quoted 3 lines · Laxman Dewangan
When spi client does the spi transfer and does not sets the
bits_per_wordfor each transfer then set it as default of spi device in spi core before calling low level transfer.
Quoted 8 lines
Quoted 8 lines
I like that (not that it counts ... )!
Quoted 2 lines
Removing the similar code from spi-tegra20-slink driver as it is not required.
Not sure if this should be part of *this* patch.
Also spi-tegra20-slink isn't the only one fixing up thebits_per_wordfor transfers, so it would be nice if you could remove it from the other drivers, too.
Just sent the patch to remove the similar code from most of driver. Tested only tegra driver.
Quoted 4 lines
Quoted 1 line
In a future patch, maybe even do the same with
speed_hz?That sounds reasonable. Could you craft one up and see how it looks?
Ok, I will prepare change and send the patch.
Thanks,
Laxman
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d