lkml.org 
[lkml]   [2009]   [Feb]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] spi-gpio: Sanitize MISO bitvalue
Date
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.
>
>





\
 
 \ /
  Last update: 2009-02-18 12:23    [W:0.052 / U:1.900 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site