* [PATCH] spi: make sure all transfer has bits_per_word set
@ 2012-11-09 9:06 Laxman Dewangan
2012-11-09 16:42 ` Mark Brown
2012-11-12 10:03 ` Jonas Gorski
0 siblings, 2 replies; 5+ messages in thread
From: Laxman Dewangan @ 2012-11-09 9:06 UTC (permalink / raw)
To: grant.likely, broonie
Cc: swarren, spi-devel-general, linux-kernel, Laxman Dewangan,
Stephen Warren
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.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Cc: Stephen Warren <swarren@wwwdotorg.org>
---
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(-)
diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c
index b8985be..07dc735 100644
--- a/drivers/spi/spi-tegra20-slink.c
+++ b/drivers/spi/spi-tegra20-slink.c
@@ -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;
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index fc0da39..6891a03 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -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);
--
1.7.1.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] spi: make sure all transfer has bits_per_word set
2012-11-09 9:06 [PATCH] spi: make sure all transfer has bits_per_word set Laxman Dewangan
@ 2012-11-09 16:42 ` Mark Brown
2012-11-12 10:03 ` Jonas Gorski
1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2012-11-09 16:42 UTC (permalink / raw)
To: Laxman Dewangan
Cc: grant.likely, swarren, spi-devel-general, linux-kernel, Stephen Warren
[-- Attachment #1: Type: text/plain, Size: 360 bytes --]
On Fri, Nov 09, 2012 at 02:36:45PM +0530, Laxman Dewangan wrote:
> 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.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] spi: make sure all transfer has bits_per_word set
2012-11-09 9:06 [PATCH] spi: make sure all transfer has bits_per_word set Laxman Dewangan
2012-11-09 16:42 ` Mark Brown
@ 2012-11-12 10:03 ` Jonas Gorski
2012-12-06 14:15 ` Grant Likely
1 sibling, 1 reply; 5+ messages in thread
From: Jonas Gorski @ 2012-11-12 10:03 UTC (permalink / raw)
To: Laxman Dewangan
Cc: grant.likely, broonie, spi-devel-general, swarren, linux-kernel,
Stephen Warren
Hi,
On 9 November 2012 10:06, Laxman Dewangan <ldewangan@nvidia.com> wrote:
> 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.
I like that (not that it counts ... )!
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] spi: make sure all transfer has bits_per_word set
2012-11-12 10:03 ` Jonas Gorski
@ 2012-12-06 14:15 ` Grant Likely
2012-12-17 17:54 ` Laxman Dewangan
0 siblings, 1 reply; 5+ messages in thread
From: Grant Likely @ 2012-12-06 14:15 UTC (permalink / raw)
To: Jonas Gorski, Laxman Dewangan
Cc: broonie, spi-devel-general, swarren, linux-kernel, Stephen Warren
On Mon, 12 Nov 2012 11:03:56 +0100, Jonas Gorski <jonas.gorski@gmail.com> wrote:
> Hi,
>
> On 9 November 2012 10:06, Laxman Dewangan <ldewangan@nvidia.com> wrote:
> > 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.
>
> I like that (not that it counts ... )!
>
> > 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?
That sounds reasonable. Could you craft one up and see how it looks?
Thanks,
g.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] spi: make sure all transfer has bits_per_word set
2012-12-06 14:15 ` Grant Likely
@ 2012-12-17 17:54 ` Laxman Dewangan
0 siblings, 0 replies; 5+ messages in thread
From: Laxman Dewangan @ 2012-12-17 17:54 UTC (permalink / raw)
To: Grant Likely
Cc: Jonas Gorski, broonie, spi-devel-general, Stephen Warren,
linux-kernel, Stephen Warren
On Thursday 06 December 2012 07:45 PM, Grant Likely wrote:
> On Mon, 12 Nov 2012 11:03:56 +0100, Jonas Gorski<jonas.gorski@gmail.com> wrote:
>> Hi,
>>
>> On 9 November 2012 10:06, Laxman Dewangan<ldewangan@nvidia.com> wrote:
>>> 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.
>> I like that (not that it counts ... )!
>>
>>> 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.
Just sent the patch to remove the similar code from most of driver.
Tested only tegra driver.
>> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-12-17 17:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-09 9:06 [PATCH] spi: make sure all transfer has bits_per_word set Laxman Dewangan
2012-11-09 16:42 ` Mark Brown
2012-11-12 10:03 ` Jonas Gorski
2012-12-06 14:15 ` Grant Likely
2012-12-17 17:54 ` Laxman Dewangan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).