* [PATCH 0/2] A couple of gpio fixes @ 2013-01-15 8:37 Shawn Guo 2013-01-15 8:37 ` [PATCH 1/2] gpio: fix warning of 'struct gpio_chip' declaration Shawn Guo 2013-01-15 8:37 ` [PATCH 2/2] gpio: devm_gpio_* support should not depend on GPIOLIB Shawn Guo 0 siblings, 2 replies; 9+ messages in thread From: Shawn Guo @ 2013-01-15 8:37 UTC (permalink / raw) To: linux-arm-kernel I recently sent a patch "mmc: slot-gpio: use devm_* managed functions to ease users" for mmc-next inclusion, and got a error report [1] from Fengguang (Thanks!), saying it breaks blackfin build. It seems to me that the error is caused by devm_gpio_* unnecessary dependency on GPIOLIB. While at it, I also include a patch (#1) to fix the 'struct gpio_chip' declaration warning that's already been there with blackfin build. And the patch #2 remove the unnecessary dependency between devm_gpio_* and GPIOLIB to get the reported error fixed. [1] http://thread.gmane.org/gmane.linux.kernel.mmc/18650 Shawn Guo (2): gpio: fix warning of 'struct gpio_chip' declaration gpio: devm_gpio_* support should not depend on GPIOLIB drivers/gpio/Kconfig | 3 ++ drivers/gpio/Makefile | 3 +- include/asm-generic/gpio.h | 91 ++++++++++++++++++++++---------------------- 3 files changed, 50 insertions(+), 47 deletions(-) -- 1.7.9.5 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] gpio: fix warning of 'struct gpio_chip' declaration 2013-01-15 8:37 [PATCH 0/2] A couple of gpio fixes Shawn Guo @ 2013-01-15 8:37 ` Shawn Guo 2013-01-17 13:30 ` Linus Walleij 2013-01-17 14:03 ` [PATCH 1/2 RESEND] " Shawn Guo 2013-01-15 8:37 ` [PATCH 2/2] gpio: devm_gpio_* support should not depend on GPIOLIB Shawn Guo 1 sibling, 2 replies; 9+ messages in thread From: Shawn Guo @ 2013-01-15 8:37 UTC (permalink / raw) To: linux-arm-kernel The struct gpio_chip is only defined inside #ifdef CONFIG_GPIOLIB, but it's referenced by gpiochip_add_pin_range() and gpiochip_remove_pin_ranges() which are outside #ifdef CONFIG_GPIOLIB. Thus, we see the following warning when building blackfin image, where GPIOLIB is not required. CC arch/blackfin/kernel/bfin_gpio.o CC init/version.o In file included from arch/blackfin/include/asm/gpio.h:321, from arch/blackfin/kernel/bfin_gpio.c:15: include/asm-generic/gpio.h:298: warning: ?struct gpio_chip? declared inside parameter list include/asm-generic/gpio.h:298: warning: its scope is only this definition or declaration, which is probably not what you want include/asm-generic/gpio.h:304: warning: ?struct gpio_chip? declared inside parameter list Move pinctrl trunk into #ifdef CONFIG_GPIOLIB to fix the warning, since it appears that pinctrl gpio range support depends on GPIOLIB. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> --- include/asm-generic/gpio.h | 74 ++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index 20ca766..2341014 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h @@ -212,6 +212,43 @@ extern void gpio_unexport(unsigned gpio); #endif /* CONFIG_GPIO_SYSFS */ +#ifdef CONFIG_PINCTRL + +/** + * struct gpio_pin_range - pin range controlled by a gpio chip + * @head: list for maintaining set of pin ranges, used internally + * @pctldev: pinctrl device which handles corresponding pins + * @range: actual range of pins controlled by a gpio controller + */ + +struct gpio_pin_range { + struct list_head node; + struct pinctrl_dev *pctldev; + struct pinctrl_gpio_range range; +}; + +int gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, + unsigned int gpio_offset, unsigned int pin_offset, + unsigned int npins); +void gpiochip_remove_pin_ranges(struct gpio_chip *chip); + +#else + +static inline int +gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, + unsigned int gpio_offset, unsigned int pin_offset, + unsigned int npins) +{ + return 0; +} + +static inline void +gpiochip_remove_pin_ranges(struct gpio_chip *chip) +{ +} + +#endif /* CONFIG_PINCTRL */ + #else /* !CONFIG_GPIOLIB */ static inline bool gpio_is_valid(int number) @@ -270,41 +307,4 @@ static inline void gpio_unexport(unsigned gpio) } #endif /* CONFIG_GPIO_SYSFS */ -#ifdef CONFIG_PINCTRL - -/** - * struct gpio_pin_range - pin range controlled by a gpio chip - * @head: list for maintaining set of pin ranges, used internally - * @pctldev: pinctrl device which handles corresponding pins - * @range: actual range of pins controlled by a gpio controller - */ - -struct gpio_pin_range { - struct list_head node; - struct pinctrl_dev *pctldev; - struct pinctrl_gpio_range range; -}; - -int gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, - unsigned int gpio_offset, unsigned int pin_offset, - unsigned int npins); -void gpiochip_remove_pin_ranges(struct gpio_chip *chip); - -#else - -static inline int -gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, - unsigned int gpio_offset, unsigned int pin_offset, - unsigned int npins) -{ - return 0; -} - -static inline void -gpiochip_remove_pin_ranges(struct gpio_chip *chip) -{ -} - -#endif /* CONFIG_PINCTRL */ - #endif /* _ASM_GENERIC_GPIO_H */ -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 1/2] gpio: fix warning of 'struct gpio_chip' declaration 2013-01-15 8:37 ` [PATCH 1/2] gpio: fix warning of 'struct gpio_chip' declaration Shawn Guo @ 2013-01-17 13:30 ` Linus Walleij 2013-01-17 14:13 ` Shawn Guo 2013-01-17 14:03 ` [PATCH 1/2 RESEND] " Shawn Guo 1 sibling, 1 reply; 9+ messages in thread From: Linus Walleij @ 2013-01-17 13:30 UTC (permalink / raw) To: linux-arm-kernel On Tue, Jan 15, 2013 at 9:37 AM, Shawn Guo <shawn.guo@linaro.org> wrote: > The struct gpio_chip is only defined inside #ifdef CONFIG_GPIOLIB, > but it's referenced by gpiochip_add_pin_range() and > gpiochip_remove_pin_ranges() which are outside #ifdef CONFIG_GPIOLIB. > Thus, we see the following warning when building blackfin image, where > GPIOLIB is not required. > > CC arch/blackfin/kernel/bfin_gpio.o > CC init/version.o > In file included from arch/blackfin/include/asm/gpio.h:321, > from arch/blackfin/kernel/bfin_gpio.c:15: > include/asm-generic/gpio.h:298: warning: ?struct gpio_chip? declared inside parameter list > include/asm-generic/gpio.h:298: warning: its scope is only this definition or declaration, which is probably not what you want > include/asm-generic/gpio.h:304: warning: ?struct gpio_chip? declared inside parameter list > > Move pinctrl trunk into #ifdef CONFIG_GPIOLIB to fix the warning, > since it appears that pinctrl gpio range support depends on GPIOLIB. > > Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Shawn can you please try to repost this with something that does not turn into quoted-printable? Look: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable (...) @@ -212,6 +212,43 @@ extern void gpio_unexport(unsigned gpio); =20 #endif /* CONFIG_GPIO_SYSFS */ =20 +#ifdef CONFIG_PINCTRL I can't apply that. Second: if this is not an immediate regression I'd prefer to put it for-next now, as touching this file always brings down something. OK? Yours, Linus Walleij ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] gpio: fix warning of 'struct gpio_chip' declaration 2013-01-17 13:30 ` Linus Walleij @ 2013-01-17 14:13 ` Shawn Guo 0 siblings, 0 replies; 9+ messages in thread From: Shawn Guo @ 2013-01-17 14:13 UTC (permalink / raw) To: linux-arm-kernel On Thu, Jan 17, 2013 at 02:30:01PM +0100, Linus Walleij wrote: > Shawn can you please try to repost this with something that does not > turn into quoted-printable? Look: > Sorry for that. Just resent it. > MIME-Version: 1.0 > Content-Type: text/plain; charset="UTF-8" > Content-Transfer-Encoding: quoted-printable > (...) > @@ -212,6 +212,43 @@ extern void gpio_unexport(unsigned gpio); > =20 > #endif /* CONFIG_GPIO_SYSFS */ > =20 > +#ifdef CONFIG_PINCTRL > > I can't apply that. > > Second: if this is not an immediate regression I'd prefer to put it > for-next now, as touching this file always brings down something. > > OK? > The warning the first patch tries to fix seems new to v3.8-rc, while the second patch is definitely fine for -next. Since I do not care much about the warning seen on blackfin, I'm fine with both of them being for -next. Shawn ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2 RESEND] gpio: fix warning of 'struct gpio_chip' declaration 2013-01-15 8:37 ` [PATCH 1/2] gpio: fix warning of 'struct gpio_chip' declaration Shawn Guo 2013-01-17 13:30 ` Linus Walleij @ 2013-01-17 14:03 ` Shawn Guo 2013-01-17 14:10 ` Linus Walleij 1 sibling, 1 reply; 9+ messages in thread From: Shawn Guo @ 2013-01-17 14:03 UTC (permalink / raw) To: linux-arm-kernel The struct gpio_chip is only defined inside #ifdef CONFIG_GPIOLIB, but it's referenced by gpiochip_add_pin_range() and gpiochip_remove_pin_ranges() which are outside #ifdef CONFIG_GPIOLIB. Thus, we see the following warning when building blackfin image, where GPIOLIB is not required. CC arch/blackfin/kernel/bfin_gpio.o CC init/version.o In file included from arch/blackfin/include/asm/gpio.h:321, from arch/blackfin/kernel/bfin_gpio.c:15: include/asm-generic/gpio.h:298: warning: 'struct gpio_chip' declared inside parameter list include/asm-generic/gpio.h:298: warning: its scope is only this definition or declaration, which is probably not what you want include/asm-generic/gpio.h:304: warning: 'struct gpio_chip' declared inside parameter list Move pinctrl trunk into #ifdef CONFIG_GPIOLIB to fix the warning, since it appears that pinctrl gpio range support depends on GPIOLIB. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> --- include/asm-generic/gpio.h | 74 ++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index 20ca766..2341014 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h @@ -212,6 +212,43 @@ extern void gpio_unexport(unsigned gpio); #endif /* CONFIG_GPIO_SYSFS */ +#ifdef CONFIG_PINCTRL + +/** + * struct gpio_pin_range - pin range controlled by a gpio chip + * @head: list for maintaining set of pin ranges, used internally + * @pctldev: pinctrl device which handles corresponding pins + * @range: actual range of pins controlled by a gpio controller + */ + +struct gpio_pin_range { + struct list_head node; + struct pinctrl_dev *pctldev; + struct pinctrl_gpio_range range; +}; + +int gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, + unsigned int gpio_offset, unsigned int pin_offset, + unsigned int npins); +void gpiochip_remove_pin_ranges(struct gpio_chip *chip); + +#else + +static inline int +gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, + unsigned int gpio_offset, unsigned int pin_offset, + unsigned int npins) +{ + return 0; +} + +static inline void +gpiochip_remove_pin_ranges(struct gpio_chip *chip) +{ +} + +#endif /* CONFIG_PINCTRL */ + #else /* !CONFIG_GPIOLIB */ static inline bool gpio_is_valid(int number) @@ -270,41 +307,4 @@ static inline void gpio_unexport(unsigned gpio) } #endif /* CONFIG_GPIO_SYSFS */ -#ifdef CONFIG_PINCTRL - -/** - * struct gpio_pin_range - pin range controlled by a gpio chip - * @head: list for maintaining set of pin ranges, used internally - * @pctldev: pinctrl device which handles corresponding pins - * @range: actual range of pins controlled by a gpio controller - */ - -struct gpio_pin_range { - struct list_head node; - struct pinctrl_dev *pctldev; - struct pinctrl_gpio_range range; -}; - -int gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, - unsigned int gpio_offset, unsigned int pin_offset, - unsigned int npins); -void gpiochip_remove_pin_ranges(struct gpio_chip *chip); - -#else - -static inline int -gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, - unsigned int gpio_offset, unsigned int pin_offset, - unsigned int npins) -{ - return 0; -} - -static inline void -gpiochip_remove_pin_ranges(struct gpio_chip *chip) -{ -} - -#endif /* CONFIG_PINCTRL */ - #endif /* _ASM_GENERIC_GPIO_H */ -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 1/2 RESEND] gpio: fix warning of 'struct gpio_chip' declaration 2013-01-17 14:03 ` [PATCH 1/2 RESEND] " Shawn Guo @ 2013-01-17 14:10 ` Linus Walleij 0 siblings, 0 replies; 9+ messages in thread From: Linus Walleij @ 2013-01-17 14:10 UTC (permalink / raw) To: linux-arm-kernel On Thu, Jan 17, 2013 at 3:03 PM, Shawn Guo <shawn.guo@linaro.org> wrote: > The struct gpio_chip is only defined inside #ifdef CONFIG_GPIOLIB, > but it's referenced by gpiochip_add_pin_range() and > gpiochip_remove_pin_ranges() which are outside #ifdef CONFIG_GPIOLIB. > Thus, we see the following warning when building blackfin image, where > GPIOLIB is not required. > > CC arch/blackfin/kernel/bfin_gpio.o > CC init/version.o > In file included from arch/blackfin/include/asm/gpio.h:321, > from arch/blackfin/kernel/bfin_gpio.c:15: > include/asm-generic/gpio.h:298: warning: 'struct gpio_chip' declared inside parameter list > include/asm-generic/gpio.h:298: warning: its scope is only this definition or declaration, which is probably not what you want > include/asm-generic/gpio.h:304: warning: 'struct gpio_chip' declared inside parameter list > > Move pinctrl trunk into #ifdef CONFIG_GPIOLIB to fix the warning, > since it appears that pinctrl gpio range support depends on GPIOLIB. > > Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Thanks, patch applied to devel (for-next) Let's see if something explodes! Yours, Linus Walleij ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2] gpio: devm_gpio_* support should not depend on GPIOLIB 2013-01-15 8:37 [PATCH 0/2] A couple of gpio fixes Shawn Guo 2013-01-15 8:37 ` [PATCH 1/2] gpio: fix warning of 'struct gpio_chip' declaration Shawn Guo @ 2013-01-15 8:37 ` Shawn Guo 2013-01-17 13:31 ` Linus Walleij 2013-01-17 14:11 ` Linus Walleij 1 sibling, 2 replies; 9+ messages in thread From: Shawn Guo @ 2013-01-15 8:37 UTC (permalink / raw) To: linux-arm-kernel Some architectures (e.g. blackfin) provide gpio API without requiring GPIOLIB support (ARCH_WANT_OPTIONAL_GPIOLIB). devm_gpio_* functions should also work for these architectures, since they do not really depend on GPIOLIB. Add a new option GPIO_DEVRES (enabled by default) to control the build of devres.c, and move devm_gpio_* function declarations out from #ifdef CONFIG_GPIOLIB in include/asm-generic/gpio.h, so that they can be available to client drivers without unnecessary dependency on GPIOLIB. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> --- drivers/gpio/Kconfig | 3 +++ drivers/gpio/Makefile | 3 ++- include/asm-generic/gpio.h | 17 ++++++++--------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 682de75..d972932 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -30,6 +30,9 @@ config ARCH_REQUIRE_GPIOLIB Selecting this from the architecture code will cause the gpiolib code to always get built in. +config GPIO_DEVRES + def_bool y + depends on HAS_IOMEM menuconfig GPIOLIB diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index c5aebd0..36ca605 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -2,7 +2,8 @@ ccflags-$(CONFIG_DEBUG_GPIO) += -DDEBUG -obj-$(CONFIG_GPIOLIB) += gpiolib.o devres.o +obj-$(CONFIG_GPIO_DEVRES) += devres.o +obj-$(CONFIG_GPIOLIB) += gpiolib.o obj-$(CONFIG_OF_GPIO) += gpiolib-of.o obj-$(CONFIG_GPIO_ACPI) += gpiolib-acpi.o diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index 2341014..71fd984 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h @@ -7,6 +7,8 @@ #include <linux/of.h> #include <linux/pinctrl/pinctrl.h> +struct device; + #ifdef CONFIG_GPIOLIB #include <linux/compiler.h> @@ -42,7 +44,6 @@ static inline bool gpio_is_valid(int number) return number >= 0 && number < ARCH_NR_GPIOS; } -struct device; struct gpio; struct seq_file; struct module; @@ -192,12 +193,6 @@ extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *labe extern int gpio_request_array(const struct gpio *array, size_t num); extern void gpio_free_array(const struct gpio *array, size_t num); -/* bindings for managed devices that want to request gpios */ -int devm_gpio_request(struct device *dev, unsigned gpio, const char *label); -int devm_gpio_request_one(struct device *dev, unsigned gpio, - unsigned long flags, const char *label); -void devm_gpio_free(struct device *dev, unsigned int gpio); - #ifdef CONFIG_GPIO_SYSFS /* @@ -280,9 +275,13 @@ static inline void gpio_set_value_cansleep(unsigned gpio, int value) #endif /* !CONFIG_GPIOLIB */ -#ifndef CONFIG_GPIO_SYSFS +/* bindings for managed devices that want to request gpios */ +int devm_gpio_request(struct device *dev, unsigned gpio, const char *label); +int devm_gpio_request_one(struct device *dev, unsigned gpio, + unsigned long flags, const char *label); +void devm_gpio_free(struct device *dev, unsigned int gpio); -struct device; +#ifndef CONFIG_GPIO_SYSFS /* sysfs support is only available with gpiolib, where it's optional */ -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] gpio: devm_gpio_* support should not depend on GPIOLIB 2013-01-15 8:37 ` [PATCH 2/2] gpio: devm_gpio_* support should not depend on GPIOLIB Shawn Guo @ 2013-01-17 13:31 ` Linus Walleij 2013-01-17 14:11 ` Linus Walleij 1 sibling, 0 replies; 9+ messages in thread From: Linus Walleij @ 2013-01-17 13:31 UTC (permalink / raw) To: linux-arm-kernel On Tue, Jan 15, 2013 at 9:37 AM, Shawn Guo <shawn.guo@linaro.org> wrote: > Some architectures (e.g. blackfin) provide gpio API without requiring > GPIOLIB support (ARCH_WANT_OPTIONAL_GPIOLIB). devm_gpio_* functions > should also work for these architectures, since they do not really > depend on GPIOLIB. > > Add a new option GPIO_DEVRES (enabled by default) to control the build > of devres.c, and move devm_gpio_* function declarations out from #ifdef > CONFIG_GPIOLIB in include/asm-generic/gpio.h, so that they can be > available to client drivers without unnecessary dependency on GPIOLIB. > > Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Fair enough, but I need the first patch in an applicable for first... Yours, Linus Walleij ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2] gpio: devm_gpio_* support should not depend on GPIOLIB 2013-01-15 8:37 ` [PATCH 2/2] gpio: devm_gpio_* support should not depend on GPIOLIB Shawn Guo 2013-01-17 13:31 ` Linus Walleij @ 2013-01-17 14:11 ` Linus Walleij 1 sibling, 0 replies; 9+ messages in thread From: Linus Walleij @ 2013-01-17 14:11 UTC (permalink / raw) To: linux-arm-kernel On Tue, Jan 15, 2013 at 9:37 AM, Shawn Guo <shawn.guo@linaro.org> wrote: > Some architectures (e.g. blackfin) provide gpio API without requiring > GPIOLIB support (ARCH_WANT_OPTIONAL_GPIOLIB). devm_gpio_* functions > should also work for these architectures, since they do not really > depend on GPIOLIB. > > Add a new option GPIO_DEVRES (enabled by default) to control the build > of devres.c, and move devm_gpio_* function declarations out from #ifdef > CONFIG_GPIOLIB in include/asm-generic/gpio.h, so that they can be > available to client drivers without unnecessary dependency on GPIOLIB. > > Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Patch applied, thanks! Yours, Linus Walleij ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-01-17 14:13 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-01-15 8:37 [PATCH 0/2] A couple of gpio fixes Shawn Guo 2013-01-15 8:37 ` [PATCH 1/2] gpio: fix warning of 'struct gpio_chip' declaration Shawn Guo 2013-01-17 13:30 ` Linus Walleij 2013-01-17 14:13 ` Shawn Guo 2013-01-17 14:03 ` [PATCH 1/2 RESEND] " Shawn Guo 2013-01-17 14:10 ` Linus Walleij 2013-01-15 8:37 ` [PATCH 2/2] gpio: devm_gpio_* support should not depend on GPIOLIB Shawn Guo 2013-01-17 13:31 ` Linus Walleij 2013-01-17 14:11 ` Linus Walleij
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).