Thread (17 messages) 17 messages, 5 authors, 2012-02-03

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

From: Mike Frysinger <hidden>
Date: 2011-10-28 12:15:24
Also in: linux-arch, lkml

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help