Skip to content

Commit 165adc9

Browse files
author
Linus Walleij
committed
gpiolib: fix up function prototypes etc
Commit 69e1601bca88809dc118abd1becb02c15a02ec71 "gpiolib: provide provision to register pin ranges" Got most of it's function prototypes wrong, so fix this up by: - Moving the void declarations into static inlines in <linux/gpio.h> (previously the actual prototypes were declared here...) - Declare the gpiochip_add_pin_range() and gpiochip_remove_pin_ranges() functions in <asm-generic/gpio.h> together with the pin range struct declaration itself. - Actually only implement these very functions in gpiolib.c if CONFIG_PINCTRL is set. - Additionally export the symbols since modules will need to be able to do this. Reviewed-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 33dfc41 commit 165adc9

3 files changed

Lines changed: 29 additions & 11 deletions

File tree

drivers/gpio/gpiolib.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,7 @@ struct gpio_chip *gpiochip_find(void *data,
11851185
EXPORT_SYMBOL_GPL(gpiochip_find);
11861186

11871187
#ifdef CONFIG_PINCTRL
1188+
11881189
void gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name,
11891190
unsigned int pin_base, unsigned int npins)
11901191
{
@@ -1206,6 +1207,7 @@ void gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name,
12061207

12071208
list_add_tail(&pin_range->node, &chip->pin_ranges);
12081209
}
1210+
EXPORT_SYMBOL_GPL(gpiochip_add_pin_range);
12091211

12101212
void gpiochip_remove_pin_ranges(struct gpio_chip *chip)
12111213
{
@@ -1217,11 +1219,9 @@ void gpiochip_remove_pin_ranges(struct gpio_chip *chip)
12171219
&pin_range->range);
12181220
}
12191221
}
1220-
#else
1221-
void gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name,
1222-
unsigned int pin_base, unsigned int npins) {}
1223-
void gpiochip_remove_pin_ranges(struct gpio_chip *chip) {}
1224-
#endif
1222+
EXPORT_SYMBOL_GPL(gpiochip_remove_pin_ranges);
1223+
1224+
#endif /* CONFIG_PINCTRL */
12251225

12261226
/* These "optional" allocation calls help prevent drivers from stomping
12271227
* on each other, and help provide better diagnostics in debugfs.

include/asm-generic/gpio.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct module;
4949
struct device_node;
5050

5151
#ifdef CONFIG_PINCTRL
52+
5253
/**
5354
* struct gpio_pin_range - pin range controlled by a gpio chip
5455
* @head: list for maintaining set of pin ranges, used internally
@@ -61,6 +62,11 @@ struct gpio_pin_range {
6162
struct pinctrl_dev *pctldev;
6263
struct pinctrl_gpio_range range;
6364
};
65+
66+
void gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name,
67+
unsigned int pin_base, unsigned int npins);
68+
void gpiochip_remove_pin_ranges(struct gpio_chip *chip);
69+
6470
#endif
6571

6672
/**

include/linux/gpio.h

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ static inline int irq_to_gpio(unsigned int irq)
7272
return -EINVAL;
7373
}
7474

75-
#endif
75+
#endif /* ! CONFIG_ARCH_HAVE_CUSTOM_GPIO_H */
7676

77-
#else
77+
#else /* ! CONFIG_GENERIC_GPIO */
7878

7979
#include <linux/kernel.h>
8080
#include <linux/types.h>
@@ -231,9 +231,21 @@ static inline int irq_to_gpio(unsigned irq)
231231
return -EINVAL;
232232
}
233233

234-
void gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name,
235-
unsigned int pin_base, unsigned int npins);
236-
void gpiochip_remove_pin_ranges(struct gpio_chip *chip);
237-
#endif
234+
#ifdef CONFIG_PINCTRL
235+
236+
static inline void
237+
gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name,
238+
unsigned int pin_base, unsigned int npins)
239+
{
240+
}
241+
242+
static inline void
243+
gpiochip_remove_pin_ranges(struct gpio_chip *chip)
244+
{
245+
}
246+
247+
#endif /* CONFIG_PINCTRL */
248+
249+
#endif /* ! CONFIG_GENERIC_GPIO */
238250

239251
#endif /* __LINUX_GPIO_H */

0 commit comments

Comments
 (0)