kernel: bcma: update to version from wireless-testing tag master-2012-07-11
[openwrt.git] / target / linux / brcm47xx / patches-3.3 / 220-add_gpio_request_one.patch
1 --- a/arch/mips/bcm47xx/gpio.c
2 +++ b/arch/mips/bcm47xx/gpio.c
3 @@ -7,6 +7,7 @@
4   */
5  
6  #include <linux/export.h>
7 +#include <linux/gpio.h>
8  #include <linux/ssb/ssb.h>
9  #include <linux/ssb/ssb_driver_chipcommon.h>
10  #include <linux/ssb/ssb_driver_extif.h>
11 @@ -100,3 +101,30 @@ int gpio_to_irq(unsigned gpio)
12         return -EINVAL;
13  }
14  EXPORT_SYMBOL_GPL(gpio_to_irq);
15 +
16 +/**
17 + * gpio_request_one - request a single GPIO with initial configuration
18 + * @gpio:      the GPIO number
19 + * @flags:     GPIO configuration as specified by GPIOF_*
20 + * @label:     a literal description string of this GPIO
21 + */
22 +int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
23 +{
24 +       int err;
25 +
26 +       err = gpio_request(gpio, label);
27 +       if (err)
28 +               return err;
29 +
30 +       if (flags & GPIOF_DIR_IN)
31 +               err = gpio_direction_input(gpio);
32 +       else
33 +               err = gpio_direction_output(gpio,
34 +                               (flags & GPIOF_INIT_HIGH) ? 1 : 0);
35 +
36 +       if (err)
37 +               gpio_free(gpio);
38 +
39 +       return err;
40 +}
41 +EXPORT_SYMBOL_GPL(gpio_request_one);
42 --- a/arch/mips/include/asm/mach-bcm47xx/gpio.h
43 +++ b/arch/mips/include/asm/mach-bcm47xx/gpio.h
44 @@ -19,6 +19,7 @@
45  extern int gpio_request(unsigned gpio, const char *label);
46  extern void gpio_free(unsigned gpio);
47  extern int gpio_to_irq(unsigned gpio);
48 +extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);
49  
50  static inline int gpio_get_value(unsigned gpio)
51  {