Skip to content

Commit

Permalink
gpiolib: Ensure struct gpio is always defined
Browse files Browse the repository at this point in the history
Currently struct gpio is only defined when using gpiolib which makes the
stub gpio_request_array() much less useful in drivers than is ideal as
they can't work with struct gpio.  Since there are no other definitions
in kernel instead make the define always available no matter if gpiolib
is selectable or selected, ensuring that drivers can always use the
type.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
  • Loading branch information
Mark Brown authored and Grant Likely committed Oct 24, 2011
1 parent 825de2e commit feb8369
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
13 changes: 1 addition & 12 deletions include/asm-generic/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ static inline bool gpio_is_valid(int number)
}

struct device;
struct gpio;
struct seq_file;
struct module;
struct device_node;
Expand Down Expand Up @@ -170,18 +171,6 @@ extern int __gpio_cansleep(unsigned gpio);

extern int __gpio_to_irq(unsigned gpio);

/**
* struct gpio - a structure describing a GPIO with configuration
* @gpio: the GPIO number
* @flags: GPIO configuration as specified by GPIOF_*
* @label: a literal description string of this GPIO
*/
struct gpio {
unsigned gpio;
unsigned long flags;
const char *label;
};

extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);
extern int gpio_request_array(const struct gpio *array, size_t num);
extern void gpio_free_array(const struct gpio *array, size_t num);
Expand Down
22 changes: 12 additions & 10 deletions include/linux/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@
#define GPIOF_OUT_INIT_LOW (GPIOF_DIR_OUT | GPIOF_INIT_LOW)
#define GPIOF_OUT_INIT_HIGH (GPIOF_DIR_OUT | GPIOF_INIT_HIGH)

/**
* struct gpio - a structure describing a GPIO with configuration
* @gpio: the GPIO number
* @flags: GPIO configuration as specified by GPIOF_*
* @label: a literal description string of this GPIO
*/
struct gpio {
unsigned gpio;
unsigned long flags;
const char *label;
};

#ifdef CONFIG_GENERIC_GPIO
#include <asm/gpio.h>

Expand All @@ -24,18 +36,8 @@
#include <linux/errno.h>

struct device;
struct gpio;
struct gpio_chip;

/*
* Some platforms don't support the GPIO programming interface.
*
* In case some driver uses it anyway (it should normally have
* depended on GENERIC_GPIO), these routines help the compiler
* optimize out much GPIO-related code ... or trigger a runtime
* warning when something is wrongly called.
*/

static inline bool gpio_is_valid(int number)
{
return false;
Expand Down

0 comments on commit feb8369

Please sign in to comment.