[PATCH] asm-generic/gpio.h: merge basic gpiolib wrappers

Mike Frysinger vapier at gentoo.org
Fri Oct 28 08:15:00 EDT 2011


On Thu, Oct 27, 2011 at 15:11, Russell King - ARM Linux wrote:
> This is extremely dangerous.  Consider for example this code
> (see ARM mach-davinci's gpio.h):

it's interesting you highlight davinci.  if i'm reading things
correctly, the current davinci code is broken today and my v2 proposed
patch actually fixes it.

let's see if i have this right:
arch/arm/include/asm/gpio.h:
...
#include <mach/gpio.h>
#ifndef __ARM_GPIOLIB_COMPLEX
/* The trivial gpiolib dispatchers */
#define gpio_get_value  __gpio_get_value
#define gpio_set_value  __gpio_set_value
#define gpio_cansleep   __gpio_cansleep
#endif
...

arch/arm/mach-davinci/include/mach/gpio.h:
...
#include <asm-generic/gpio.h>
...
static inline void gpio_set_value(unsigned gpio, int value)
{
    if (__builtin_constant_p(value) && gpio < davinci_soc_info.gpio_num) {
           ... do some SoC checking ...
    }
    __gpio_set_value(gpio, value);
}
... same thing for gpio_get_value and gpio_cansleep ...
...

since the davinci code doesn't define __ARM_GPIOLIB_COMPLEX, the
common arm gpio.h will rewrite these few gpio calls to the gpiolib
code all the time, and so all the inline funcs in the davinci header
always get ignored.

i noticed because when comparing the compiled
-mike



More information about the linux-arm-kernel mailing list