public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: Michael Buesch <mb@bu3sch.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, openwrt-devel@lists.openwrt.org
Subject: Re: [PATCH] spi-gpio: Sanitize MISO bitvalue
Date: Mon, 16 Feb 2009 11:58:48 -0800	[thread overview]
Message-ID: <200902161158.48890.david-b@pacbell.net> (raw)
In-Reply-To: <200902151630.41426.mb@bu3sch.de>

On Sunday 15 February 2009, Michael Buesch wrote:
> gpio_get_value() returns 0 or nonzero, but getmiso() expects 0 or 1.
> Sanitize the value to a 0/1 boolean.
> 
> Signed-off-by: Michael Buesch <mb@bu3sch.de>

Acked-by: David Brownell <dbrownell@users.sourceforge.net>


> ---
> 
> Well, we could also change the bitbang helpers in linux/spi/spi_bitbang.h

That would be the main alternate fix to consider, and
it's worth updating the docs there to specify that getmiso()
needs to return 0/1 ... 

> or change the way the gpio_get_value API is defined,

Not an option.  The more instructions thrown in these
inner loops, the harder it is to get even inlined code to
clock over 1 MHz.


> but I personally think 
> this patch is pretty good as is.
> In any case, it fixes a real bug on platforms like the bcm47xx which
> return 0 or nonzero for gpio_get_value.
> 
> Index: linux-2.6/drivers/spi/spi_gpio.c
> ===================================================================
> --- linux-2.6.orig/drivers/spi/spi_gpio.c	2009-02-14 21:37:14.000000000 +0100
> +++ linux-2.6/drivers/spi/spi_gpio.c	2009-02-15 16:27:16.000000000 +0100
> @@ -114,7 +114,7 @@ static inline void setmosi(const struct 
>  
>  static inline int getmiso(const struct spi_device *spi)
>  {
> -	return gpio_get_value(SPI_MISO_GPIO);
> +	return !!gpio_get_value(SPI_MISO_GPIO);
>  }
>  
>  #undef pdata
> 
> -- 
> Greetings, Michael.
> 
> 




  reply	other threads:[~2009-02-16 20:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-15 15:30 [PATCH] spi-gpio: Sanitize MISO bitvalue Michael Buesch
2009-02-16 19:58 ` David Brownell [this message]
2009-02-18 21:04 ` Andrew Morton
2009-02-18 21:52   ` Michael Buesch
2009-02-19  0:29   ` David Brownell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200902161158.48890.david-b@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mb@bu3sch.de \
    --cc=openwrt-devel@lists.openwrt.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox