diff mbox

[3.7] spi/bcm63xx: fix transfer bits_per_words check

Message ID 1353764690-5961-1-git-send-email-jonas.gorski@gmail.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Jonas Gorski Nov. 24, 2012, 1:44 p.m. UTC
Transfers often do not have bits_per_words set, so use the spi device's
bits_per_words in this case.

This fixes the driver rejecting valid transfers e.g. generated by
spi_write() or spi_read().

Cc: stable@vger.kernel.org
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
 drivers/spi/spi-bcm63xx.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Florian Fainelli Nov. 24, 2012, 3:02 p.m. UTC | #1
Le 24/11/2012 14:44, Jonas Gorski a écrit :
> Transfers often do not have bits_per_words set, so use the spi device's
> bits_per_words in this case.
>
> This fixes the driver rejecting valid transfers e.g. generated by
> spi_write() or spi_read().
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>

Acked-by: Florian Fainelli <florian@openwrt.org>

> ---
>   drivers/spi/spi-bcm63xx.c |    3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c
> index a9f4049..d7c2916 100644
> --- a/drivers/spi/spi-bcm63xx.c
> +++ b/drivers/spi/spi-bcm63xx.c
> @@ -103,7 +103,8 @@ static int bcm63xx_spi_check_transfer(struct spi_device *spi,
>   {
>   	u8 bits_per_word;
>
> -	bits_per_word = (t) ? t->bits_per_word : spi->bits_per_word;
> +	bits_per_word = (t && t->bits_per_word) ?
> +			t->bits_per_word : spi->bits_per_word;
>   	if (bits_per_word != 8) {
>   		dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n",
>   			__func__, bits_per_word);
>


------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
Jonas Gorski Nov. 24, 2012, 5:53 p.m. UTC | #2
On 24 November 2012 18:28, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:
> On Sat, Nov 24, 2012 at 02:44:50PM +0100, Jonas Gorski wrote:
>> Transfers often do not have bits_per_words set, so use the spi device's
>> bits_per_words in this case.
>>
>> This fixes the driver rejecting valid transfers e.g. generated by
>> spi_write() or spi_read().
>
> This is now done by the SPI core, there's no need for individual drivers
> to do this.

So that will go to stable kernels, too?

------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
Jonas Gorski Nov. 24, 2012, 6:19 p.m. UTC | #3
On 24 November 2012 19:01, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:
> On Sat, Nov 24, 2012 at 06:53:10PM +0100, Jonas Gorski wrote:
>> On 24 November 2012 18:28, Mark Brown
>
>> > This is now done by the SPI core, there's no need for individual drivers
>> > to do this.
>
>> So that will go to stable kernels, too?
>
> No, I hadn't sent it there.  I'd really expect that anyone using a
> release kernel would've noticed this if there were a problem, it's
> pretty obvious when it goes wrong, and I tend to be extremely
> conservative with changes to stable kernels especially framework ones.

Well, I noticed this particular problem on a 3.6 kernel (3.6.7 to be
exact), so by that definition at least one noticed, unless I don't
count as anyone ;-). So, how can I make this driver less broken for
release kernels? I somewhat doubt the framework change will be picked
up by release kernel maintainers.

------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
Florian Fainelli Nov. 26, 2012, 1:11 p.m. UTC | #4
On Saturday 24 November 2012 19:19:34 Jonas Gorski wrote:
> On 24 November 2012 19:01, Mark Brown
> <broonie@opensource.wolfsonmicro.com> wrote:
> > On Sat, Nov 24, 2012 at 06:53:10PM +0100, Jonas Gorski wrote:
> >> On 24 November 2012 18:28, Mark Brown
> >
> >> > This is now done by the SPI core, there's no need for individual drivers
> >> > to do this.
> >
> >> So that will go to stable kernels, too?
> >
> > No, I hadn't sent it there.  I'd really expect that anyone using a
> > release kernel would've noticed this if there were a problem, it's
> > pretty obvious when it goes wrong, and I tend to be extremely
> > conservative with changes to stable kernels especially framework ones.
> 
> Well, I noticed this particular problem on a 3.6 kernel (3.6.7 to be
> exact), so by that definition at least one noticed, unless I don't
> count as anyone ;-). So, how can I make this driver less broken for
> release kernels? I somewhat doubt the framework change will be picked
> up by release kernel maintainers.

Considering it is a simple one-liner in spi-bcm63xx and that you don't want to
propagate a framework-level change back to -stable (which makes sense), don't
you want to pick that one?

At least two other users told me about this bug in private conversations.
--
Florian


------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
diff mbox

Patch

diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c
index a9f4049..d7c2916 100644
--- a/drivers/spi/spi-bcm63xx.c
+++ b/drivers/spi/spi-bcm63xx.c
@@ -103,7 +103,8 @@  static int bcm63xx_spi_check_transfer(struct spi_device *spi,
 {
 	u8 bits_per_word;
 
-	bits_per_word = (t) ? t->bits_per_word : spi->bits_per_word;
+	bits_per_word = (t && t->bits_per_word) ?
+			t->bits_per_word : spi->bits_per_word;
 	if (bits_per_word != 8) {
 		dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n",
 			__func__, bits_per_word);