* [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h @ 2011-10-25 7:33 Mark Brown 2011-10-25 8:33 ` Grant Likely ` (3 more replies) 0 siblings, 4 replies; 14+ messages in thread From: Mark Brown @ 2011-10-25 7:33 UTC (permalink / raw) To: Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt, Mike Frysinger, Geert Cc: linux-arm-kernel, linux-kernel, uclinux-dist-devel, linux-m68k, linux-mips, linux-sh, linux-arch, Mark Brown Rather than requiring architectures that use gpiolib but don't have any need to define anything custom to copy an asm/gpio.h provide a Kconfig symbol which architectures must select in order to include gpio.h and for other architectures just provide the trivial implementation directly. This makes it much easier to do gpiolib updates and is also a step towards making gpiolib APIs available on every architecture. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- arch/alpha/include/asm/gpio.h | 55 ------------------------------ arch/arm/Kconfig | 1 + arch/avr32/Kconfig | 1 + arch/blackfin/Kconfig | 1 + arch/ia64/include/asm/gpio.h | 55 ------------------------------ arch/m68k/Kconfig.cpu | 1 + arch/microblaze/include/asm/gpio.h | 53 ----------------------------- arch/mips/Kconfig | 1 + arch/openrisc/include/asm/gpio.h | 65 ------------------------------------ arch/powerpc/include/asm/gpio.h | 53 ----------------------------- arch/sh/Kconfig | 1 + arch/sparc/include/asm/gpio.h | 36 -------------------- arch/unicore32/Kconfig | 1 + arch/x86/include/asm/gpio.h | 53 ----------------------------- arch/xtensa/include/asm/gpio.h | 56 ------------------------------- drivers/gpio/Kconfig | 8 ++++ include/linux/gpio.h | 34 +++++++++++++++++++ 17 files changed, 49 insertions(+), 426 deletions(-) delete mode 100644 arch/alpha/include/asm/gpio.h delete mode 100644 arch/ia64/include/asm/gpio.h delete mode 100644 arch/microblaze/include/asm/gpio.h delete mode 100644 arch/openrisc/include/asm/gpio.h delete mode 100644 arch/powerpc/include/asm/gpio.h delete mode 100644 arch/sparc/include/asm/gpio.h delete mode 100644 arch/x86/include/asm/gpio.h delete mode 100644 arch/xtensa/include/asm/gpio.h diff --git a/arch/alpha/include/asm/gpio.h b/arch/alpha/include/asm/gpio.h deleted file mode 100644 index 7dc6a63..0000000 --- a/arch/alpha/include/asm/gpio.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Generic GPIO API implementation for Alpha. - * - * A stright copy of that for PowerPC which was: - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_ALPHA_GPIO_H -#define _ASM_ALPHA_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * We don't (yet) implement inlined/rapid versions for on-chip gpios. - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_ALPHA_GPIO_H */ diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 7e8ffe7..5e0446c 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1,6 +1,7 @@ config ARM bool default y + select ARCH_HAVE_CUSTOM_GPIO_H select HAVE_AOUT select HAVE_DMA_API_DEBUG select HAVE_IDE if PCI || ISA || PCMCIA diff --git a/arch/avr32/Kconfig b/arch/avr32/Kconfig index 197e96f..b2e3e58 100644 --- a/arch/avr32/Kconfig +++ b/arch/avr32/Kconfig @@ -10,6 +10,7 @@ config AVR32 select GENERIC_IRQ_PROBE select HARDIRQS_SW_RESEND select GENERIC_IRQ_SHOW + select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_HAVE_NMI_SAFE_CMPXCHG help AVR32 is a high-performance 32-bit RISC microprocessor core, diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig index c747629..2c13eef 100644 --- a/arch/blackfin/Kconfig +++ b/arch/blackfin/Kconfig @@ -31,6 +31,7 @@ config BLACKFIN select HAVE_KERNEL_LZO if RAMKERNEL select HAVE_OPROFILE select HAVE_PERF_EVENTS + select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_WANT_OPTIONAL_GPIOLIB select HAVE_GENERIC_HARDIRQS select GENERIC_ATOMIC64 diff --git a/arch/ia64/include/asm/gpio.h b/arch/ia64/include/asm/gpio.h deleted file mode 100644 index 590a20d..0000000 --- a/arch/ia64/include/asm/gpio.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Generic GPIO API implementation for IA-64. - * - * A stright copy of that for PowerPC which was: - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_IA64_GPIO_H -#define _ASM_IA64_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * We don't (yet) implement inlined/rapid versions for on-chip gpios. - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_IA64_GPIO_H */ diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu index e632b2d..d4a818b 100644 --- a/arch/m68k/Kconfig.cpu +++ b/arch/m68k/Kconfig.cpu @@ -21,6 +21,7 @@ config MCPU32 config COLDFIRE bool select GENERIC_GPIO + select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_REQUIRE_GPIOLIB select CPU_HAS_NO_BITFIELDS help diff --git a/arch/microblaze/include/asm/gpio.h b/arch/microblaze/include/asm/gpio.h deleted file mode 100644 index 2b2c18b..0000000 --- a/arch/microblaze/include/asm/gpio.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Generic GPIO API implementation for PowerPC. - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_MICROBLAZE_GPIO_H -#define _ASM_MICROBLAZE_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * We don't (yet) implement inlined/rapid versions for on-chip gpios. - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_MICROBLAZE_GPIO_H */ diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 62b9677..567290c 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -8,6 +8,7 @@ config MIPS select HAVE_PERF_EVENTS select PERF_USE_VMALLOC select HAVE_ARCH_KGDB + select ARCH_HAVE_CUSTOM_GPIO_H select HAVE_FUNCTION_TRACER select HAVE_FUNCTION_TRACE_MCOUNT_TEST select HAVE_DYNAMIC_FTRACE diff --git a/arch/openrisc/include/asm/gpio.h b/arch/openrisc/include/asm/gpio.h deleted file mode 100644 index 0b0d174..0000000 --- a/arch/openrisc/include/asm/gpio.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * OpenRISC Linux - * - * Linux architectural port borrowing liberally from similar works of - * others. All original copyrights apply as per the original source - * declaration. - * - * OpenRISC implementation: - * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> - * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> - * et al. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef __ASM_OPENRISC_GPIO_H -#define __ASM_OPENRISC_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * OpenRISC (or1k) does not have on-chip GPIO's so there is not really - * any standardized implementation that makes sense here. If passing - * through gpiolib becomes a bottleneck then it may make sense, on a - * case-by-case basis, to implement these inlined/rapid versions. - * - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -/* - * Not implemented, yet. - */ -static inline int gpio_to_irq(unsigned int gpio) -{ - return -ENOSYS; -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* __ASM_OPENRISC_GPIO_H */ diff --git a/arch/powerpc/include/asm/gpio.h b/arch/powerpc/include/asm/gpio.h deleted file mode 100644 index 38762ed..0000000 --- a/arch/powerpc/include/asm/gpio.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Generic GPIO API implementation for PowerPC. - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef __ASM_POWERPC_GPIO_H -#define __ASM_POWERPC_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * We don't (yet) implement inlined/rapid versions for on-chip gpios. - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* __ASM_POWERPC_GPIO_H */ diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index ff9177c..d00e11a 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -11,6 +11,7 @@ config SUPERH select HAVE_DMA_ATTRS select HAVE_IRQ_WORK select HAVE_PERF_EVENTS + select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_HAVE_NMI_SAFE_CMPXCHG if (GUSA_RB || CPU_SH4A) select PERF_USE_VMALLOC select HAVE_KERNEL_GZIP diff --git a/arch/sparc/include/asm/gpio.h b/arch/sparc/include/asm/gpio.h deleted file mode 100644 index a0e3ac0..0000000 --- a/arch/sparc/include/asm/gpio.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef __ASM_SPARC_GPIO_H -#define __ASM_SPARC_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return -ENOSYS; -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* __ASM_SPARC_GPIO_H */ diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig index e57dcce..7bdc7c6 100644 --- a/arch/unicore32/Kconfig +++ b/arch/unicore32/Kconfig @@ -8,6 +8,7 @@ config UNICORE32 select HAVE_KERNEL_BZIP2 select HAVE_KERNEL_LZO select HAVE_KERNEL_LZMA + select ARCH_HAVE_CUSTOM_GPIO_H select GENERIC_FIND_FIRST_BIT select GENERIC_IRQ_PROBE select GENERIC_IRQ_SHOW diff --git a/arch/x86/include/asm/gpio.h b/arch/x86/include/asm/gpio.h deleted file mode 100644 index 91d915a..0000000 --- a/arch/x86/include/asm/gpio.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Generic GPIO API implementation for x86. - * - * Derived from the generic GPIO API for powerpc: - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_X86_GPIO_H -#define _ASM_X86_GPIO_H - -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_X86_GPIO_H */ diff --git a/arch/xtensa/include/asm/gpio.h b/arch/xtensa/include/asm/gpio.h deleted file mode 100644 index a8c9fc4..0000000 --- a/arch/xtensa/include/asm/gpio.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Generic GPIO API implementation for xtensa. - * - * Stolen from x86, which is derived from the generic GPIO API for powerpc: - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_XTENSA_GPIO_H -#define _ASM_XTENSA_GPIO_H - -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -/* - * Not implemented, yet. - */ -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_XTENSA_GPIO_H */ diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index a107d44..ef920a2 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -2,6 +2,14 @@ # GPIO infrastructure and drivers # +config ARCH_HAVE_CUSTOM_GPIO_H + bool + help + Selecting this config option from the architecture Kconfig allows + the architecture to provide a custom asm/gpio.h implementation + overriding the default implementations. New uses of this are + strongly discouraged. + config ARCH_WANT_OPTIONAL_GPIOLIB bool help diff --git a/include/linux/gpio.h b/include/linux/gpio.h index 38ac48b..3149f68 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h @@ -1,6 +1,8 @@ #ifndef __LINUX_GPIO_H #define __LINUX_GPIO_H +#include <linux/errno.h> + /* see Documentation/gpio.txt */ /* make these flag values available regardless of GPIO kconfig options */ @@ -27,7 +29,39 @@ struct gpio { }; #ifdef CONFIG_GENERIC_GPIO + +#ifdef CONFIG_ARCH_HAVE_CUSTOM_GPIO_H #include <asm/gpio.h> +#else + +#include <asm-generic/gpio.h> + +static inline int gpio_get_value(unsigned int gpio) +{ + return __gpio_get_value(gpio); +} + +static inline void gpio_set_value(unsigned int gpio, int value) +{ + __gpio_set_value(gpio, value); +} + +static inline int gpio_cansleep(unsigned int gpio) +{ + return __gpio_cansleep(gpio); +} + +static inline int gpio_to_irq(unsigned int gpio) +{ + return __gpio_to_irq(gpio); +} + +static inline int irq_to_gpio(unsigned int irq) +{ + return -EINVAL; +} + +#endif #else -- 1.7.6.3 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h 2011-10-25 7:33 [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h Mark Brown @ 2011-10-25 8:33 ` Grant Likely 2011-10-25 8:39 ` Mark Brown 2011-10-25 23:44 ` Mike Frysinger ` (2 subsequent siblings) 3 siblings, 1 reply; 14+ messages in thread From: Grant Likely @ 2011-10-25 8:33 UTC (permalink / raw) To: Mark Brown Cc: Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt, Mike Frysinger, Geert Uytterhoeven, Ralf Baechle, Paul Mundt, Guan Xuetao, linux-arm-kernel, linux-kernel, uclinux-dist-devel, linux-m68k, linux-mips, linux-sh, linux-arch On Tue, Oct 25, 2011 at 09:33:32AM +0200, Mark Brown wrote: > Rather than requiring architectures that use gpiolib but don't have any > need to define anything custom to copy an asm/gpio.h provide a Kconfig > symbol which architectures must select in order to include gpio.h and > for other architectures just provide the trivial implementation directly. > > This makes it much easier to do gpiolib updates and is also a step towards > making gpiolib APIs available on every architecture. > > Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Grant Likely <grant.likely@secretlab.ca> (not that I've actually tested this much yet; it should probably go into a separate branch to marinate in linux-next for a bit without impacting the other GPIO patches I've got queued. g. > --- > arch/alpha/include/asm/gpio.h | 55 ------------------------------ > arch/arm/Kconfig | 1 + > arch/avr32/Kconfig | 1 + > arch/blackfin/Kconfig | 1 + > arch/ia64/include/asm/gpio.h | 55 ------------------------------ > arch/m68k/Kconfig.cpu | 1 + > arch/microblaze/include/asm/gpio.h | 53 ----------------------------- > arch/mips/Kconfig | 1 + > arch/openrisc/include/asm/gpio.h | 65 ------------------------------------ > arch/powerpc/include/asm/gpio.h | 53 ----------------------------- > arch/sh/Kconfig | 1 + > arch/sparc/include/asm/gpio.h | 36 -------------------- > arch/unicore32/Kconfig | 1 + > arch/x86/include/asm/gpio.h | 53 ----------------------------- > arch/xtensa/include/asm/gpio.h | 56 ------------------------------- > drivers/gpio/Kconfig | 8 ++++ > include/linux/gpio.h | 34 +++++++++++++++++++ > 17 files changed, 49 insertions(+), 426 deletions(-) > delete mode 100644 arch/alpha/include/asm/gpio.h > delete mode 100644 arch/ia64/include/asm/gpio.h > delete mode 100644 arch/microblaze/include/asm/gpio.h > delete mode 100644 arch/openrisc/include/asm/gpio.h > delete mode 100644 arch/powerpc/include/asm/gpio.h > delete mode 100644 arch/sparc/include/asm/gpio.h > delete mode 100644 arch/x86/include/asm/gpio.h > delete mode 100644 arch/xtensa/include/asm/gpio.h > > diff --git a/arch/alpha/include/asm/gpio.h b/arch/alpha/include/asm/gpio.h > deleted file mode 100644 > index 7dc6a63..0000000 > --- a/arch/alpha/include/asm/gpio.h > +++ /dev/null > @@ -1,55 +0,0 @@ > -/* > - * Generic GPIO API implementation for Alpha. > - * > - * A stright copy of that for PowerPC which was: > - * > - * Copyright (c) 2007-2008 MontaVista Software, Inc. > - * > - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> > - * > - * This program is free software; you can redistribute it and/or modify > - * it under the terms of the GNU General Public License as published by > - * the Free Software Foundation; either version 2 of the License, or > - * (at your option) any later version. > - */ > - > -#ifndef _ASM_ALPHA_GPIO_H > -#define _ASM_ALPHA_GPIO_H > - > -#include <linux/errno.h> > -#include <asm-generic/gpio.h> > - > -#ifdef CONFIG_GPIOLIB > - > -/* > - * We don't (yet) implement inlined/rapid versions for on-chip gpios. > - * Just call gpiolib. > - */ > -static inline int gpio_get_value(unsigned int gpio) > -{ > - return __gpio_get_value(gpio); > -} > - > -static inline void gpio_set_value(unsigned int gpio, int value) > -{ > - __gpio_set_value(gpio, value); > -} > - > -static inline int gpio_cansleep(unsigned int gpio) > -{ > - return __gpio_cansleep(gpio); > -} > - > -static inline int gpio_to_irq(unsigned int gpio) > -{ > - return __gpio_to_irq(gpio); > -} > - > -static inline int irq_to_gpio(unsigned int irq) > -{ > - return -EINVAL; > -} > - > -#endif /* CONFIG_GPIOLIB */ > - > -#endif /* _ASM_ALPHA_GPIO_H */ > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig > index 7e8ffe7..5e0446c 100644 > --- a/arch/arm/Kconfig > +++ b/arch/arm/Kconfig > @@ -1,6 +1,7 @@ > config ARM > bool > default y > + select ARCH_HAVE_CUSTOM_GPIO_H > select HAVE_AOUT > select HAVE_DMA_API_DEBUG > select HAVE_IDE if PCI || ISA || PCMCIA > diff --git a/arch/avr32/Kconfig b/arch/avr32/Kconfig > index 197e96f..b2e3e58 100644 > --- a/arch/avr32/Kconfig > +++ b/arch/avr32/Kconfig > @@ -10,6 +10,7 @@ config AVR32 > select GENERIC_IRQ_PROBE > select HARDIRQS_SW_RESEND > select GENERIC_IRQ_SHOW > + select ARCH_HAVE_CUSTOM_GPIO_H > select ARCH_HAVE_NMI_SAFE_CMPXCHG > help > AVR32 is a high-performance 32-bit RISC microprocessor core, > diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig > index c747629..2c13eef 100644 > --- a/arch/blackfin/Kconfig > +++ b/arch/blackfin/Kconfig > @@ -31,6 +31,7 @@ config BLACKFIN > select HAVE_KERNEL_LZO if RAMKERNEL > select HAVE_OPROFILE > select HAVE_PERF_EVENTS > + select ARCH_HAVE_CUSTOM_GPIO_H > select ARCH_WANT_OPTIONAL_GPIOLIB > select HAVE_GENERIC_HARDIRQS > select GENERIC_ATOMIC64 > diff --git a/arch/ia64/include/asm/gpio.h b/arch/ia64/include/asm/gpio.h > deleted file mode 100644 > index 590a20d..0000000 > --- a/arch/ia64/include/asm/gpio.h > +++ /dev/null > @@ -1,55 +0,0 @@ > -/* > - * Generic GPIO API implementation for IA-64. > - * > - * A stright copy of that for PowerPC which was: > - * > - * Copyright (c) 2007-2008 MontaVista Software, Inc. > - * > - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> > - * > - * This program is free software; you can redistribute it and/or modify > - * it under the terms of the GNU General Public License as published by > - * the Free Software Foundation; either version 2 of the License, or > - * (at your option) any later version. > - */ > - > -#ifndef _ASM_IA64_GPIO_H > -#define _ASM_IA64_GPIO_H > - > -#include <linux/errno.h> > -#include <asm-generic/gpio.h> > - > -#ifdef CONFIG_GPIOLIB > - > -/* > - * We don't (yet) implement inlined/rapid versions for on-chip gpios. > - * Just call gpiolib. > - */ > -static inline int gpio_get_value(unsigned int gpio) > -{ > - return __gpio_get_value(gpio); > -} > - > -static inline void gpio_set_value(unsigned int gpio, int value) > -{ > - __gpio_set_value(gpio, value); > -} > - > -static inline int gpio_cansleep(unsigned int gpio) > -{ > - return __gpio_cansleep(gpio); > -} > - > -static inline int gpio_to_irq(unsigned int gpio) > -{ > - return __gpio_to_irq(gpio); > -} > - > -static inline int irq_to_gpio(unsigned int irq) > -{ > - return -EINVAL; > -} > - > -#endif /* CONFIG_GPIOLIB */ > - > -#endif /* _ASM_IA64_GPIO_H */ > diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu > index e632b2d..d4a818b 100644 > --- a/arch/m68k/Kconfig.cpu > +++ b/arch/m68k/Kconfig.cpu > @@ -21,6 +21,7 @@ config MCPU32 > config COLDFIRE > bool > select GENERIC_GPIO > + select ARCH_HAVE_CUSTOM_GPIO_H > select ARCH_REQUIRE_GPIOLIB > select CPU_HAS_NO_BITFIELDS > help > diff --git a/arch/microblaze/include/asm/gpio.h b/arch/microblaze/include/asm/gpio.h > deleted file mode 100644 > index 2b2c18b..0000000 > --- a/arch/microblaze/include/asm/gpio.h > +++ /dev/null > @@ -1,53 +0,0 @@ > -/* > - * Generic GPIO API implementation for PowerPC. > - * > - * Copyright (c) 2007-2008 MontaVista Software, Inc. > - * > - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> > - * > - * This program is free software; you can redistribute it and/or modify > - * it under the terms of the GNU General Public License as published by > - * the Free Software Foundation; either version 2 of the License, or > - * (at your option) any later version. > - */ > - > -#ifndef _ASM_MICROBLAZE_GPIO_H > -#define _ASM_MICROBLAZE_GPIO_H > - > -#include <linux/errno.h> > -#include <asm-generic/gpio.h> > - > -#ifdef CONFIG_GPIOLIB > - > -/* > - * We don't (yet) implement inlined/rapid versions for on-chip gpios. > - * Just call gpiolib. > - */ > -static inline int gpio_get_value(unsigned int gpio) > -{ > - return __gpio_get_value(gpio); > -} > - > -static inline void gpio_set_value(unsigned int gpio, int value) > -{ > - __gpio_set_value(gpio, value); > -} > - > -static inline int gpio_cansleep(unsigned int gpio) > -{ > - return __gpio_cansleep(gpio); > -} > - > -static inline int gpio_to_irq(unsigned int gpio) > -{ > - return __gpio_to_irq(gpio); > -} > - > -static inline int irq_to_gpio(unsigned int irq) > -{ > - return -EINVAL; > -} > - > -#endif /* CONFIG_GPIOLIB */ > - > -#endif /* _ASM_MICROBLAZE_GPIO_H */ > diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig > index 62b9677..567290c 100644 > --- a/arch/mips/Kconfig > +++ b/arch/mips/Kconfig > @@ -8,6 +8,7 @@ config MIPS > select HAVE_PERF_EVENTS > select PERF_USE_VMALLOC > select HAVE_ARCH_KGDB > + select ARCH_HAVE_CUSTOM_GPIO_H > select HAVE_FUNCTION_TRACER > select HAVE_FUNCTION_TRACE_MCOUNT_TEST > select HAVE_DYNAMIC_FTRACE > diff --git a/arch/openrisc/include/asm/gpio.h b/arch/openrisc/include/asm/gpio.h > deleted file mode 100644 > index 0b0d174..0000000 > --- a/arch/openrisc/include/asm/gpio.h > +++ /dev/null > @@ -1,65 +0,0 @@ > -/* > - * OpenRISC Linux > - * > - * Linux architectural port borrowing liberally from similar works of > - * others. All original copyrights apply as per the original source > - * declaration. > - * > - * OpenRISC implementation: > - * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> > - * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> > - * et al. > - * > - * This program is free software; you can redistribute it and/or modify > - * it under the terms of the GNU General Public License as published by > - * the Free Software Foundation; either version 2 of the License, or > - * (at your option) any later version. > - */ > - > -#ifndef __ASM_OPENRISC_GPIO_H > -#define __ASM_OPENRISC_GPIO_H > - > -#include <linux/errno.h> > -#include <asm-generic/gpio.h> > - > -#ifdef CONFIG_GPIOLIB > - > -/* > - * OpenRISC (or1k) does not have on-chip GPIO's so there is not really > - * any standardized implementation that makes sense here. If passing > - * through gpiolib becomes a bottleneck then it may make sense, on a > - * case-by-case basis, to implement these inlined/rapid versions. > - * > - * Just call gpiolib. > - */ > -static inline int gpio_get_value(unsigned int gpio) > -{ > - return __gpio_get_value(gpio); > -} > - > -static inline void gpio_set_value(unsigned int gpio, int value) > -{ > - __gpio_set_value(gpio, value); > -} > - > -static inline int gpio_cansleep(unsigned int gpio) > -{ > - return __gpio_cansleep(gpio); > -} > - > -/* > - * Not implemented, yet. > - */ > -static inline int gpio_to_irq(unsigned int gpio) > -{ > - return -ENOSYS; > -} > - > -static inline int irq_to_gpio(unsigned int irq) > -{ > - return -EINVAL; > -} > - > -#endif /* CONFIG_GPIOLIB */ > - > -#endif /* __ASM_OPENRISC_GPIO_H */ > diff --git a/arch/powerpc/include/asm/gpio.h b/arch/powerpc/include/asm/gpio.h > deleted file mode 100644 > index 38762ed..0000000 > --- a/arch/powerpc/include/asm/gpio.h > +++ /dev/null > @@ -1,53 +0,0 @@ > -/* > - * Generic GPIO API implementation for PowerPC. > - * > - * Copyright (c) 2007-2008 MontaVista Software, Inc. > - * > - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> > - * > - * This program is free software; you can redistribute it and/or modify > - * it under the terms of the GNU General Public License as published by > - * the Free Software Foundation; either version 2 of the License, or > - * (at your option) any later version. > - */ > - > -#ifndef __ASM_POWERPC_GPIO_H > -#define __ASM_POWERPC_GPIO_H > - > -#include <linux/errno.h> > -#include <asm-generic/gpio.h> > - > -#ifdef CONFIG_GPIOLIB > - > -/* > - * We don't (yet) implement inlined/rapid versions for on-chip gpios. > - * Just call gpiolib. > - */ > -static inline int gpio_get_value(unsigned int gpio) > -{ > - return __gpio_get_value(gpio); > -} > - > -static inline void gpio_set_value(unsigned int gpio, int value) > -{ > - __gpio_set_value(gpio, value); > -} > - > -static inline int gpio_cansleep(unsigned int gpio) > -{ > - return __gpio_cansleep(gpio); > -} > - > -static inline int gpio_to_irq(unsigned int gpio) > -{ > - return __gpio_to_irq(gpio); > -} > - > -static inline int irq_to_gpio(unsigned int irq) > -{ > - return -EINVAL; > -} > - > -#endif /* CONFIG_GPIOLIB */ > - > -#endif /* __ASM_POWERPC_GPIO_H */ > diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig > index ff9177c..d00e11a 100644 > --- a/arch/sh/Kconfig > +++ b/arch/sh/Kconfig > @@ -11,6 +11,7 @@ config SUPERH > select HAVE_DMA_ATTRS > select HAVE_IRQ_WORK > select HAVE_PERF_EVENTS > + select ARCH_HAVE_CUSTOM_GPIO_H > select ARCH_HAVE_NMI_SAFE_CMPXCHG if (GUSA_RB || CPU_SH4A) > select PERF_USE_VMALLOC > select HAVE_KERNEL_GZIP > diff --git a/arch/sparc/include/asm/gpio.h b/arch/sparc/include/asm/gpio.h > deleted file mode 100644 > index a0e3ac0..0000000 > --- a/arch/sparc/include/asm/gpio.h > +++ /dev/null > @@ -1,36 +0,0 @@ > -#ifndef __ASM_SPARC_GPIO_H > -#define __ASM_SPARC_GPIO_H > - > -#include <linux/errno.h> > -#include <asm-generic/gpio.h> > - > -#ifdef CONFIG_GPIOLIB > - > -static inline int gpio_get_value(unsigned int gpio) > -{ > - return __gpio_get_value(gpio); > -} > - > -static inline void gpio_set_value(unsigned int gpio, int value) > -{ > - __gpio_set_value(gpio, value); > -} > - > -static inline int gpio_cansleep(unsigned int gpio) > -{ > - return __gpio_cansleep(gpio); > -} > - > -static inline int gpio_to_irq(unsigned int gpio) > -{ > - return -ENOSYS; > -} > - > -static inline int irq_to_gpio(unsigned int irq) > -{ > - return -EINVAL; > -} > - > -#endif /* CONFIG_GPIOLIB */ > - > -#endif /* __ASM_SPARC_GPIO_H */ > diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig > index e57dcce..7bdc7c6 100644 > --- a/arch/unicore32/Kconfig > +++ b/arch/unicore32/Kconfig > @@ -8,6 +8,7 @@ config UNICORE32 > select HAVE_KERNEL_BZIP2 > select HAVE_KERNEL_LZO > select HAVE_KERNEL_LZMA > + select ARCH_HAVE_CUSTOM_GPIO_H > select GENERIC_FIND_FIRST_BIT > select GENERIC_IRQ_PROBE > select GENERIC_IRQ_SHOW > diff --git a/arch/x86/include/asm/gpio.h b/arch/x86/include/asm/gpio.h > deleted file mode 100644 > index 91d915a..0000000 > --- a/arch/x86/include/asm/gpio.h > +++ /dev/null > @@ -1,53 +0,0 @@ > -/* > - * Generic GPIO API implementation for x86. > - * > - * Derived from the generic GPIO API for powerpc: > - * > - * Copyright (c) 2007-2008 MontaVista Software, Inc. > - * > - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> > - * > - * This program is free software; you can redistribute it and/or modify > - * it under the terms of the GNU General Public License as published by > - * the Free Software Foundation; either version 2 of the License, or > - * (at your option) any later version. > - */ > - > -#ifndef _ASM_X86_GPIO_H > -#define _ASM_X86_GPIO_H > - > -#include <asm-generic/gpio.h> > - > -#ifdef CONFIG_GPIOLIB > - > -/* > - * Just call gpiolib. > - */ > -static inline int gpio_get_value(unsigned int gpio) > -{ > - return __gpio_get_value(gpio); > -} > - > -static inline void gpio_set_value(unsigned int gpio, int value) > -{ > - __gpio_set_value(gpio, value); > -} > - > -static inline int gpio_cansleep(unsigned int gpio) > -{ > - return __gpio_cansleep(gpio); > -} > - > -static inline int gpio_to_irq(unsigned int gpio) > -{ > - return __gpio_to_irq(gpio); > -} > - > -static inline int irq_to_gpio(unsigned int irq) > -{ > - return -EINVAL; > -} > - > -#endif /* CONFIG_GPIOLIB */ > - > -#endif /* _ASM_X86_GPIO_H */ > diff --git a/arch/xtensa/include/asm/gpio.h b/arch/xtensa/include/asm/gpio.h > deleted file mode 100644 > index a8c9fc4..0000000 > --- a/arch/xtensa/include/asm/gpio.h > +++ /dev/null > @@ -1,56 +0,0 @@ > -/* > - * Generic GPIO API implementation for xtensa. > - * > - * Stolen from x86, which is derived from the generic GPIO API for powerpc: > - * > - * Copyright (c) 2007-2008 MontaVista Software, Inc. > - * > - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> > - * > - * This program is free software; you can redistribute it and/or modify > - * it under the terms of the GNU General Public License as published by > - * the Free Software Foundation; either version 2 of the License, or > - * (at your option) any later version. > - */ > - > -#ifndef _ASM_XTENSA_GPIO_H > -#define _ASM_XTENSA_GPIO_H > - > -#include <asm-generic/gpio.h> > - > -#ifdef CONFIG_GPIOLIB > - > -/* > - * Just call gpiolib. > - */ > -static inline int gpio_get_value(unsigned int gpio) > -{ > - return __gpio_get_value(gpio); > -} > - > -static inline void gpio_set_value(unsigned int gpio, int value) > -{ > - __gpio_set_value(gpio, value); > -} > - > -static inline int gpio_cansleep(unsigned int gpio) > -{ > - return __gpio_cansleep(gpio); > -} > - > -static inline int gpio_to_irq(unsigned int gpio) > -{ > - return __gpio_to_irq(gpio); > -} > - > -/* > - * Not implemented, yet. > - */ > -static inline int irq_to_gpio(unsigned int irq) > -{ > - return -EINVAL; > -} > - > -#endif /* CONFIG_GPIOLIB */ > - > -#endif /* _ASM_XTENSA_GPIO_H */ > diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig > index a107d44..ef920a2 100644 > --- a/drivers/gpio/Kconfig > +++ b/drivers/gpio/Kconfig > @@ -2,6 +2,14 @@ > # GPIO infrastructure and drivers > # > > +config ARCH_HAVE_CUSTOM_GPIO_H > + bool > + help > + Selecting this config option from the architecture Kconfig allows > + the architecture to provide a custom asm/gpio.h implementation > + overriding the default implementations. New uses of this are > + strongly discouraged. > + > config ARCH_WANT_OPTIONAL_GPIOLIB > bool > help > diff --git a/include/linux/gpio.h b/include/linux/gpio.h > index 38ac48b..3149f68 100644 > --- a/include/linux/gpio.h > +++ b/include/linux/gpio.h > @@ -1,6 +1,8 @@ > #ifndef __LINUX_GPIO_H > #define __LINUX_GPIO_H > > +#include <linux/errno.h> > + > /* see Documentation/gpio.txt */ > > /* make these flag values available regardless of GPIO kconfig options */ > @@ -27,7 +29,39 @@ struct gpio { > }; > > #ifdef CONFIG_GENERIC_GPIO > + > +#ifdef CONFIG_ARCH_HAVE_CUSTOM_GPIO_H > #include <asm/gpio.h> > +#else > + > +#include <asm-generic/gpio.h> > + > +static inline int gpio_get_value(unsigned int gpio) > +{ > + return __gpio_get_value(gpio); > +} > + > +static inline void gpio_set_value(unsigned int gpio, int value) > +{ > + __gpio_set_value(gpio, value); > +} > + > +static inline int gpio_cansleep(unsigned int gpio) > +{ > + return __gpio_cansleep(gpio); > +} > + > +static inline int gpio_to_irq(unsigned int gpio) > +{ > + return __gpio_to_irq(gpio); > +} > + > +static inline int irq_to_gpio(unsigned int irq) > +{ > + return -EINVAL; > +} > + > +#endif > > #else > > -- > 1.7.6.3 > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h 2011-10-25 8:33 ` Grant Likely @ 2011-10-25 8:39 ` Mark Brown 0 siblings, 0 replies; 14+ messages in thread From: Mark Brown @ 2011-10-25 8:39 UTC (permalink / raw) To: Grant Likely Cc: Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt, Mike Frysinger, Geert Uytterhoeven, Ralf Baechle, Paul Mundt, Guan Xuetao, linux-arm-kernel, linux-kernel, uclinux-dist-devel, linux-m68k, linux-mips, linux-sh, linux-arch On Tue, Oct 25, 2011 at 10:33:01AM +0200, Grant Likely wrote: > (not that I've actually tested this much yet; it should probably go > into a separate branch to marinate in linux-next for a bit without > impacting the other GPIO patches I've got queued. Yes, it should. I've test built a few configurations covering both asm/gpio.h and default implementations and it seems to be doing the right thing but I might well have missed something. I'm hoping to also have a further patch to go on top of this which makes _OPTIONAL_GPOILIB on by default. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h 2011-10-25 7:33 [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h Mark Brown 2011-10-25 8:33 ` Grant Likely @ 2011-10-25 23:44 ` Mike Frysinger 2011-10-26 7:33 ` Mark Brown 2011-10-27 13:01 ` [PATCH] asm-generic/gpio.h: merge basic gpiolib wrappers Mike Frysinger 2012-02-04 15:54 ` [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h Mark Brown 3 siblings, 1 reply; 14+ messages in thread From: Mike Frysinger @ 2011-10-25 23:44 UTC (permalink / raw) To: Mark Brown Cc: Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt, Geert Uytterhoeven, Ralf Baechle, Paul Mundt, Guan Xuetao, Grant Likely, linux-arm-kernel, linux-kernel, uclinux-dist-devel, linux-m68k, linux-mips, linux-sh, linux-arch On Tue, Oct 25, 2011 at 03:33, Mark Brown wrote: > Rather than requiring architectures that use gpiolib but don't have any > need to define anything custom to copy an asm/gpio.h provide a Kconfig > symbol which architectures must select in order to include gpio.h and > for other architectures just provide the trivial implementation directly. i don't think this is generally how asm-generic is handled. instead, how about: - move the duplicate code to asm-generic/gpio.h - have the arches which merely need asm-generic/gpio.h add "generic-y += gpio.h" to their include/asm/Kbuild - for arches which need to override these common funcs in some way, add #ifdef protection to the asm-generic/gpio.h and it seems like with slightly more work, this path allow you to merge most of arch/sh/include/asm/gpio.h. and it has the advantage of not needing new Kconfig symbols. for example, with asm-generic/atomic.h, it does: #ifndef atomic_sub_return static inline int atomic_sub_return(int i, atomic_t *v) { ... common implementation ... } #endif and then any arch that wants to override it does: #define atomic_sub_return atomic_sub_return static inline int atomic_sub_return(int i, atomic_t *v) { weirdness } #include <asm-generic/atomic.h> -mike ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h 2011-10-25 23:44 ` Mike Frysinger @ 2011-10-26 7:33 ` Mark Brown 2012-02-03 23:16 ` Grant Likely 0 siblings, 1 reply; 14+ messages in thread From: Mark Brown @ 2011-10-26 7:33 UTC (permalink / raw) To: Mike Frysinger Cc: Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt, Geert Uytterhoeven, Ralf Baechle, Paul Mundt, Guan Xuetao, Grant Likely, linux-arm-kernel, linux-kernel, uclinux-dist-devel, linux-m68k, linux-mips, linux-sh, linux-arch On Tue, Oct 25, 2011 at 07:44:14PM -0400, Mike Frysinger wrote: > i don't think this is generally how asm-generic is handled. instead, how about: > - move the duplicate code to asm-generic/gpio.h > - have the arches which merely need asm-generic/gpio.h add "generic-y > += gpio.h" to their include/asm/Kbuild > - for arches which need to override these common funcs in some way, > add #ifdef protection to the asm-generic/gpio.h > and it seems like with slightly more work, this path allow you to > merge most of arch/sh/include/asm/gpio.h. and it has the advantage of > not needing new Kconfig symbols. That's really not how gpiolib is currently handled, unfortunately - trying to transition over to that model in one patch would be way too much. The goal here from that point of view is to make transitioning to something more sensible easier by getting rid of the boilerplate code, it makes doing the more invasive changes like you're suggesting much easier as we're only dealing with the architectures that are actually doing something. It also means that we're able to immediately work on turning on gpiolib on random architectures which is a definite win. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h 2011-10-26 7:33 ` Mark Brown @ 2012-02-03 23:16 ` Grant Likely 0 siblings, 0 replies; 14+ messages in thread From: Grant Likely @ 2012-02-03 23:16 UTC (permalink / raw) To: Mark Brown Cc: Mike Frysinger, Russell King, Haavard Skinnemoen, Hans-Christian Egtvedt, Geert Uytterhoeven, Ralf Baechle, Paul Mundt, Guan Xuetao, linux-arm-kernel, linux-kernel, uclinux-dist-devel, linux-m68k, linux-mips, linux-sh, linux-arch On Wed, Oct 26, 2011 at 1:33 AM, Mark Brown <broonie@opensource.wolfsonmicro.com> wrote: > On Tue, Oct 25, 2011 at 07:44:14PM -0400, Mike Frysinger wrote: > >> i don't think this is generally how asm-generic is handled. instead, how about: >> - move the duplicate code to asm-generic/gpio.h >> - have the arches which merely need asm-generic/gpio.h add "generic-y >> += gpio.h" to their include/asm/Kbuild >> - for arches which need to override these common funcs in some way, >> add #ifdef protection to the asm-generic/gpio.h > >> and it seems like with slightly more work, this path allow you to >> merge most of arch/sh/include/asm/gpio.h. and it has the advantage of >> not needing new Kconfig symbols. > > That's really not how gpiolib is currently handled, unfortunately - > trying to transition over to that model in one patch would be way too > much. > > The goal here from that point of view is to make transitioning to > something more sensible easier by getting rid of the boilerplate code, > it makes doing the more invasive changes like you're suggesting much > easier as we're only dealing with the architectures that are actually > doing something. It also means that we're able to immediately work on > turning on gpiolib on random architectures which is a definite win. I had picked up this patch, but I've dropped again from gpio/next since there are still a lot of drivers including asm/gpio.h. It caused build breakage on linux-next with allmodconfig. g. -- Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] asm-generic/gpio.h: merge basic gpiolib wrappers 2011-10-25 7:33 [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h Mark Brown 2011-10-25 8:33 ` Grant Likely 2011-10-25 23:44 ` Mike Frysinger @ 2011-10-27 13:01 ` Mike Frysinger 2011-10-27 22:52 ` [PATCH v2] " Mike Frysinger 2011-11-03 3:45 ` [PATCH v3] " Mike Frysinger 2012-02-04 15:54 ` [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h Mark Brown 3 siblings, 2 replies; 14+ messages in thread From: Mike Frysinger @ 2011-10-27 13:01 UTC (permalink / raw) To: Grant Likely, Richard Henderson, Ivan Kokshaysky, Matt Turner, Haavard Skinnemoen <hskin> Cc: linux-alpha, linux-arch, linux-ia64, microblaze-uclinux, linux-mips, linux-sh, linux, linuxppc-dev, sparclinux, x86, linux-arm-kernel, uclinux-dist-devel, linux-kernel, Mike Frysinger, linux-m68k Rather than requiring architectures that use gpiolib but don't have any need to define anything custom to copy an asm/gpio.h, merge this code into the asm-generic/gpio.h. We add ifdef checks so that arches can still override things while using the asm-generic/gpio.h, but on a more fine grained per-func approach. I've compile tested these guys (with & without GPIOLIB), but don't have the hardware to boot: - alpha defconfig - arm defconfig - blackfin defconfig - ia64 defconfig - mips: ar7 & ath79 & bcm47xx & bcm63xx & ip22 defconfig - powerpc: mpc85xx & ppc64 defconfig - sh: kfr2r09 defconfig - sparc defconfig - x86_64 defconfig I don't have any toolchains for avr32, microblaze, openrisc, unicore32, or xtensa. So they lose :x. I don't see m68k supporting gpoilib, so I've just ignored it. Signed-off-by: Mike Frysinger <vapier@gentoo.org> --- arch/alpha/include/asm/Kbuild | 2 + arch/alpha/include/asm/gpio.h | 55 ------------------- arch/arm/include/asm/gpio.h | 13 +++-- arch/avr32/mach-at32ap/include/mach/gpio.h | 19 +------ arch/blackfin/include/asm/gpio.h | 16 ++---- arch/ia64/include/asm/Kbuild | 2 + arch/ia64/include/asm/gpio.h | 55 ------------------- arch/microblaze/include/asm/Kbuild | 2 + arch/microblaze/include/asm/gpio.h | 53 ------------------ arch/mips/include/asm/mach-ar7/gpio.h | 5 -- arch/mips/include/asm/mach-ath79/gpio.h | 8 ++- arch/mips/include/asm/mach-bcm47xx/gpio.h | 3 + arch/mips/include/asm/mach-bcm63xx/gpio.h | 5 -- arch/mips/include/asm/mach-generic/gpio.h | 8 +-- arch/mips/include/asm/mach-loongson/gpio.h | 7 +-- arch/mips/include/asm/mach-rc32434/gpio.h | 10 +--- arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h | 12 +--- arch/openrisc/include/asm/Kbuild | 1 + arch/openrisc/include/asm/gpio.h | 65 ----------------------- arch/powerpc/include/asm/Kbuild | 2 + arch/powerpc/include/asm/gpio.h | 53 ------------------ arch/sh/include/asm/gpio.h | 32 +----------- arch/sparc/include/asm/Kbuild | 1 + arch/sparc/include/asm/gpio.h | 36 ------------- arch/unicore32/include/asm/gpio.h | 8 ++- arch/x86/include/asm/Kbuild | 2 + arch/x86/include/asm/gpio.h | 53 ------------------ arch/xtensa/include/asm/Kbuild | 2 + arch/xtensa/include/asm/gpio.h | 56 ------------------- include/asm-generic/gpio.h | 23 ++++++++ 30 files changed, 81 insertions(+), 528 deletions(-) delete mode 100644 arch/alpha/include/asm/gpio.h delete mode 100644 arch/ia64/include/asm/gpio.h delete mode 100644 arch/microblaze/include/asm/gpio.h delete mode 100644 arch/openrisc/include/asm/gpio.h delete mode 100644 arch/powerpc/include/asm/gpio.h delete mode 100644 arch/sparc/include/asm/gpio.h delete mode 100644 arch/x86/include/asm/gpio.h delete mode 100644 arch/xtensa/include/asm/gpio.h diff --git a/arch/alpha/include/asm/Kbuild b/arch/alpha/include/asm/Kbuild index e423def..0bcff1a 100644 --- a/arch/alpha/include/asm/Kbuild +++ b/arch/alpha/include/asm/Kbuild @@ -1,5 +1,7 @@ include include/asm-generic/Kbuild.asm +generic-y += gpio.h + header-y += compiler.h header-y += console.h header-y += fpu.h diff --git a/arch/alpha/include/asm/gpio.h b/arch/alpha/include/asm/gpio.h deleted file mode 100644 index 7dc6a63..0000000 --- a/arch/alpha/include/asm/gpio.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Generic GPIO API implementation for Alpha. - * - * A stright copy of that for PowerPC which was: - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_ALPHA_GPIO_H -#define _ASM_ALPHA_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * We don't (yet) implement inlined/rapid versions for on-chip gpios. - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_ALPHA_GPIO_H */ diff --git a/arch/arm/include/asm/gpio.h b/arch/arm/include/asm/gpio.h index 11ad0bf..741efb2 100644 --- a/arch/arm/include/asm/gpio.h +++ b/arch/arm/include/asm/gpio.h @@ -5,14 +5,15 @@ #include <mach/gpio.h> #ifndef __ARM_GPIOLIB_COMPLEX +/* assume the mach has defined this */ +#ifndef irq_to_gpio +#define irq_to_gpio irq_to_gpio +#endif + /* Note: this may rely upon the value of ARCH_NR_GPIOS set in mach/gpio.h */ #include <asm-generic/gpio.h> -/* The trivial gpiolib dispatchers */ -#define gpio_get_value __gpio_get_value -#define gpio_set_value __gpio_set_value -#define gpio_cansleep __gpio_cansleep -#endif +#else /* * Provide a default gpio_to_irq() which should satisfy every case. @@ -23,4 +24,6 @@ #define gpio_to_irq __gpio_to_irq #endif +#endif + #endif /* _ARCH_ARM_GPIO_H */ diff --git a/arch/avr32/mach-at32ap/include/mach/gpio.h b/arch/avr32/mach-at32ap/include/mach/gpio.h index 0180f58..f2ff962 100644 --- a/arch/avr32/mach-at32ap/include/mach/gpio.h +++ b/arch/avr32/mach-at32ap/include/mach/gpio.h @@ -10,26 +10,13 @@ */ #define ARCH_NR_GPIOS (NR_GPIO_IRQS + 2 * 32) +/* We implement a few ourself */ +#define gpio_to_irq gpio_to_irq +#define irq_to_gpio irq_to_gpio /* Arch-neutral GPIO API, supporting both "native" and external GPIOs. */ #include <asm-generic/gpio.h> -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - - static inline int gpio_to_irq(unsigned int gpio) { if (gpio < NR_GPIO_IRQS) diff --git a/arch/blackfin/include/asm/gpio.h b/arch/blackfin/include/asm/gpio.h index 5a25856..6e25dcc 100644 --- a/arch/blackfin/include/asm/gpio.h +++ b/arch/blackfin/include/asm/gpio.h @@ -189,6 +189,12 @@ void bfin_gpio_set_value(unsigned gpio, int value); #include <asm/errno.h> #ifdef CONFIG_GPIOLIB + +/* We implement a few ourself */ +#define gpio_get_value gpio_get_value +#define gpio_set_value gpio_set_value +#define irq_to_gpio irq_to_gpio + #include <asm-generic/gpio.h> /* cansleep wrappers */ static inline int gpio_get_value(unsigned int gpio) @@ -207,16 +213,6 @@ static inline void gpio_set_value(unsigned int gpio, int value) __gpio_set_value(gpio, value); } -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned gpio) -{ - return __gpio_to_irq(gpio); -} - #else /* !CONFIG_GPIOLIB */ static inline int gpio_request(unsigned gpio, const char *label) diff --git a/arch/ia64/include/asm/Kbuild b/arch/ia64/include/asm/Kbuild index 241d1c5..d0fdd2d 100644 --- a/arch/ia64/include/asm/Kbuild +++ b/arch/ia64/include/asm/Kbuild @@ -1,5 +1,7 @@ include include/asm-generic/Kbuild.asm +generic-y += gpio.h + header-y += break.h header-y += fpu.h header-y += gcc_intrin.h diff --git a/arch/ia64/include/asm/gpio.h b/arch/ia64/include/asm/gpio.h deleted file mode 100644 index 590a20d..0000000 --- a/arch/ia64/include/asm/gpio.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Generic GPIO API implementation for IA-64. - * - * A stright copy of that for PowerPC which was: - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_IA64_GPIO_H -#define _ASM_IA64_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * We don't (yet) implement inlined/rapid versions for on-chip gpios. - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_IA64_GPIO_H */ diff --git a/arch/microblaze/include/asm/Kbuild b/arch/microblaze/include/asm/Kbuild index db5294c..5bf1ca7 100644 --- a/arch/microblaze/include/asm/Kbuild +++ b/arch/microblaze/include/asm/Kbuild @@ -1,3 +1,5 @@ include include/asm-generic/Kbuild.asm +generic-y += gpio.h + header-y += elf.h diff --git a/arch/microblaze/include/asm/gpio.h b/arch/microblaze/include/asm/gpio.h deleted file mode 100644 index 2b2c18b..0000000 --- a/arch/microblaze/include/asm/gpio.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Generic GPIO API implementation for PowerPC. - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_MICROBLAZE_GPIO_H -#define _ASM_MICROBLAZE_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * We don't (yet) implement inlined/rapid versions for on-chip gpios. - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_MICROBLAZE_GPIO_H */ diff --git a/arch/mips/include/asm/mach-ar7/gpio.h b/arch/mips/include/asm/mach-ar7/gpio.h index c177cd1..78f40c2 100644 --- a/arch/mips/include/asm/mach-ar7/gpio.h +++ b/arch/mips/include/asm/mach-ar7/gpio.h @@ -27,11 +27,6 @@ #define gpio_to_irq(gpio) -1 -#define gpio_get_value __gpio_get_value -#define gpio_set_value __gpio_set_value - -#define gpio_cansleep __gpio_cansleep - /* Board specific GPIO functions */ int ar7_gpio_enable(unsigned gpio); int ar7_gpio_disable(unsigned gpio); diff --git a/arch/mips/include/asm/mach-ath79/gpio.h b/arch/mips/include/asm/mach-ath79/gpio.h index 60dcb62..2c570a0 100644 --- a/arch/mips/include/asm/mach-ath79/gpio.h +++ b/arch/mips/include/asm/mach-ath79/gpio.h @@ -13,6 +13,12 @@ #ifndef __ASM_MACH_ATH79_GPIO_H #define __ASM_MACH_ATH79_GPIO_H +/* We implement a few ourself */ +#define gpio_get_value gpio_get_value +#define gpio_set_value gpio_set_value +#define gpio_to_irq gpio_to_irq +#define irq_to_gpio irq_to_gpio + #define ARCH_NR_GPIOS 64 #include <asm-generic/gpio.h> @@ -21,6 +27,4 @@ int irq_to_gpio(unsigned irq); int gpio_get_value(unsigned gpio); void gpio_set_value(unsigned gpio, int value); -#define gpio_cansleep __gpio_cansleep - #endif /* __ASM_MACH_ATH79_GPIO_H */ diff --git a/arch/mips/include/asm/mach-bcm47xx/gpio.h b/arch/mips/include/asm/mach-bcm47xx/gpio.h index 76961ca..d678316 100644 --- a/arch/mips/include/asm/mach-bcm47xx/gpio.h +++ b/arch/mips/include/asm/mach-bcm47xx/gpio.h @@ -19,6 +19,7 @@ extern int gpio_request(unsigned gpio, const char *label); extern void gpio_free(unsigned gpio); extern int gpio_to_irq(unsigned gpio); +#define gpio_to_irq gpio_to_irq static inline int gpio_get_value(unsigned gpio) { @@ -35,6 +36,7 @@ static inline int gpio_get_value(unsigned gpio) } return -EINVAL; } +#define gpio_get_value gpio_get_value static inline void gpio_set_value(unsigned gpio, int value) { @@ -53,6 +55,7 @@ static inline void gpio_set_value(unsigned gpio, int value) #endif } } +#define gpio_set_value gpio_set_value static inline int gpio_direction_input(unsigned gpio) { diff --git a/arch/mips/include/asm/mach-bcm63xx/gpio.h b/arch/mips/include/asm/mach-bcm63xx/gpio.h index 1eb534d..c71bf66 100644 --- a/arch/mips/include/asm/mach-bcm63xx/gpio.h +++ b/arch/mips/include/asm/mach-bcm63xx/gpio.h @@ -5,11 +5,6 @@ #define gpio_to_irq(gpio) -1 -#define gpio_get_value __gpio_get_value -#define gpio_set_value __gpio_set_value - -#define gpio_cansleep __gpio_cansleep - #include <asm-generic/gpio.h> #endif /* __ASM_MIPS_MACH_BCM63XX_GPIO_H */ diff --git a/arch/mips/include/asm/mach-generic/gpio.h b/arch/mips/include/asm/mach-generic/gpio.h index b4e7020..e8a89c5 100644 --- a/arch/mips/include/asm/mach-generic/gpio.h +++ b/arch/mips/include/asm/mach-generic/gpio.h @@ -1,11 +1,7 @@ #ifndef __ASM_MACH_GENERIC_GPIO_H #define __ASM_MACH_GENERIC_GPIO_H -#ifdef CONFIG_GPIOLIB -#define gpio_get_value __gpio_get_value -#define gpio_set_value __gpio_set_value -#define gpio_cansleep __gpio_cansleep -#else +#ifndef CONFIG_GPIOLIB int gpio_request(unsigned gpio, const char *label); void gpio_free(unsigned gpio); int gpio_direction_input(unsigned gpio); @@ -14,7 +10,9 @@ int gpio_get_value(unsigned gpio); void gpio_set_value(unsigned gpio, int value); #endif int gpio_to_irq(unsigned gpio); +#define gpio_to_irq gpio_to_irq int irq_to_gpio(unsigned irq); +#define irq_to_gpio irq_to_gpio #include <asm-generic/gpio.h> /* cansleep wrappers */ diff --git a/arch/mips/include/asm/mach-loongson/gpio.h b/arch/mips/include/asm/mach-loongson/gpio.h index e30e73d..df6efc0 100644 --- a/arch/mips/include/asm/mach-loongson/gpio.h +++ b/arch/mips/include/asm/mach-loongson/gpio.h @@ -13,6 +13,8 @@ #ifndef __STLS2F_GPIO_H #define __STLS2F_GPIO_H +#define gpio_to_irq gpio_to_irq + #include <asm-generic/gpio.h> extern void gpio_set_value(unsigned gpio, int value); @@ -27,9 +29,4 @@ static inline int gpio_to_irq(int gpio) return -EINVAL; } -static inline int irq_to_gpio(int gpio) -{ - return -EINVAL; -} - #endif /* __STLS2F_GPIO_H */ diff --git a/arch/mips/include/asm/mach-rc32434/gpio.h b/arch/mips/include/asm/mach-rc32434/gpio.h index 12ee8d5..8b0815b 100644 --- a/arch/mips/include/asm/mach-rc32434/gpio.h +++ b/arch/mips/include/asm/mach-rc32434/gpio.h @@ -13,18 +13,14 @@ #ifndef _RC32434_GPIO_H_ #define _RC32434_GPIO_H_ +#define gpio_to_irq(gpio) (8 + 4 * 32 + gpio) +#define irq_to_gpio(irq) (irq - (8 + 4 * 32)) + #include <linux/types.h> #include <asm-generic/gpio.h> #define NR_BUILTIN_GPIO 32 -#define gpio_get_value __gpio_get_value -#define gpio_set_value __gpio_set_value -#define gpio_cansleep __gpio_cansleep - -#define gpio_to_irq(gpio) (8 + 4 * 32 + gpio) -#define irq_to_gpio(irq) (irq - (8 + 4 * 32)) - struct rb532_gpio_reg { u32 gpiofunc; /* GPIO Function Register * gpiofunc[x]=0 bit = gpio diff --git a/arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h b/arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h index ebdbab9..8356a8e 100644 --- a/arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h +++ b/arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h @@ -11,16 +11,15 @@ #ifndef __PMC_MSP71XX_GPIO_H #define __PMC_MSP71XX_GPIO_H +/* We implement a few ourself */ +#define gpio_to_irq gpio_to_irq + /* Max number of gpio's is 28 on chip plus 3 banks of I2C IO Expanders */ #define ARCH_NR_GPIOS (28 + (3 * 8)) /* new generic GPIO API - see Documentation/gpio.txt */ #include <asm-generic/gpio.h> -#define gpio_get_value __gpio_get_value -#define gpio_set_value __gpio_set_value -#define gpio_cansleep __gpio_cansleep - /* Setup calls for the gpio and gpio extended */ extern void msp71xx_init_gpio(void); extern void msp71xx_init_gpio_extended(void); @@ -38,9 +37,4 @@ static inline int gpio_to_irq(unsigned gpio) return -EINVAL; } -static inline int irq_to_gpio(unsigned irq) -{ - return -EINVAL; -} - #endif /* __PMC_MSP71XX_GPIO_H */ diff --git a/arch/openrisc/include/asm/Kbuild b/arch/openrisc/include/asm/Kbuild index 11162e6..03f0823 100644 --- a/arch/openrisc/include/asm/Kbuild +++ b/arch/openrisc/include/asm/Kbuild @@ -23,6 +23,7 @@ generic-y += fb.h generic-y += fcntl.h generic-y += ftrace.h generic-y += futex.h +generic-y += gpio.h generic-y += hardirq.h generic-y += hw_irq.h generic-y += ioctl.h diff --git a/arch/openrisc/include/asm/gpio.h b/arch/openrisc/include/asm/gpio.h deleted file mode 100644 index 0b0d174..0000000 --- a/arch/openrisc/include/asm/gpio.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * OpenRISC Linux - * - * Linux architectural port borrowing liberally from similar works of - * others. All original copyrights apply as per the original source - * declaration. - * - * OpenRISC implementation: - * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> - * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> - * et al. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef __ASM_OPENRISC_GPIO_H -#define __ASM_OPENRISC_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * OpenRISC (or1k) does not have on-chip GPIO's so there is not really - * any standardized implementation that makes sense here. If passing - * through gpiolib becomes a bottleneck then it may make sense, on a - * case-by-case basis, to implement these inlined/rapid versions. - * - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -/* - * Not implemented, yet. - */ -static inline int gpio_to_irq(unsigned int gpio) -{ - return -ENOSYS; -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* __ASM_OPENRISC_GPIO_H */ diff --git a/arch/powerpc/include/asm/Kbuild b/arch/powerpc/include/asm/Kbuild index d51df17..9cf0632 100644 --- a/arch/powerpc/include/asm/Kbuild +++ b/arch/powerpc/include/asm/Kbuild @@ -1,5 +1,7 @@ include include/asm-generic/Kbuild.asm +generic-y += gpio.h + header-y += auxvec.h header-y += bootx.h header-y += byteorder.h diff --git a/arch/powerpc/include/asm/gpio.h b/arch/powerpc/include/asm/gpio.h deleted file mode 100644 index 38762ed..0000000 --- a/arch/powerpc/include/asm/gpio.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Generic GPIO API implementation for PowerPC. - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef __ASM_POWERPC_GPIO_H -#define __ASM_POWERPC_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * We don't (yet) implement inlined/rapid versions for on-chip gpios. - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* __ASM_POWERPC_GPIO_H */ diff --git a/arch/sh/include/asm/gpio.h b/arch/sh/include/asm/gpio.h index 04f53d3..44fee05 100644 --- a/arch/sh/include/asm/gpio.h +++ b/arch/sh/include/asm/gpio.h @@ -12,9 +12,6 @@ #ifndef __ASM_SH_GPIO_H #define __ASM_SH_GPIO_H -#include <linux/kernel.h> -#include <linux/errno.h> - #if defined(CONFIG_CPU_SH3) #include <cpu/gpio.h> #endif @@ -22,33 +19,6 @@ #define ARCH_NR_GPIOS 512 #include <linux/sh_pfc.h> -#ifdef CONFIG_GPIOLIB - -static inline int gpio_get_value(unsigned gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -ENOSYS; -} - -#endif /* CONFIG_GPIOLIB */ +#include <asm-generic/gpio.h> #endif /* __ASM_SH_GPIO_H */ diff --git a/arch/sparc/include/asm/Kbuild b/arch/sparc/include/asm/Kbuild index 2c2e388..6d27595 100644 --- a/arch/sparc/include/asm/Kbuild +++ b/arch/sparc/include/asm/Kbuild @@ -18,6 +18,7 @@ header-y += utrap.h header-y += watchdog.h generic-y += div64.h +generic-y += gpio.h generic-y += local64.h generic-y += irq_regs.h generic-y += local.h diff --git a/arch/sparc/include/asm/gpio.h b/arch/sparc/include/asm/gpio.h deleted file mode 100644 index a0e3ac0..0000000 --- a/arch/sparc/include/asm/gpio.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef __ASM_SPARC_GPIO_H -#define __ASM_SPARC_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return -ENOSYS; -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* __ASM_SPARC_GPIO_H */ diff --git a/arch/unicore32/include/asm/gpio.h b/arch/unicore32/include/asm/gpio.h index 2716f14..437f4e8 100644 --- a/arch/unicore32/include/asm/gpio.h +++ b/arch/unicore32/include/asm/gpio.h @@ -13,6 +13,12 @@ #ifndef __UNICORE_GPIO_H__ #define __UNICORE_GPIO_H__ +/* We implement a few ourself */ +#define gpio_get_value gpio_get_value +#define gpio_set_value gpio_set_value +#define gpio_to_irq gpio_to_irq +#define irq_to_gpio irq_to_gpio + #include <linux/io.h> #include <asm/irq.h> #include <mach/hardware.h> @@ -83,8 +89,6 @@ static inline void gpio_set_value(unsigned gpio, int value) __gpio_set_value(gpio, value); } -#define gpio_cansleep __gpio_cansleep - static inline unsigned gpio_to_irq(unsigned gpio) { if ((gpio < IRQ_GPIOHIGH) && (FIELD(1, 1, gpio) & readl(GPIO_GPIR))) diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild index 6fa90a8..99d44ce 100644 --- a/arch/x86/include/asm/Kbuild +++ b/arch/x86/include/asm/Kbuild @@ -1,5 +1,7 @@ include include/asm-generic/Kbuild.asm +generic-y += gpio.h + header-y += boot.h header-y += bootparam.h header-y += debugreg.h diff --git a/arch/x86/include/asm/gpio.h b/arch/x86/include/asm/gpio.h deleted file mode 100644 index 91d915a..0000000 --- a/arch/x86/include/asm/gpio.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Generic GPIO API implementation for x86. - * - * Derived from the generic GPIO API for powerpc: - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_X86_GPIO_H -#define _ASM_X86_GPIO_H - -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_X86_GPIO_H */ diff --git a/arch/xtensa/include/asm/Kbuild b/arch/xtensa/include/asm/Kbuild index c68e168..7d52c50 100644 --- a/arch/xtensa/include/asm/Kbuild +++ b/arch/xtensa/include/asm/Kbuild @@ -1 +1,3 @@ include include/asm-generic/Kbuild.asm + +generic-y += gpio.h diff --git a/arch/xtensa/include/asm/gpio.h b/arch/xtensa/include/asm/gpio.h deleted file mode 100644 index a8c9fc4..0000000 --- a/arch/xtensa/include/asm/gpio.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Generic GPIO API implementation for xtensa. - * - * Stolen from x86, which is derived from the generic GPIO API for powerpc: - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_XTENSA_GPIO_H -#define _ASM_XTENSA_GPIO_H - -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -/* - * Not implemented, yet. - */ -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_XTENSA_GPIO_H */ diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index d494001..622851c 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h @@ -170,6 +170,29 @@ extern int __gpio_cansleep(unsigned gpio); extern int __gpio_to_irq(unsigned gpio); +#ifndef gpio_get_value +#define gpio_get_value(gpio) __gpio_get_value(gpio) +#endif + +#ifndef gpio_set_value +#define gpio_set_value(gpio, value) __gpio_set_value(gpio, value) +#endif + +#ifndef gpio_cansleep +#define gpio_cansleep(gpio) __gpio_cansleep(gpio) +#endif + +#ifndef gpio_to_irq +#define gpio_to_irq(gpio) __gpio_to_irq(gpio) +#endif + +#ifndef irq_to_gpio +static inline int irq_to_gpio(unsigned int irq) +{ + return -EINVAL; +} +#endif + /** * struct gpio - a structure describing a GPIO with configuration * @gpio: the GPIO number -- 1.7.6.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v2] asm-generic/gpio.h: merge basic gpiolib wrappers 2011-10-27 13:01 ` [PATCH] asm-generic/gpio.h: merge basic gpiolib wrappers Mike Frysinger @ 2011-10-27 22:52 ` Mike Frysinger 2011-11-03 3:45 ` [PATCH v3] " Mike Frysinger 1 sibling, 0 replies; 14+ messages in thread From: Mike Frysinger @ 2011-10-27 22:52 UTC (permalink / raw) To: Grant Likely, Richard Henderson, Ivan Kokshaysky, Matt Turner, Haavard Skinnemoen <hskin> Cc: linux-alpha, linux-arch, linux-ia64, microblaze-uclinux, linux-mips, linux-sh, linux, linuxppc-dev, sparclinux, x86, linux-arm-kernel, uclinux-dist-devel, linux-kernel, Mike Frysinger, linux-m68k Rather than requiring architectures that use gpiolib but don't have any need to define anything custom to copy an asm/gpio.h, merge this code into the asm-generic/gpio.h. We add ifdef checks so that arches can still override things while using the asm-generic/gpio.h, but on a more fine grained per-func approach. I've compile tested these guys (with & without GPIOLIB), but don't have the hardware to boot: - alpha defconfig - arm: every defconfig - blackfin defconfig - ia64 defconfig - m68k: multi & m5208evb defconfig - mips: ar7 & ath79 & bcm47xx & bcm63xx & ip22 defconfig - powerpc: mpc85xx & ppc64 defconfig - sh: kfr2r09 defconfig - sparc defconfig - x86_64 defconfig There is concern for adding code to the arm gpio headers, but since my diffstat removes more than it adds, and it only adds when there are funcs which need to be customized in the first place, I think this holds to the desire to ultimately kill off (when possible) the misc sub gpio headers. After all, if you can kill the overridden function, my additional lines shouldn't be needed either. I don't have any toolchains for avr32, microblaze, openrisc, unicore32, or xtensa. So they lose :x. Signed-off-by: Mike Frysinger <vapier@gentoo.org> --- v2 - grub through arm gpio.h headers - add m68k support note: i've done a full build of all arm defconfigs, and any warnings or build failures appear to be unrelated to my change (sadly, there seem to be way more than there should be ...). i'll start a 2nd build which compares the binary output to make sure they're the same, but if people see something that needs more attention before that, feel free to highlight it. arch/alpha/include/asm/Kbuild | 2 + arch/alpha/include/asm/gpio.h | 55 ------------------- arch/arm/include/asm/gpio.h | 16 ------ arch/arm/include/asm/hardware/iop3xx-gpio.h | 21 ++------ arch/arm/mach-davinci/include/mach/gpio.h | 11 ++-- arch/arm/mach-ixp4xx/include/mach/gpio.h | 8 +-- arch/arm/mach-ks8695/include/mach/gpio.h | 1 + arch/arm/mach-mmp/include/mach/gpio.h | 2 - arch/arm/mach-pxa/include/mach/gpio.h | 2 +- arch/arm/mach-sa1100/include/mach/gpio.h | 13 ++--- arch/arm/mach-shmobile/include/mach/gpio.h | 16 ------ arch/arm/mach-w90x900/include/mach/gpio.h | 1 + arch/arm/plat-mxc/include/mach/irqs.h | 2 - arch/arm/plat-omap/include/plat/gpio.h | 4 +- arch/arm/plat-pxa/include/plat/gpio.h | 6 +-- arch/avr32/mach-at32ap/include/mach/gpio.h | 19 +------ arch/blackfin/include/asm/gpio.h | 16 ++---- arch/ia64/include/asm/Kbuild | 2 + arch/ia64/include/asm/gpio.h | 55 ------------------- arch/m68k/include/asm/gpio.h | 7 +++ arch/microblaze/include/asm/Kbuild | 2 + arch/microblaze/include/asm/gpio.h | 53 ------------------ arch/mips/include/asm/mach-ar7/gpio.h | 5 -- arch/mips/include/asm/mach-ath79/gpio.h | 8 ++- arch/mips/include/asm/mach-bcm47xx/gpio.h | 3 + arch/mips/include/asm/mach-bcm63xx/gpio.h | 5 -- arch/mips/include/asm/mach-generic/gpio.h | 8 +-- arch/mips/include/asm/mach-loongson/gpio.h | 7 +-- arch/mips/include/asm/mach-rc32434/gpio.h | 10 +--- arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h | 12 +--- arch/openrisc/include/asm/Kbuild | 1 + arch/openrisc/include/asm/gpio.h | 65 ----------------------- arch/powerpc/include/asm/Kbuild | 2 + arch/powerpc/include/asm/gpio.h | 53 ------------------ arch/sh/include/asm/gpio.h | 32 +----------- arch/sparc/include/asm/Kbuild | 1 + arch/sparc/include/asm/gpio.h | 36 ------------- arch/unicore32/include/asm/gpio.h | 8 ++- arch/x86/include/asm/Kbuild | 2 + arch/x86/include/asm/gpio.h | 53 ------------------ arch/xtensa/include/asm/Kbuild | 2 + arch/xtensa/include/asm/gpio.h | 56 ------------------- include/asm-generic/gpio.h | 23 ++++++++ 43 files changed, 105 insertions(+), 601 deletions(-) delete mode 100644 arch/alpha/include/asm/gpio.h delete mode 100644 arch/ia64/include/asm/gpio.h delete mode 100644 arch/microblaze/include/asm/gpio.h delete mode 100644 arch/openrisc/include/asm/gpio.h delete mode 100644 arch/powerpc/include/asm/gpio.h delete mode 100644 arch/sparc/include/asm/gpio.h delete mode 100644 arch/x86/include/asm/gpio.h delete mode 100644 arch/xtensa/include/asm/gpio.h diff --git a/arch/alpha/include/asm/Kbuild b/arch/alpha/include/asm/Kbuild index e423def..0bcff1a 100644 --- a/arch/alpha/include/asm/Kbuild +++ b/arch/alpha/include/asm/Kbuild @@ -1,5 +1,7 @@ include include/asm-generic/Kbuild.asm +generic-y += gpio.h + header-y += compiler.h header-y += console.h header-y += fpu.h diff --git a/arch/alpha/include/asm/gpio.h b/arch/alpha/include/asm/gpio.h deleted file mode 100644 index 7dc6a63..0000000 --- a/arch/alpha/include/asm/gpio.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Generic GPIO API implementation for Alpha. - * - * A stright copy of that for PowerPC which was: - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_ALPHA_GPIO_H -#define _ASM_ALPHA_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * We don't (yet) implement inlined/rapid versions for on-chip gpios. - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_ALPHA_GPIO_H */ diff --git a/arch/arm/include/asm/gpio.h b/arch/arm/include/asm/gpio.h index 11ad0bf..9818329 100644 --- a/arch/arm/include/asm/gpio.h +++ b/arch/arm/include/asm/gpio.h @@ -4,23 +4,7 @@ /* not all ARM platforms necessarily support this API ... */ #include <mach/gpio.h> -#ifndef __ARM_GPIOLIB_COMPLEX /* Note: this may rely upon the value of ARCH_NR_GPIOS set in mach/gpio.h */ #include <asm-generic/gpio.h> -/* The trivial gpiolib dispatchers */ -#define gpio_get_value __gpio_get_value -#define gpio_set_value __gpio_set_value -#define gpio_cansleep __gpio_cansleep -#endif - -/* - * Provide a default gpio_to_irq() which should satisfy every case. - * However, some platforms want to do this differently, so allow them - * to override it. - */ -#ifndef gpio_to_irq -#define gpio_to_irq __gpio_to_irq -#endif - #endif /* _ARCH_ARM_GPIO_H */ diff --git a/arch/arm/include/asm/hardware/iop3xx-gpio.h b/arch/arm/include/asm/hardware/iop3xx-gpio.h index 9eda7dc..4033b81 100644 --- a/arch/arm/include/asm/hardware/iop3xx-gpio.h +++ b/arch/arm/include/asm/hardware/iop3xx-gpio.h @@ -25,11 +25,14 @@ #ifndef __ASM_ARM_HARDWARE_IOP3XX_GPIO_H #define __ASM_ARM_HARDWARE_IOP3XX_GPIO_H +/* We implement a few ourself */ +#define gpio_get_value gpio_get_value +#define gpio_set_value gpio_set_value +#define gpio_cansleep gpio_cansleep + #include <mach/hardware.h> #include <asm-generic/gpio.h> -#define __ARM_GPIOLIB_COMPLEX - #define IOP3XX_N_GPIOS 8 static inline int gpio_get_value(unsigned gpio) @@ -57,19 +60,5 @@ static inline int gpio_cansleep(unsigned gpio) return __gpio_cansleep(gpio); } -/* - * The GPIOs are not generating any interrupt - * Note : manuals are not clear about this - */ -static inline int gpio_to_irq(int gpio) -{ - return -EINVAL; -} - -static inline int irq_to_gpio(int gpio) -{ - return -EINVAL; -} - #endif diff --git a/arch/arm/mach-davinci/include/mach/gpio.h b/arch/arm/mach-davinci/include/mach/gpio.h index fbaae47..1604005 100644 --- a/arch/arm/mach-davinci/include/mach/gpio.h +++ b/arch/arm/mach-davinci/include/mach/gpio.h @@ -13,6 +13,11 @@ #ifndef __DAVINCI_GPIO_H #define __DAVINCI_GPIO_H +/* We implement a few ourself */ +#define gpio_set_value gpio_set_value +#define gpio_get_value gpio_get_value +#define gpio_cansleep gpio_cansleep + #include <asm-generic/gpio.h> /* The inline versions use the static inlines in the driver header */ @@ -77,10 +82,4 @@ static inline int gpio_cansleep(unsigned gpio) return __gpio_cansleep(gpio); } -static inline int irq_to_gpio(unsigned irq) -{ - /* don't support the reverse mapping */ - return -ENOSYS; -} - #endif /* __DAVINCI_GPIO_H */ diff --git a/arch/arm/mach-ixp4xx/include/mach/gpio.h b/arch/arm/mach-ixp4xx/include/mach/gpio.h index 83d6b4e..7835e31 100644 --- a/arch/arm/mach-ixp4xx/include/mach/gpio.h +++ b/arch/arm/mach-ixp4xx/include/mach/gpio.h @@ -28,8 +28,6 @@ #include <linux/kernel.h> #include <mach/hardware.h> -#define __ARM_GPIOLIB_COMPLEX - static inline int gpio_request(unsigned gpio, const char *label) { return 0; @@ -63,17 +61,17 @@ static inline int gpio_get_value(unsigned gpio) return value; } +#define gpio_get_value gpio_get_value static inline void gpio_set_value(unsigned gpio, int value) { gpio_line_set(gpio, value); } - -#include <asm-generic/gpio.h> /* cansleep wrappers */ +#define gpio_set_value gpio_set_value extern int gpio_to_irq(int gpio); #define gpio_to_irq gpio_to_irq extern int irq_to_gpio(unsigned int irq); +#define irq_to_gpio irq_to_gpio #endif - diff --git a/arch/arm/mach-ks8695/include/mach/gpio.h b/arch/arm/mach-ks8695/include/mach/gpio.h index f5fda36..d81c6f8 100644 --- a/arch/arm/mach-ks8695/include/mach/gpio.h +++ b/arch/arm/mach-ks8695/include/mach/gpio.h @@ -15,5 +15,6 @@ * Map IRQ number to GPIO line. */ extern int irq_to_gpio(unsigned int irq); +#define irq_to_gpio irq_to_gpio #endif diff --git a/arch/arm/mach-mmp/include/mach/gpio.h b/arch/arm/mach-mmp/include/mach/gpio.h index 6812623..871b4c8 100644 --- a/arch/arm/mach-mmp/include/mach/gpio.h +++ b/arch/arm/mach-mmp/include/mach/gpio.h @@ -1,8 +1,6 @@ #ifndef __ASM_MACH_GPIO_H #define __ASM_MACH_GPIO_H -#include <asm-generic/gpio.h> - #define gpio_to_irq(gpio) (IRQ_GPIO_START + (gpio)) #define irq_to_gpio(irq) ((irq) - IRQ_GPIO_START) diff --git a/arch/arm/mach-pxa/include/mach/gpio.h b/arch/arm/mach-pxa/include/mach/gpio.h index 004cade..a28277c 100644 --- a/arch/arm/mach-pxa/include/mach/gpio.h +++ b/arch/arm/mach-pxa/include/mach/gpio.h @@ -24,7 +24,6 @@ #ifndef __ASM_ARCH_PXA_GPIO_H #define __ASM_ARCH_PXA_GPIO_H -#include <asm-generic/gpio.h> /* The defines for the driver are needed for the accelerated accessors */ #include "gpio-pxa.h" @@ -43,6 +42,7 @@ static inline int irq_to_gpio(unsigned int irq) return -1; } +#define irq_to_gpio irq_to_gpio #include <plat/gpio.h> #endif diff --git a/arch/arm/mach-sa1100/include/mach/gpio.h b/arch/arm/mach-sa1100/include/mach/gpio.h index 7036318..6198f7a 100644 --- a/arch/arm/mach-sa1100/include/mach/gpio.h +++ b/arch/arm/mach-sa1100/include/mach/gpio.h @@ -24,12 +24,16 @@ #ifndef __ASM_ARCH_SA1100_GPIO_H #define __ASM_ARCH_SA1100_GPIO_H +/* We implement a few ourself */ +#define gpio_get_value gpio_get_value +#define gpio_set_value gpio_set_value +#define gpio_to_irq(gpio) ((gpio < 11) ? (IRQ_GPIO0 + gpio) : \ + (IRQ_GPIO11 - 11 + gpio)) + #include <mach/hardware.h> #include <asm/irq.h> #include <asm-generic/gpio.h> -#define __ARM_GPIOLIB_COMPLEX - static inline int gpio_get_value(unsigned gpio) { if (__builtin_constant_p(gpio) && (gpio <= GPIO_MAX)) @@ -49,9 +53,4 @@ static inline void gpio_set_value(unsigned gpio, int value) __gpio_set_value(gpio, value); } -#define gpio_cansleep __gpio_cansleep - -#define gpio_to_irq(gpio) ((gpio < 11) ? (IRQ_GPIO0 + gpio) : \ - (IRQ_GPIO11 - 11 + gpio)) - #endif diff --git a/arch/arm/mach-shmobile/include/mach/gpio.h b/arch/arm/mach-shmobile/include/mach/gpio.h index 7bf0890..f8a5637 100644 --- a/arch/arm/mach-shmobile/include/mach/gpio.h +++ b/arch/arm/mach-shmobile/include/mach/gpio.h @@ -10,23 +10,7 @@ #ifndef __ASM_ARCH_GPIO_H #define __ASM_ARCH_GPIO_H -#include <linux/kernel.h> -#include <linux/errno.h> - #define ARCH_NR_GPIOS 1024 #include <linux/sh_pfc.h> -#ifdef CONFIG_GPIOLIB - -static inline int irq_to_gpio(unsigned int irq) -{ - return -ENOSYS; -} - -#else - -#define __ARM_GPIOLIB_COMPLEX - -#endif /* CONFIG_GPIOLIB */ - #endif /* __ASM_ARCH_GPIO_H */ diff --git a/arch/arm/mach-w90x900/include/mach/gpio.h b/arch/arm/mach-w90x900/include/mach/gpio.h index 5385a42..c905219 100644 --- a/arch/arm/mach-w90x900/include/mach/gpio.h +++ b/arch/arm/mach-w90x900/include/mach/gpio.h @@ -26,5 +26,6 @@ static inline int irq_to_gpio(unsigned irq) { return irq; } +#define irq_to_gpio irq_to_gpio #endif diff --git a/arch/arm/plat-mxc/include/mach/irqs.h b/arch/arm/plat-mxc/include/mach/irqs.h index 00e812b..4589307 100644 --- a/arch/arm/plat-mxc/include/mach/irqs.h +++ b/arch/arm/plat-mxc/include/mach/irqs.h @@ -11,8 +11,6 @@ #ifndef __ASM_ARCH_MXC_IRQS_H__ #define __ASM_ARCH_MXC_IRQS_H__ -#include <asm-generic/gpio.h> - /* * SoCs with TZIC interrupt controller have 128 IRQs, those with AVIC have 64 */ diff --git a/arch/arm/plat-omap/include/plat/gpio.h b/arch/arm/plat-omap/include/plat/gpio.h index 9e86ee0..1fd4986 100644 --- a/arch/arm/plat-omap/include/plat/gpio.h +++ b/arch/arm/plat-omap/include/plat/gpio.h @@ -219,9 +219,6 @@ extern void omap_gpio_restore_context(void); * The original OMAP-specific calls should eventually be removed. */ -#include <linux/errno.h> -#include <asm-generic/gpio.h> - static inline int irq_to_gpio(unsigned irq) { int tmp; @@ -238,5 +235,6 @@ static inline int irq_to_gpio(unsigned irq) /* we don't supply reverse mappings for non-SOC gpios */ return -EIO; } +#define irq_to_gpio irq_to_gpio #endif diff --git a/arch/arm/plat-pxa/include/plat/gpio.h b/arch/arm/plat-pxa/include/plat/gpio.h index 258f772..4ee329c 100644 --- a/arch/arm/plat-pxa/include/plat/gpio.h +++ b/arch/arm/plat-pxa/include/plat/gpio.h @@ -1,8 +1,6 @@ #ifndef __PLAT_GPIO_H #define __PLAT_GPIO_H -#define __ARM_GPIOLIB_COMPLEX - /* The individual machine provides register offsets and NR_BUILTIN_GPIO */ #include <mach/gpio-pxa.h> @@ -13,6 +11,7 @@ static inline int gpio_get_value(unsigned gpio) else return __gpio_get_value(gpio); } +#define gpio_get_value gpio_get_value static inline void gpio_set_value(unsigned gpio, int value) { @@ -24,7 +23,6 @@ static inline void gpio_set_value(unsigned gpio, int value) } else __gpio_set_value(gpio, value); } - -#define gpio_cansleep __gpio_cansleep +#define gpio_set_value gpio_set_value #endif /* __PLAT_GPIO_H */ diff --git a/arch/avr32/mach-at32ap/include/mach/gpio.h b/arch/avr32/mach-at32ap/include/mach/gpio.h index 0180f58..f2ff962 100644 --- a/arch/avr32/mach-at32ap/include/mach/gpio.h +++ b/arch/avr32/mach-at32ap/include/mach/gpio.h @@ -10,26 +10,13 @@ */ #define ARCH_NR_GPIOS (NR_GPIO_IRQS + 2 * 32) +/* We implement a few ourself */ +#define gpio_to_irq gpio_to_irq +#define irq_to_gpio irq_to_gpio /* Arch-neutral GPIO API, supporting both "native" and external GPIOs. */ #include <asm-generic/gpio.h> -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - - static inline int gpio_to_irq(unsigned int gpio) { if (gpio < NR_GPIO_IRQS) diff --git a/arch/blackfin/include/asm/gpio.h b/arch/blackfin/include/asm/gpio.h index 5a25856..6e25dcc 100644 --- a/arch/blackfin/include/asm/gpio.h +++ b/arch/blackfin/include/asm/gpio.h @@ -189,6 +189,12 @@ void bfin_gpio_set_value(unsigned gpio, int value); #include <asm/errno.h> #ifdef CONFIG_GPIOLIB + +/* We implement a few ourself */ +#define gpio_get_value gpio_get_value +#define gpio_set_value gpio_set_value +#define irq_to_gpio irq_to_gpio + #include <asm-generic/gpio.h> /* cansleep wrappers */ static inline int gpio_get_value(unsigned int gpio) @@ -207,16 +213,6 @@ static inline void gpio_set_value(unsigned int gpio, int value) __gpio_set_value(gpio, value); } -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned gpio) -{ - return __gpio_to_irq(gpio); -} - #else /* !CONFIG_GPIOLIB */ static inline int gpio_request(unsigned gpio, const char *label) diff --git a/arch/ia64/include/asm/Kbuild b/arch/ia64/include/asm/Kbuild index 241d1c5..d0fdd2d 100644 --- a/arch/ia64/include/asm/Kbuild +++ b/arch/ia64/include/asm/Kbuild @@ -1,5 +1,7 @@ include include/asm-generic/Kbuild.asm +generic-y += gpio.h + header-y += break.h header-y += fpu.h header-y += gcc_intrin.h diff --git a/arch/ia64/include/asm/gpio.h b/arch/ia64/include/asm/gpio.h deleted file mode 100644 index 590a20d..0000000 --- a/arch/ia64/include/asm/gpio.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Generic GPIO API implementation for IA-64. - * - * A stright copy of that for PowerPC which was: - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_IA64_GPIO_H -#define _ASM_IA64_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * We don't (yet) implement inlined/rapid versions for on-chip gpios. - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_IA64_GPIO_H */ diff --git a/arch/m68k/include/asm/gpio.h b/arch/m68k/include/asm/gpio.h index b204683..4544b6a 100644 --- a/arch/m68k/include/asm/gpio.h +++ b/arch/m68k/include/asm/gpio.h @@ -16,6 +16,13 @@ #ifndef coldfire_gpio_h #define coldfire_gpio_h +/* We implement a few ourself */ +#define gpio_get_value gpio_get_value +#define gpio_set_value gpio_set_value +#define gpio_cansleep gpio_cansleep +#define gpio_to_irq gpio_to_irq +#define irq_to_gpio irq_to_gpio + #include <linux/io.h> #include <asm-generic/gpio.h> #include <asm/coldfire.h> diff --git a/arch/microblaze/include/asm/Kbuild b/arch/microblaze/include/asm/Kbuild index db5294c..5bf1ca7 100644 --- a/arch/microblaze/include/asm/Kbuild +++ b/arch/microblaze/include/asm/Kbuild @@ -1,3 +1,5 @@ include include/asm-generic/Kbuild.asm +generic-y += gpio.h + header-y += elf.h diff --git a/arch/microblaze/include/asm/gpio.h b/arch/microblaze/include/asm/gpio.h deleted file mode 100644 index 2b2c18b..0000000 --- a/arch/microblaze/include/asm/gpio.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Generic GPIO API implementation for PowerPC. - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_MICROBLAZE_GPIO_H -#define _ASM_MICROBLAZE_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * We don't (yet) implement inlined/rapid versions for on-chip gpios. - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_MICROBLAZE_GPIO_H */ diff --git a/arch/mips/include/asm/mach-ar7/gpio.h b/arch/mips/include/asm/mach-ar7/gpio.h index c177cd1..78f40c2 100644 --- a/arch/mips/include/asm/mach-ar7/gpio.h +++ b/arch/mips/include/asm/mach-ar7/gpio.h @@ -27,11 +27,6 @@ #define gpio_to_irq(gpio) -1 -#define gpio_get_value __gpio_get_value -#define gpio_set_value __gpio_set_value - -#define gpio_cansleep __gpio_cansleep - /* Board specific GPIO functions */ int ar7_gpio_enable(unsigned gpio); int ar7_gpio_disable(unsigned gpio); diff --git a/arch/mips/include/asm/mach-ath79/gpio.h b/arch/mips/include/asm/mach-ath79/gpio.h index 60dcb62..2c570a0 100644 --- a/arch/mips/include/asm/mach-ath79/gpio.h +++ b/arch/mips/include/asm/mach-ath79/gpio.h @@ -13,6 +13,12 @@ #ifndef __ASM_MACH_ATH79_GPIO_H #define __ASM_MACH_ATH79_GPIO_H +/* We implement a few ourself */ +#define gpio_get_value gpio_get_value +#define gpio_set_value gpio_set_value +#define gpio_to_irq gpio_to_irq +#define irq_to_gpio irq_to_gpio + #define ARCH_NR_GPIOS 64 #include <asm-generic/gpio.h> @@ -21,6 +27,4 @@ int irq_to_gpio(unsigned irq); int gpio_get_value(unsigned gpio); void gpio_set_value(unsigned gpio, int value); -#define gpio_cansleep __gpio_cansleep - #endif /* __ASM_MACH_ATH79_GPIO_H */ diff --git a/arch/mips/include/asm/mach-bcm47xx/gpio.h b/arch/mips/include/asm/mach-bcm47xx/gpio.h index 76961ca..d678316 100644 --- a/arch/mips/include/asm/mach-bcm47xx/gpio.h +++ b/arch/mips/include/asm/mach-bcm47xx/gpio.h @@ -19,6 +19,7 @@ extern int gpio_request(unsigned gpio, const char *label); extern void gpio_free(unsigned gpio); extern int gpio_to_irq(unsigned gpio); +#define gpio_to_irq gpio_to_irq static inline int gpio_get_value(unsigned gpio) { @@ -35,6 +36,7 @@ static inline int gpio_get_value(unsigned gpio) } return -EINVAL; } +#define gpio_get_value gpio_get_value static inline void gpio_set_value(unsigned gpio, int value) { @@ -53,6 +55,7 @@ static inline void gpio_set_value(unsigned gpio, int value) #endif } } +#define gpio_set_value gpio_set_value static inline int gpio_direction_input(unsigned gpio) { diff --git a/arch/mips/include/asm/mach-bcm63xx/gpio.h b/arch/mips/include/asm/mach-bcm63xx/gpio.h index 1eb534d..c71bf66 100644 --- a/arch/mips/include/asm/mach-bcm63xx/gpio.h +++ b/arch/mips/include/asm/mach-bcm63xx/gpio.h @@ -5,11 +5,6 @@ #define gpio_to_irq(gpio) -1 -#define gpio_get_value __gpio_get_value -#define gpio_set_value __gpio_set_value - -#define gpio_cansleep __gpio_cansleep - #include <asm-generic/gpio.h> #endif /* __ASM_MIPS_MACH_BCM63XX_GPIO_H */ diff --git a/arch/mips/include/asm/mach-generic/gpio.h b/arch/mips/include/asm/mach-generic/gpio.h index b4e7020..e8a89c5 100644 --- a/arch/mips/include/asm/mach-generic/gpio.h +++ b/arch/mips/include/asm/mach-generic/gpio.h @@ -1,11 +1,7 @@ #ifndef __ASM_MACH_GENERIC_GPIO_H #define __ASM_MACH_GENERIC_GPIO_H -#ifdef CONFIG_GPIOLIB -#define gpio_get_value __gpio_get_value -#define gpio_set_value __gpio_set_value -#define gpio_cansleep __gpio_cansleep -#else +#ifndef CONFIG_GPIOLIB int gpio_request(unsigned gpio, const char *label); void gpio_free(unsigned gpio); int gpio_direction_input(unsigned gpio); @@ -14,7 +10,9 @@ int gpio_get_value(unsigned gpio); void gpio_set_value(unsigned gpio, int value); #endif int gpio_to_irq(unsigned gpio); +#define gpio_to_irq gpio_to_irq int irq_to_gpio(unsigned irq); +#define irq_to_gpio irq_to_gpio #include <asm-generic/gpio.h> /* cansleep wrappers */ diff --git a/arch/mips/include/asm/mach-loongson/gpio.h b/arch/mips/include/asm/mach-loongson/gpio.h index e30e73d..df6efc0 100644 --- a/arch/mips/include/asm/mach-loongson/gpio.h +++ b/arch/mips/include/asm/mach-loongson/gpio.h @@ -13,6 +13,8 @@ #ifndef __STLS2F_GPIO_H #define __STLS2F_GPIO_H +#define gpio_to_irq gpio_to_irq + #include <asm-generic/gpio.h> extern void gpio_set_value(unsigned gpio, int value); @@ -27,9 +29,4 @@ static inline int gpio_to_irq(int gpio) return -EINVAL; } -static inline int irq_to_gpio(int gpio) -{ - return -EINVAL; -} - #endif /* __STLS2F_GPIO_H */ diff --git a/arch/mips/include/asm/mach-rc32434/gpio.h b/arch/mips/include/asm/mach-rc32434/gpio.h index 12ee8d5..8b0815b 100644 --- a/arch/mips/include/asm/mach-rc32434/gpio.h +++ b/arch/mips/include/asm/mach-rc32434/gpio.h @@ -13,18 +13,14 @@ #ifndef _RC32434_GPIO_H_ #define _RC32434_GPIO_H_ +#define gpio_to_irq(gpio) (8 + 4 * 32 + gpio) +#define irq_to_gpio(irq) (irq - (8 + 4 * 32)) + #include <linux/types.h> #include <asm-generic/gpio.h> #define NR_BUILTIN_GPIO 32 -#define gpio_get_value __gpio_get_value -#define gpio_set_value __gpio_set_value -#define gpio_cansleep __gpio_cansleep - -#define gpio_to_irq(gpio) (8 + 4 * 32 + gpio) -#define irq_to_gpio(irq) (irq - (8 + 4 * 32)) - struct rb532_gpio_reg { u32 gpiofunc; /* GPIO Function Register * gpiofunc[x]=0 bit = gpio diff --git a/arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h b/arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h index ebdbab9..8356a8e 100644 --- a/arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h +++ b/arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h @@ -11,16 +11,15 @@ #ifndef __PMC_MSP71XX_GPIO_H #define __PMC_MSP71XX_GPIO_H +/* We implement a few ourself */ +#define gpio_to_irq gpio_to_irq + /* Max number of gpio's is 28 on chip plus 3 banks of I2C IO Expanders */ #define ARCH_NR_GPIOS (28 + (3 * 8)) /* new generic GPIO API - see Documentation/gpio.txt */ #include <asm-generic/gpio.h> -#define gpio_get_value __gpio_get_value -#define gpio_set_value __gpio_set_value -#define gpio_cansleep __gpio_cansleep - /* Setup calls for the gpio and gpio extended */ extern void msp71xx_init_gpio(void); extern void msp71xx_init_gpio_extended(void); @@ -38,9 +37,4 @@ static inline int gpio_to_irq(unsigned gpio) return -EINVAL; } -static inline int irq_to_gpio(unsigned irq) -{ - return -EINVAL; -} - #endif /* __PMC_MSP71XX_GPIO_H */ diff --git a/arch/openrisc/include/asm/Kbuild b/arch/openrisc/include/asm/Kbuild index 11162e6..03f0823 100644 --- a/arch/openrisc/include/asm/Kbuild +++ b/arch/openrisc/include/asm/Kbuild @@ -23,6 +23,7 @@ generic-y += fb.h generic-y += fcntl.h generic-y += ftrace.h generic-y += futex.h +generic-y += gpio.h generic-y += hardirq.h generic-y += hw_irq.h generic-y += ioctl.h diff --git a/arch/openrisc/include/asm/gpio.h b/arch/openrisc/include/asm/gpio.h deleted file mode 100644 index 0b0d174..0000000 --- a/arch/openrisc/include/asm/gpio.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * OpenRISC Linux - * - * Linux architectural port borrowing liberally from similar works of - * others. All original copyrights apply as per the original source - * declaration. - * - * OpenRISC implementation: - * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> - * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> - * et al. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef __ASM_OPENRISC_GPIO_H -#define __ASM_OPENRISC_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * OpenRISC (or1k) does not have on-chip GPIO's so there is not really - * any standardized implementation that makes sense here. If passing - * through gpiolib becomes a bottleneck then it may make sense, on a - * case-by-case basis, to implement these inlined/rapid versions. - * - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -/* - * Not implemented, yet. - */ -static inline int gpio_to_irq(unsigned int gpio) -{ - return -ENOSYS; -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* __ASM_OPENRISC_GPIO_H */ diff --git a/arch/powerpc/include/asm/Kbuild b/arch/powerpc/include/asm/Kbuild index d51df17..9cf0632 100644 --- a/arch/powerpc/include/asm/Kbuild +++ b/arch/powerpc/include/asm/Kbuild @@ -1,5 +1,7 @@ include include/asm-generic/Kbuild.asm +generic-y += gpio.h + header-y += auxvec.h header-y += bootx.h header-y += byteorder.h diff --git a/arch/powerpc/include/asm/gpio.h b/arch/powerpc/include/asm/gpio.h deleted file mode 100644 index 38762ed..0000000 --- a/arch/powerpc/include/asm/gpio.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Generic GPIO API implementation for PowerPC. - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef __ASM_POWERPC_GPIO_H -#define __ASM_POWERPC_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * We don't (yet) implement inlined/rapid versions for on-chip gpios. - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* __ASM_POWERPC_GPIO_H */ diff --git a/arch/sh/include/asm/gpio.h b/arch/sh/include/asm/gpio.h index 04f53d3..44fee05 100644 --- a/arch/sh/include/asm/gpio.h +++ b/arch/sh/include/asm/gpio.h @@ -12,9 +12,6 @@ #ifndef __ASM_SH_GPIO_H #define __ASM_SH_GPIO_H -#include <linux/kernel.h> -#include <linux/errno.h> - #if defined(CONFIG_CPU_SH3) #include <cpu/gpio.h> #endif @@ -22,33 +19,6 @@ #define ARCH_NR_GPIOS 512 #include <linux/sh_pfc.h> -#ifdef CONFIG_GPIOLIB - -static inline int gpio_get_value(unsigned gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -ENOSYS; -} - -#endif /* CONFIG_GPIOLIB */ +#include <asm-generic/gpio.h> #endif /* __ASM_SH_GPIO_H */ diff --git a/arch/sparc/include/asm/Kbuild b/arch/sparc/include/asm/Kbuild index 2c2e388..6d27595 100644 --- a/arch/sparc/include/asm/Kbuild +++ b/arch/sparc/include/asm/Kbuild @@ -18,6 +18,7 @@ header-y += utrap.h header-y += watchdog.h generic-y += div64.h +generic-y += gpio.h generic-y += local64.h generic-y += irq_regs.h generic-y += local.h diff --git a/arch/sparc/include/asm/gpio.h b/arch/sparc/include/asm/gpio.h deleted file mode 100644 index a0e3ac0..0000000 --- a/arch/sparc/include/asm/gpio.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef __ASM_SPARC_GPIO_H -#define __ASM_SPARC_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return -ENOSYS; -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* __ASM_SPARC_GPIO_H */ diff --git a/arch/unicore32/include/asm/gpio.h b/arch/unicore32/include/asm/gpio.h index 2716f14..437f4e8 100644 --- a/arch/unicore32/include/asm/gpio.h +++ b/arch/unicore32/include/asm/gpio.h @@ -13,6 +13,12 @@ #ifndef __UNICORE_GPIO_H__ #define __UNICORE_GPIO_H__ +/* We implement a few ourself */ +#define gpio_get_value gpio_get_value +#define gpio_set_value gpio_set_value +#define gpio_to_irq gpio_to_irq +#define irq_to_gpio irq_to_gpio + #include <linux/io.h> #include <asm/irq.h> #include <mach/hardware.h> @@ -83,8 +89,6 @@ static inline void gpio_set_value(unsigned gpio, int value) __gpio_set_value(gpio, value); } -#define gpio_cansleep __gpio_cansleep - static inline unsigned gpio_to_irq(unsigned gpio) { if ((gpio < IRQ_GPIOHIGH) && (FIELD(1, 1, gpio) & readl(GPIO_GPIR))) diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild index 6fa90a8..99d44ce 100644 --- a/arch/x86/include/asm/Kbuild +++ b/arch/x86/include/asm/Kbuild @@ -1,5 +1,7 @@ include include/asm-generic/Kbuild.asm +generic-y += gpio.h + header-y += boot.h header-y += bootparam.h header-y += debugreg.h diff --git a/arch/x86/include/asm/gpio.h b/arch/x86/include/asm/gpio.h deleted file mode 100644 index 91d915a..0000000 --- a/arch/x86/include/asm/gpio.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Generic GPIO API implementation for x86. - * - * Derived from the generic GPIO API for powerpc: - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_X86_GPIO_H -#define _ASM_X86_GPIO_H - -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_X86_GPIO_H */ diff --git a/arch/xtensa/include/asm/Kbuild b/arch/xtensa/include/asm/Kbuild index c68e168..7d52c50 100644 --- a/arch/xtensa/include/asm/Kbuild +++ b/arch/xtensa/include/asm/Kbuild @@ -1 +1,3 @@ include include/asm-generic/Kbuild.asm + +generic-y += gpio.h diff --git a/arch/xtensa/include/asm/gpio.h b/arch/xtensa/include/asm/gpio.h deleted file mode 100644 index a8c9fc4..0000000 --- a/arch/xtensa/include/asm/gpio.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Generic GPIO API implementation for xtensa. - * - * Stolen from x86, which is derived from the generic GPIO API for powerpc: - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_XTENSA_GPIO_H -#define _ASM_XTENSA_GPIO_H - -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -/* - * Not implemented, yet. - */ -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_XTENSA_GPIO_H */ diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index d494001..622851c 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h @@ -170,6 +170,29 @@ extern int __gpio_cansleep(unsigned gpio); extern int __gpio_to_irq(unsigned gpio); +#ifndef gpio_get_value +#define gpio_get_value(gpio) __gpio_get_value(gpio) +#endif + +#ifndef gpio_set_value +#define gpio_set_value(gpio, value) __gpio_set_value(gpio, value) +#endif + +#ifndef gpio_cansleep +#define gpio_cansleep(gpio) __gpio_cansleep(gpio) +#endif + +#ifndef gpio_to_irq +#define gpio_to_irq(gpio) __gpio_to_irq(gpio) +#endif + +#ifndef irq_to_gpio +static inline int irq_to_gpio(unsigned int irq) +{ + return -EINVAL; +} +#endif + /** * struct gpio - a structure describing a GPIO with configuration * @gpio: the GPIO number -- 1.7.6.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v3] asm-generic/gpio.h: merge basic gpiolib wrappers 2011-10-27 13:01 ` [PATCH] asm-generic/gpio.h: merge basic gpiolib wrappers Mike Frysinger 2011-10-27 22:52 ` [PATCH v2] " Mike Frysinger @ 2011-11-03 3:45 ` Mike Frysinger 1 sibling, 0 replies; 14+ messages in thread From: Mike Frysinger @ 2011-11-03 3:45 UTC (permalink / raw) To: Grant Likely, Richard Henderson, Ivan Kokshaysky, Matt Turner, Haavard Skinnemoen <hskin> Cc: linux-alpha, linux-arch, linux-ia64, microblaze-uclinux, linux-mips, linux-sh, linux, linuxppc-dev, sparclinux, x86, linux-arm-kernel, uclinux-dist-devel, linux-kernel, Mike Frysinger, linux-m68k Rather than requiring architectures that use gpiolib but don't have any need to define anything custom to copy an asm/gpio.h, merge this code into the asm-generic/gpio.h. We add ifdef checks so that arches can still override things while using the asm-generic/gpio.h, but on a more fine grained per-func approach. I've compile tested these guys (with & without GPIOLIB), but don't have the hardware to boot: - alpha defconfig - arm: all defconfigs - blackfin defconfig - ia64 defconfig - m68k: multi & m5208evb defconfig - mips: ar7 & ath79 & bcm47xx & bcm63xx & ip22 defconfig - powerpc: mpc85xx & ppc64 defconfig - sh: kfr2r09 defconfig - sparc defconfig - x86_64 defconfig I don't have any toolchains for avr32, microblaze, openrisc, unicore32, or xtensa. So they lose :x. Signed-off-by: Mike Frysinger <vapier@gentoo.org> --- v3 - built on top of Linus' recent gpio fixes - fixes builds for one or two arm platforms - all the arm defconfigs have been checked on the disassembly level arch/alpha/include/asm/Kbuild | 2 + arch/alpha/include/asm/gpio.h | 55 ------------------- arch/arm/include/asm/gpio.h | 16 ------ arch/arm/include/asm/hardware/iop3xx-gpio.h | 21 ++------ arch/arm/mach-davinci/include/mach/gpio.h | 13 ++--- arch/arm/mach-ixp4xx/include/mach/gpio.h | 8 +-- arch/arm/mach-ks8695/include/mach/gpio.h | 1 + arch/arm/mach-mmp/include/mach/gpio.h | 2 - arch/arm/mach-pxa/include/mach/gpio.h | 2 +- arch/arm/mach-sa1100/include/mach/gpio.h | 13 ++--- arch/arm/mach-shmobile/include/mach/gpio.h | 16 ------ arch/arm/mach-w90x900/include/mach/gpio.h | 1 + arch/arm/plat-omap/include/plat/gpio.h | 4 +- arch/arm/plat-pxa/include/plat/gpio.h | 8 ++-- arch/avr32/mach-at32ap/include/mach/gpio.h | 19 +------ arch/blackfin/include/asm/gpio.h | 16 ++---- arch/ia64/include/asm/Kbuild | 2 + arch/ia64/include/asm/gpio.h | 55 ------------------- arch/m68k/include/asm/gpio.h | 7 +++ arch/microblaze/include/asm/Kbuild | 2 + arch/microblaze/include/asm/gpio.h | 53 ------------------ arch/mips/include/asm/mach-ar7/gpio.h | 5 -- arch/mips/include/asm/mach-ath79/gpio.h | 8 ++- arch/mips/include/asm/mach-bcm47xx/gpio.h | 3 + arch/mips/include/asm/mach-bcm63xx/gpio.h | 5 -- arch/mips/include/asm/mach-generic/gpio.h | 8 +-- arch/mips/include/asm/mach-loongson/gpio.h | 7 +-- arch/mips/include/asm/mach-rc32434/gpio.h | 10 +--- arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h | 12 +--- arch/openrisc/include/asm/Kbuild | 1 + arch/openrisc/include/asm/gpio.h | 65 ----------------------- arch/powerpc/include/asm/Kbuild | 2 + arch/powerpc/include/asm/gpio.h | 53 ------------------ arch/sh/include/asm/gpio.h | 32 +----------- arch/sparc/include/asm/Kbuild | 1 + arch/sparc/include/asm/gpio.h | 36 ------------- arch/unicore32/include/asm/gpio.h | 8 ++- arch/x86/include/asm/Kbuild | 2 + arch/x86/include/asm/gpio.h | 53 ------------------ arch/xtensa/include/asm/Kbuild | 2 + arch/xtensa/include/asm/gpio.h | 56 ------------------- include/asm-generic/gpio.h | 23 ++++++++ 42 files changed, 107 insertions(+), 601 deletions(-) delete mode 100644 arch/alpha/include/asm/gpio.h delete mode 100644 arch/ia64/include/asm/gpio.h delete mode 100644 arch/microblaze/include/asm/gpio.h delete mode 100644 arch/openrisc/include/asm/gpio.h delete mode 100644 arch/powerpc/include/asm/gpio.h delete mode 100644 arch/sparc/include/asm/gpio.h delete mode 100644 arch/x86/include/asm/gpio.h delete mode 100644 arch/xtensa/include/asm/gpio.h diff --git a/arch/alpha/include/asm/Kbuild b/arch/alpha/include/asm/Kbuild index e423def..0bcff1a 100644 --- a/arch/alpha/include/asm/Kbuild +++ b/arch/alpha/include/asm/Kbuild @@ -1,5 +1,7 @@ include include/asm-generic/Kbuild.asm +generic-y += gpio.h + header-y += compiler.h header-y += console.h header-y += fpu.h diff --git a/arch/alpha/include/asm/gpio.h b/arch/alpha/include/asm/gpio.h deleted file mode 100644 index 7dc6a63..0000000 --- a/arch/alpha/include/asm/gpio.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Generic GPIO API implementation for Alpha. - * - * A stright copy of that for PowerPC which was: - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_ALPHA_GPIO_H -#define _ASM_ALPHA_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * We don't (yet) implement inlined/rapid versions for on-chip gpios. - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_ALPHA_GPIO_H */ diff --git a/arch/arm/include/asm/gpio.h b/arch/arm/include/asm/gpio.h index 11ad0bf..9818329 100644 --- a/arch/arm/include/asm/gpio.h +++ b/arch/arm/include/asm/gpio.h @@ -4,23 +4,7 @@ /* not all ARM platforms necessarily support this API ... */ #include <mach/gpio.h> -#ifndef __ARM_GPIOLIB_COMPLEX /* Note: this may rely upon the value of ARCH_NR_GPIOS set in mach/gpio.h */ #include <asm-generic/gpio.h> -/* The trivial gpiolib dispatchers */ -#define gpio_get_value __gpio_get_value -#define gpio_set_value __gpio_set_value -#define gpio_cansleep __gpio_cansleep -#endif - -/* - * Provide a default gpio_to_irq() which should satisfy every case. - * However, some platforms want to do this differently, so allow them - * to override it. - */ -#ifndef gpio_to_irq -#define gpio_to_irq __gpio_to_irq -#endif - #endif /* _ARCH_ARM_GPIO_H */ diff --git a/arch/arm/include/asm/hardware/iop3xx-gpio.h b/arch/arm/include/asm/hardware/iop3xx-gpio.h index 9eda7dc..4033b81 100644 --- a/arch/arm/include/asm/hardware/iop3xx-gpio.h +++ b/arch/arm/include/asm/hardware/iop3xx-gpio.h @@ -25,11 +25,14 @@ #ifndef __ASM_ARM_HARDWARE_IOP3XX_GPIO_H #define __ASM_ARM_HARDWARE_IOP3XX_GPIO_H +/* We implement a few ourself */ +#define gpio_get_value gpio_get_value +#define gpio_set_value gpio_set_value +#define gpio_cansleep gpio_cansleep + #include <mach/hardware.h> #include <asm-generic/gpio.h> -#define __ARM_GPIOLIB_COMPLEX - #define IOP3XX_N_GPIOS 8 static inline int gpio_get_value(unsigned gpio) @@ -57,19 +60,5 @@ static inline int gpio_cansleep(unsigned gpio) return __gpio_cansleep(gpio); } -/* - * The GPIOs are not generating any interrupt - * Note : manuals are not clear about this - */ -static inline int gpio_to_irq(int gpio) -{ - return -EINVAL; -} - -static inline int irq_to_gpio(int gpio) -{ - return -EINVAL; -} - #endif diff --git a/arch/arm/mach-davinci/include/mach/gpio.h b/arch/arm/mach-davinci/include/mach/gpio.h index 960e9de..1604005 100644 --- a/arch/arm/mach-davinci/include/mach/gpio.h +++ b/arch/arm/mach-davinci/include/mach/gpio.h @@ -13,9 +13,12 @@ #ifndef __DAVINCI_GPIO_H #define __DAVINCI_GPIO_H -#include <asm-generic/gpio.h> +/* We implement a few ourself */ +#define gpio_set_value gpio_set_value +#define gpio_get_value gpio_get_value +#define gpio_cansleep gpio_cansleep -#define __ARM_GPIOLIB_COMPLEX +#include <asm-generic/gpio.h> /* The inline versions use the static inlines in the driver header */ #include "gpio-davinci.h" @@ -79,10 +82,4 @@ static inline int gpio_cansleep(unsigned gpio) return __gpio_cansleep(gpio); } -static inline int irq_to_gpio(unsigned irq) -{ - /* don't support the reverse mapping */ - return -ENOSYS; -} - #endif /* __DAVINCI_GPIO_H */ diff --git a/arch/arm/mach-ixp4xx/include/mach/gpio.h b/arch/arm/mach-ixp4xx/include/mach/gpio.h index 83d6b4e..7835e31 100644 --- a/arch/arm/mach-ixp4xx/include/mach/gpio.h +++ b/arch/arm/mach-ixp4xx/include/mach/gpio.h @@ -28,8 +28,6 @@ #include <linux/kernel.h> #include <mach/hardware.h> -#define __ARM_GPIOLIB_COMPLEX - static inline int gpio_request(unsigned gpio, const char *label) { return 0; @@ -63,17 +61,17 @@ static inline int gpio_get_value(unsigned gpio) return value; } +#define gpio_get_value gpio_get_value static inline void gpio_set_value(unsigned gpio, int value) { gpio_line_set(gpio, value); } - -#include <asm-generic/gpio.h> /* cansleep wrappers */ +#define gpio_set_value gpio_set_value extern int gpio_to_irq(int gpio); #define gpio_to_irq gpio_to_irq extern int irq_to_gpio(unsigned int irq); +#define irq_to_gpio irq_to_gpio #endif - diff --git a/arch/arm/mach-ks8695/include/mach/gpio.h b/arch/arm/mach-ks8695/include/mach/gpio.h index f5fda36..d81c6f8 100644 --- a/arch/arm/mach-ks8695/include/mach/gpio.h +++ b/arch/arm/mach-ks8695/include/mach/gpio.h @@ -15,5 +15,6 @@ * Map IRQ number to GPIO line. */ extern int irq_to_gpio(unsigned int irq); +#define irq_to_gpio irq_to_gpio #endif diff --git a/arch/arm/mach-mmp/include/mach/gpio.h b/arch/arm/mach-mmp/include/mach/gpio.h index 6812623..871b4c8 100644 --- a/arch/arm/mach-mmp/include/mach/gpio.h +++ b/arch/arm/mach-mmp/include/mach/gpio.h @@ -1,8 +1,6 @@ #ifndef __ASM_MACH_GPIO_H #define __ASM_MACH_GPIO_H -#include <asm-generic/gpio.h> - #define gpio_to_irq(gpio) (IRQ_GPIO_START + (gpio)) #define irq_to_gpio(irq) ((irq) - IRQ_GPIO_START) diff --git a/arch/arm/mach-pxa/include/mach/gpio.h b/arch/arm/mach-pxa/include/mach/gpio.h index 004cade..a28277c 100644 --- a/arch/arm/mach-pxa/include/mach/gpio.h +++ b/arch/arm/mach-pxa/include/mach/gpio.h @@ -24,7 +24,6 @@ #ifndef __ASM_ARCH_PXA_GPIO_H #define __ASM_ARCH_PXA_GPIO_H -#include <asm-generic/gpio.h> /* The defines for the driver are needed for the accelerated accessors */ #include "gpio-pxa.h" @@ -43,6 +42,7 @@ static inline int irq_to_gpio(unsigned int irq) return -1; } +#define irq_to_gpio irq_to_gpio #include <plat/gpio.h> #endif diff --git a/arch/arm/mach-sa1100/include/mach/gpio.h b/arch/arm/mach-sa1100/include/mach/gpio.h index 7036318..6198f7a 100644 --- a/arch/arm/mach-sa1100/include/mach/gpio.h +++ b/arch/arm/mach-sa1100/include/mach/gpio.h @@ -24,12 +24,16 @@ #ifndef __ASM_ARCH_SA1100_GPIO_H #define __ASM_ARCH_SA1100_GPIO_H +/* We implement a few ourself */ +#define gpio_get_value gpio_get_value +#define gpio_set_value gpio_set_value +#define gpio_to_irq(gpio) ((gpio < 11) ? (IRQ_GPIO0 + gpio) : \ + (IRQ_GPIO11 - 11 + gpio)) + #include <mach/hardware.h> #include <asm/irq.h> #include <asm-generic/gpio.h> -#define __ARM_GPIOLIB_COMPLEX - static inline int gpio_get_value(unsigned gpio) { if (__builtin_constant_p(gpio) && (gpio <= GPIO_MAX)) @@ -49,9 +53,4 @@ static inline void gpio_set_value(unsigned gpio, int value) __gpio_set_value(gpio, value); } -#define gpio_cansleep __gpio_cansleep - -#define gpio_to_irq(gpio) ((gpio < 11) ? (IRQ_GPIO0 + gpio) : \ - (IRQ_GPIO11 - 11 + gpio)) - #endif diff --git a/arch/arm/mach-shmobile/include/mach/gpio.h b/arch/arm/mach-shmobile/include/mach/gpio.h index 7bf0890..f8a5637 100644 --- a/arch/arm/mach-shmobile/include/mach/gpio.h +++ b/arch/arm/mach-shmobile/include/mach/gpio.h @@ -10,23 +10,7 @@ #ifndef __ASM_ARCH_GPIO_H #define __ASM_ARCH_GPIO_H -#include <linux/kernel.h> -#include <linux/errno.h> - #define ARCH_NR_GPIOS 1024 #include <linux/sh_pfc.h> -#ifdef CONFIG_GPIOLIB - -static inline int irq_to_gpio(unsigned int irq) -{ - return -ENOSYS; -} - -#else - -#define __ARM_GPIOLIB_COMPLEX - -#endif /* CONFIG_GPIOLIB */ - #endif /* __ASM_ARCH_GPIO_H */ diff --git a/arch/arm/mach-w90x900/include/mach/gpio.h b/arch/arm/mach-w90x900/include/mach/gpio.h index 5385a42..c905219 100644 --- a/arch/arm/mach-w90x900/include/mach/gpio.h +++ b/arch/arm/mach-w90x900/include/mach/gpio.h @@ -26,5 +26,6 @@ static inline int irq_to_gpio(unsigned irq) { return irq; } +#define irq_to_gpio irq_to_gpio #endif diff --git a/arch/arm/plat-omap/include/plat/gpio.h b/arch/arm/plat-omap/include/plat/gpio.h index 9e86ee0..1fd4986 100644 --- a/arch/arm/plat-omap/include/plat/gpio.h +++ b/arch/arm/plat-omap/include/plat/gpio.h @@ -219,9 +219,6 @@ extern void omap_gpio_restore_context(void); * The original OMAP-specific calls should eventually be removed. */ -#include <linux/errno.h> -#include <asm-generic/gpio.h> - static inline int irq_to_gpio(unsigned irq) { int tmp; @@ -238,5 +235,6 @@ static inline int irq_to_gpio(unsigned irq) /* we don't supply reverse mappings for non-SOC gpios */ return -EIO; } +#define irq_to_gpio irq_to_gpio #endif diff --git a/arch/arm/plat-pxa/include/plat/gpio.h b/arch/arm/plat-pxa/include/plat/gpio.h index 258f772..60380f7 100644 --- a/arch/arm/plat-pxa/include/plat/gpio.h +++ b/arch/arm/plat-pxa/include/plat/gpio.h @@ -1,11 +1,13 @@ #ifndef __PLAT_GPIO_H #define __PLAT_GPIO_H -#define __ARM_GPIOLIB_COMPLEX - /* The individual machine provides register offsets and NR_BUILTIN_GPIO */ #include <mach/gpio-pxa.h> +#define gpio_get_value gpio_get_value +#define gpio_set_value gpio_set_value +#include <asm-generic/gpio.h> + static inline int gpio_get_value(unsigned gpio) { if (__builtin_constant_p(gpio) && (gpio < NR_BUILTIN_GPIO)) @@ -25,6 +27,4 @@ static inline void gpio_set_value(unsigned gpio, int value) __gpio_set_value(gpio, value); } -#define gpio_cansleep __gpio_cansleep - #endif /* __PLAT_GPIO_H */ diff --git a/arch/avr32/mach-at32ap/include/mach/gpio.h b/arch/avr32/mach-at32ap/include/mach/gpio.h index 0180f58..f2ff962 100644 --- a/arch/avr32/mach-at32ap/include/mach/gpio.h +++ b/arch/avr32/mach-at32ap/include/mach/gpio.h @@ -10,26 +10,13 @@ */ #define ARCH_NR_GPIOS (NR_GPIO_IRQS + 2 * 32) +/* We implement a few ourself */ +#define gpio_to_irq gpio_to_irq +#define irq_to_gpio irq_to_gpio /* Arch-neutral GPIO API, supporting both "native" and external GPIOs. */ #include <asm-generic/gpio.h> -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - - static inline int gpio_to_irq(unsigned int gpio) { if (gpio < NR_GPIO_IRQS) diff --git a/arch/blackfin/include/asm/gpio.h b/arch/blackfin/include/asm/gpio.h index 5a25856..6e25dcc 100644 --- a/arch/blackfin/include/asm/gpio.h +++ b/arch/blackfin/include/asm/gpio.h @@ -189,6 +189,12 @@ void bfin_gpio_set_value(unsigned gpio, int value); #include <asm/errno.h> #ifdef CONFIG_GPIOLIB + +/* We implement a few ourself */ +#define gpio_get_value gpio_get_value +#define gpio_set_value gpio_set_value +#define irq_to_gpio irq_to_gpio + #include <asm-generic/gpio.h> /* cansleep wrappers */ static inline int gpio_get_value(unsigned int gpio) @@ -207,16 +213,6 @@ static inline void gpio_set_value(unsigned int gpio, int value) __gpio_set_value(gpio, value); } -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned gpio) -{ - return __gpio_to_irq(gpio); -} - #else /* !CONFIG_GPIOLIB */ static inline int gpio_request(unsigned gpio, const char *label) diff --git a/arch/ia64/include/asm/Kbuild b/arch/ia64/include/asm/Kbuild index 241d1c5..d0fdd2d 100644 --- a/arch/ia64/include/asm/Kbuild +++ b/arch/ia64/include/asm/Kbuild @@ -1,5 +1,7 @@ include include/asm-generic/Kbuild.asm +generic-y += gpio.h + header-y += break.h header-y += fpu.h header-y += gcc_intrin.h diff --git a/arch/ia64/include/asm/gpio.h b/arch/ia64/include/asm/gpio.h deleted file mode 100644 index 590a20d..0000000 --- a/arch/ia64/include/asm/gpio.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Generic GPIO API implementation for IA-64. - * - * A stright copy of that for PowerPC which was: - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_IA64_GPIO_H -#define _ASM_IA64_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * We don't (yet) implement inlined/rapid versions for on-chip gpios. - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_IA64_GPIO_H */ diff --git a/arch/m68k/include/asm/gpio.h b/arch/m68k/include/asm/gpio.h index b204683..4544b6a 100644 --- a/arch/m68k/include/asm/gpio.h +++ b/arch/m68k/include/asm/gpio.h @@ -16,6 +16,13 @@ #ifndef coldfire_gpio_h #define coldfire_gpio_h +/* We implement a few ourself */ +#define gpio_get_value gpio_get_value +#define gpio_set_value gpio_set_value +#define gpio_cansleep gpio_cansleep +#define gpio_to_irq gpio_to_irq +#define irq_to_gpio irq_to_gpio + #include <linux/io.h> #include <asm-generic/gpio.h> #include <asm/coldfire.h> diff --git a/arch/microblaze/include/asm/Kbuild b/arch/microblaze/include/asm/Kbuild index db5294c..5bf1ca7 100644 --- a/arch/microblaze/include/asm/Kbuild +++ b/arch/microblaze/include/asm/Kbuild @@ -1,3 +1,5 @@ include include/asm-generic/Kbuild.asm +generic-y += gpio.h + header-y += elf.h diff --git a/arch/microblaze/include/asm/gpio.h b/arch/microblaze/include/asm/gpio.h deleted file mode 100644 index 2b2c18b..0000000 --- a/arch/microblaze/include/asm/gpio.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Generic GPIO API implementation for PowerPC. - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_MICROBLAZE_GPIO_H -#define _ASM_MICROBLAZE_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * We don't (yet) implement inlined/rapid versions for on-chip gpios. - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_MICROBLAZE_GPIO_H */ diff --git a/arch/mips/include/asm/mach-ar7/gpio.h b/arch/mips/include/asm/mach-ar7/gpio.h index c177cd1..78f40c2 100644 --- a/arch/mips/include/asm/mach-ar7/gpio.h +++ b/arch/mips/include/asm/mach-ar7/gpio.h @@ -27,11 +27,6 @@ #define gpio_to_irq(gpio) -1 -#define gpio_get_value __gpio_get_value -#define gpio_set_value __gpio_set_value - -#define gpio_cansleep __gpio_cansleep - /* Board specific GPIO functions */ int ar7_gpio_enable(unsigned gpio); int ar7_gpio_disable(unsigned gpio); diff --git a/arch/mips/include/asm/mach-ath79/gpio.h b/arch/mips/include/asm/mach-ath79/gpio.h index 60dcb62..2c570a0 100644 --- a/arch/mips/include/asm/mach-ath79/gpio.h +++ b/arch/mips/include/asm/mach-ath79/gpio.h @@ -13,6 +13,12 @@ #ifndef __ASM_MACH_ATH79_GPIO_H #define __ASM_MACH_ATH79_GPIO_H +/* We implement a few ourself */ +#define gpio_get_value gpio_get_value +#define gpio_set_value gpio_set_value +#define gpio_to_irq gpio_to_irq +#define irq_to_gpio irq_to_gpio + #define ARCH_NR_GPIOS 64 #include <asm-generic/gpio.h> @@ -21,6 +27,4 @@ int irq_to_gpio(unsigned irq); int gpio_get_value(unsigned gpio); void gpio_set_value(unsigned gpio, int value); -#define gpio_cansleep __gpio_cansleep - #endif /* __ASM_MACH_ATH79_GPIO_H */ diff --git a/arch/mips/include/asm/mach-bcm47xx/gpio.h b/arch/mips/include/asm/mach-bcm47xx/gpio.h index 76961ca..d678316 100644 --- a/arch/mips/include/asm/mach-bcm47xx/gpio.h +++ b/arch/mips/include/asm/mach-bcm47xx/gpio.h @@ -19,6 +19,7 @@ extern int gpio_request(unsigned gpio, const char *label); extern void gpio_free(unsigned gpio); extern int gpio_to_irq(unsigned gpio); +#define gpio_to_irq gpio_to_irq static inline int gpio_get_value(unsigned gpio) { @@ -35,6 +36,7 @@ static inline int gpio_get_value(unsigned gpio) } return -EINVAL; } +#define gpio_get_value gpio_get_value static inline void gpio_set_value(unsigned gpio, int value) { @@ -53,6 +55,7 @@ static inline void gpio_set_value(unsigned gpio, int value) #endif } } +#define gpio_set_value gpio_set_value static inline int gpio_direction_input(unsigned gpio) { diff --git a/arch/mips/include/asm/mach-bcm63xx/gpio.h b/arch/mips/include/asm/mach-bcm63xx/gpio.h index 1eb534d..c71bf66 100644 --- a/arch/mips/include/asm/mach-bcm63xx/gpio.h +++ b/arch/mips/include/asm/mach-bcm63xx/gpio.h @@ -5,11 +5,6 @@ #define gpio_to_irq(gpio) -1 -#define gpio_get_value __gpio_get_value -#define gpio_set_value __gpio_set_value - -#define gpio_cansleep __gpio_cansleep - #include <asm-generic/gpio.h> #endif /* __ASM_MIPS_MACH_BCM63XX_GPIO_H */ diff --git a/arch/mips/include/asm/mach-generic/gpio.h b/arch/mips/include/asm/mach-generic/gpio.h index b4e7020..e8a89c5 100644 --- a/arch/mips/include/asm/mach-generic/gpio.h +++ b/arch/mips/include/asm/mach-generic/gpio.h @@ -1,11 +1,7 @@ #ifndef __ASM_MACH_GENERIC_GPIO_H #define __ASM_MACH_GENERIC_GPIO_H -#ifdef CONFIG_GPIOLIB -#define gpio_get_value __gpio_get_value -#define gpio_set_value __gpio_set_value -#define gpio_cansleep __gpio_cansleep -#else +#ifndef CONFIG_GPIOLIB int gpio_request(unsigned gpio, const char *label); void gpio_free(unsigned gpio); int gpio_direction_input(unsigned gpio); @@ -14,7 +10,9 @@ int gpio_get_value(unsigned gpio); void gpio_set_value(unsigned gpio, int value); #endif int gpio_to_irq(unsigned gpio); +#define gpio_to_irq gpio_to_irq int irq_to_gpio(unsigned irq); +#define irq_to_gpio irq_to_gpio #include <asm-generic/gpio.h> /* cansleep wrappers */ diff --git a/arch/mips/include/asm/mach-loongson/gpio.h b/arch/mips/include/asm/mach-loongson/gpio.h index e30e73d..df6efc0 100644 --- a/arch/mips/include/asm/mach-loongson/gpio.h +++ b/arch/mips/include/asm/mach-loongson/gpio.h @@ -13,6 +13,8 @@ #ifndef __STLS2F_GPIO_H #define __STLS2F_GPIO_H +#define gpio_to_irq gpio_to_irq + #include <asm-generic/gpio.h> extern void gpio_set_value(unsigned gpio, int value); @@ -27,9 +29,4 @@ static inline int gpio_to_irq(int gpio) return -EINVAL; } -static inline int irq_to_gpio(int gpio) -{ - return -EINVAL; -} - #endif /* __STLS2F_GPIO_H */ diff --git a/arch/mips/include/asm/mach-rc32434/gpio.h b/arch/mips/include/asm/mach-rc32434/gpio.h index 12ee8d5..8b0815b 100644 --- a/arch/mips/include/asm/mach-rc32434/gpio.h +++ b/arch/mips/include/asm/mach-rc32434/gpio.h @@ -13,18 +13,14 @@ #ifndef _RC32434_GPIO_H_ #define _RC32434_GPIO_H_ +#define gpio_to_irq(gpio) (8 + 4 * 32 + gpio) +#define irq_to_gpio(irq) (irq - (8 + 4 * 32)) + #include <linux/types.h> #include <asm-generic/gpio.h> #define NR_BUILTIN_GPIO 32 -#define gpio_get_value __gpio_get_value -#define gpio_set_value __gpio_set_value -#define gpio_cansleep __gpio_cansleep - -#define gpio_to_irq(gpio) (8 + 4 * 32 + gpio) -#define irq_to_gpio(irq) (irq - (8 + 4 * 32)) - struct rb532_gpio_reg { u32 gpiofunc; /* GPIO Function Register * gpiofunc[x]=0 bit = gpio diff --git a/arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h b/arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h index ebdbab9..8356a8e 100644 --- a/arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h +++ b/arch/mips/include/asm/pmc-sierra/msp71xx/gpio.h @@ -11,16 +11,15 @@ #ifndef __PMC_MSP71XX_GPIO_H #define __PMC_MSP71XX_GPIO_H +/* We implement a few ourself */ +#define gpio_to_irq gpio_to_irq + /* Max number of gpio's is 28 on chip plus 3 banks of I2C IO Expanders */ #define ARCH_NR_GPIOS (28 + (3 * 8)) /* new generic GPIO API - see Documentation/gpio.txt */ #include <asm-generic/gpio.h> -#define gpio_get_value __gpio_get_value -#define gpio_set_value __gpio_set_value -#define gpio_cansleep __gpio_cansleep - /* Setup calls for the gpio and gpio extended */ extern void msp71xx_init_gpio(void); extern void msp71xx_init_gpio_extended(void); @@ -38,9 +37,4 @@ static inline int gpio_to_irq(unsigned gpio) return -EINVAL; } -static inline int irq_to_gpio(unsigned irq) -{ - return -EINVAL; -} - #endif /* __PMC_MSP71XX_GPIO_H */ diff --git a/arch/openrisc/include/asm/Kbuild b/arch/openrisc/include/asm/Kbuild index 11162e6..03f0823 100644 --- a/arch/openrisc/include/asm/Kbuild +++ b/arch/openrisc/include/asm/Kbuild @@ -23,6 +23,7 @@ generic-y += fb.h generic-y += fcntl.h generic-y += ftrace.h generic-y += futex.h +generic-y += gpio.h generic-y += hardirq.h generic-y += hw_irq.h generic-y += ioctl.h diff --git a/arch/openrisc/include/asm/gpio.h b/arch/openrisc/include/asm/gpio.h deleted file mode 100644 index 0b0d174..0000000 --- a/arch/openrisc/include/asm/gpio.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * OpenRISC Linux - * - * Linux architectural port borrowing liberally from similar works of - * others. All original copyrights apply as per the original source - * declaration. - * - * OpenRISC implementation: - * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> - * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> - * et al. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef __ASM_OPENRISC_GPIO_H -#define __ASM_OPENRISC_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * OpenRISC (or1k) does not have on-chip GPIO's so there is not really - * any standardized implementation that makes sense here. If passing - * through gpiolib becomes a bottleneck then it may make sense, on a - * case-by-case basis, to implement these inlined/rapid versions. - * - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -/* - * Not implemented, yet. - */ -static inline int gpio_to_irq(unsigned int gpio) -{ - return -ENOSYS; -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* __ASM_OPENRISC_GPIO_H */ diff --git a/arch/powerpc/include/asm/Kbuild b/arch/powerpc/include/asm/Kbuild index d51df17..9cf0632 100644 --- a/arch/powerpc/include/asm/Kbuild +++ b/arch/powerpc/include/asm/Kbuild @@ -1,5 +1,7 @@ include include/asm-generic/Kbuild.asm +generic-y += gpio.h + header-y += auxvec.h header-y += bootx.h header-y += byteorder.h diff --git a/arch/powerpc/include/asm/gpio.h b/arch/powerpc/include/asm/gpio.h deleted file mode 100644 index 38762ed..0000000 --- a/arch/powerpc/include/asm/gpio.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Generic GPIO API implementation for PowerPC. - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef __ASM_POWERPC_GPIO_H -#define __ASM_POWERPC_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * We don't (yet) implement inlined/rapid versions for on-chip gpios. - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* __ASM_POWERPC_GPIO_H */ diff --git a/arch/sh/include/asm/gpio.h b/arch/sh/include/asm/gpio.h index 04f53d3..44fee05 100644 --- a/arch/sh/include/asm/gpio.h +++ b/arch/sh/include/asm/gpio.h @@ -12,9 +12,6 @@ #ifndef __ASM_SH_GPIO_H #define __ASM_SH_GPIO_H -#include <linux/kernel.h> -#include <linux/errno.h> - #if defined(CONFIG_CPU_SH3) #include <cpu/gpio.h> #endif @@ -22,33 +19,6 @@ #define ARCH_NR_GPIOS 512 #include <linux/sh_pfc.h> -#ifdef CONFIG_GPIOLIB - -static inline int gpio_get_value(unsigned gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -ENOSYS; -} - -#endif /* CONFIG_GPIOLIB */ +#include <asm-generic/gpio.h> #endif /* __ASM_SH_GPIO_H */ diff --git a/arch/sparc/include/asm/Kbuild b/arch/sparc/include/asm/Kbuild index 2c2e388..6d27595 100644 --- a/arch/sparc/include/asm/Kbuild +++ b/arch/sparc/include/asm/Kbuild @@ -18,6 +18,7 @@ header-y += utrap.h header-y += watchdog.h generic-y += div64.h +generic-y += gpio.h generic-y += local64.h generic-y += irq_regs.h generic-y += local.h diff --git a/arch/sparc/include/asm/gpio.h b/arch/sparc/include/asm/gpio.h deleted file mode 100644 index a0e3ac0..0000000 --- a/arch/sparc/include/asm/gpio.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef __ASM_SPARC_GPIO_H -#define __ASM_SPARC_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return -ENOSYS; -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* __ASM_SPARC_GPIO_H */ diff --git a/arch/unicore32/include/asm/gpio.h b/arch/unicore32/include/asm/gpio.h index 2716f14..437f4e8 100644 --- a/arch/unicore32/include/asm/gpio.h +++ b/arch/unicore32/include/asm/gpio.h @@ -13,6 +13,12 @@ #ifndef __UNICORE_GPIO_H__ #define __UNICORE_GPIO_H__ +/* We implement a few ourself */ +#define gpio_get_value gpio_get_value +#define gpio_set_value gpio_set_value +#define gpio_to_irq gpio_to_irq +#define irq_to_gpio irq_to_gpio + #include <linux/io.h> #include <asm/irq.h> #include <mach/hardware.h> @@ -83,8 +89,6 @@ static inline void gpio_set_value(unsigned gpio, int value) __gpio_set_value(gpio, value); } -#define gpio_cansleep __gpio_cansleep - static inline unsigned gpio_to_irq(unsigned gpio) { if ((gpio < IRQ_GPIOHIGH) && (FIELD(1, 1, gpio) & readl(GPIO_GPIR))) diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild index 6fa90a8..99d44ce 100644 --- a/arch/x86/include/asm/Kbuild +++ b/arch/x86/include/asm/Kbuild @@ -1,5 +1,7 @@ include include/asm-generic/Kbuild.asm +generic-y += gpio.h + header-y += boot.h header-y += bootparam.h header-y += debugreg.h diff --git a/arch/x86/include/asm/gpio.h b/arch/x86/include/asm/gpio.h deleted file mode 100644 index 91d915a..0000000 --- a/arch/x86/include/asm/gpio.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Generic GPIO API implementation for x86. - * - * Derived from the generic GPIO API for powerpc: - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_X86_GPIO_H -#define _ASM_X86_GPIO_H - -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_X86_GPIO_H */ diff --git a/arch/xtensa/include/asm/Kbuild b/arch/xtensa/include/asm/Kbuild index c68e168..7d52c50 100644 --- a/arch/xtensa/include/asm/Kbuild +++ b/arch/xtensa/include/asm/Kbuild @@ -1 +1,3 @@ include include/asm-generic/Kbuild.asm + +generic-y += gpio.h diff --git a/arch/xtensa/include/asm/gpio.h b/arch/xtensa/include/asm/gpio.h deleted file mode 100644 index a8c9fc4..0000000 --- a/arch/xtensa/include/asm/gpio.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Generic GPIO API implementation for xtensa. - * - * Stolen from x86, which is derived from the generic GPIO API for powerpc: - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_XTENSA_GPIO_H -#define _ASM_XTENSA_GPIO_H - -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -/* - * Not implemented, yet. - */ -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_XTENSA_GPIO_H */ diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index 8c86210..1990836 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h @@ -171,6 +171,29 @@ extern int __gpio_cansleep(unsigned gpio); extern int __gpio_to_irq(unsigned gpio); +#ifndef gpio_get_value +#define gpio_get_value(gpio) __gpio_get_value(gpio) +#endif + +#ifndef gpio_set_value +#define gpio_set_value(gpio, value) __gpio_set_value(gpio, value) +#endif + +#ifndef gpio_cansleep +#define gpio_cansleep(gpio) __gpio_cansleep(gpio) +#endif + +#ifndef gpio_to_irq +#define gpio_to_irq(gpio) __gpio_to_irq(gpio) +#endif + +#ifndef irq_to_gpio +static inline int irq_to_gpio(unsigned int irq) +{ + return -EINVAL; +} +#endif + 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); -- 1.7.6.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h 2011-10-25 7:33 [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h Mark Brown ` (2 preceding siblings ...) 2011-10-27 13:01 ` [PATCH] asm-generic/gpio.h: merge basic gpiolib wrappers Mike Frysinger @ 2012-02-04 15:54 ` Mark Brown 2012-02-04 17:06 ` Sam Ravnborg 3 siblings, 1 reply; 14+ messages in thread From: Mark Brown @ 2012-02-04 15:54 UTC (permalink / raw) To: Guan Xuetao, Russell King, Ralf Baechle, Paul Mundt, Geert Uytterhoeven, Mike Frysinger, Haavard Skinnemoen, Hans-Christian Egtvedt, Grant Likely Cc: linux-arch, linux-mips, uclinux-dist-devel, linux-m68k, linux-kernel, linux-sh, Mark Brown Rather than requiring architectures that use gpiolib but don't have any need to define anything custom to copy an asm/gpio.h provide a Kconfig symbol which architectures must select in order to include gpio.h and for other architectures just provide the trivial implementation directly. This makes it much easier to do gpiolib updates and is also a step towards making gpiolib APIs available on every architecture. For architectures with existing boilerplate code leave a stub header in place which warns on direct inclusion of asm/gpio.h and includes linux/gpio.h to catch code that's doing this. Direct inclusion of asm/gpio.h has long been deprecated. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> --- Build tested on x86 which is one of the affected architectures. arch/alpha/include/asm/gpio.h | 59 ++---------------------------- arch/arm/Kconfig | 1 + arch/avr32/Kconfig | 1 + arch/blackfin/Kconfig | 1 + arch/ia64/include/asm/gpio.h | 59 ++---------------------------- arch/m68k/Kconfig.cpu | 1 + arch/microblaze/include/asm/gpio.h | 57 ++--------------------------- arch/mips/Kconfig | 1 + arch/openrisc/include/asm/gpio.h | 69 ++--------------------------------- arch/powerpc/include/asm/gpio.h | 57 ++--------------------------- arch/sh/Kconfig | 1 + arch/sparc/include/asm/gpio.h | 40 ++------------------- arch/unicore32/Kconfig | 1 + arch/x86/include/asm/gpio.h | 57 ++--------------------------- arch/xtensa/include/asm/gpio.h | 60 ++----------------------------- drivers/gpio/Kconfig | 8 ++++ include/linux/gpio.h | 34 +++++++++++++++++ 17 files changed, 81 insertions(+), 426 deletions(-) diff --git a/arch/alpha/include/asm/gpio.h b/arch/alpha/include/asm/gpio.h index 7dc6a63..b3799d8 100644 --- a/arch/alpha/include/asm/gpio.h +++ b/arch/alpha/include/asm/gpio.h @@ -1,55 +1,4 @@ -/* - * Generic GPIO API implementation for Alpha. - * - * A stright copy of that for PowerPC which was: - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_ALPHA_GPIO_H -#define _ASM_ALPHA_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * We don't (yet) implement inlined/rapid versions for on-chip gpios. - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_ALPHA_GPIO_H */ +#ifndef __LINUX_GPIO_H +#warning Include linux/gpio.h instead of asm/gpio.h +#include <linux/gpio.h> +#endif diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index a48aecc..dcf4187 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1,6 +1,7 @@ config ARM bool default y + select ARCH_HAVE_CUSTOM_GPIO_H select HAVE_AOUT select HAVE_DMA_API_DEBUG select HAVE_IDE if PCI || ISA || PCMCIA diff --git a/arch/avr32/Kconfig b/arch/avr32/Kconfig index 197e96f..b2e3e58 100644 --- a/arch/avr32/Kconfig +++ b/arch/avr32/Kconfig @@ -10,6 +10,7 @@ config AVR32 select GENERIC_IRQ_PROBE select HARDIRQS_SW_RESEND select GENERIC_IRQ_SHOW + select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_HAVE_NMI_SAFE_CMPXCHG help AVR32 is a high-performance 32-bit RISC microprocessor core, diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig index abe5a9e..c45ecdc 100644 --- a/arch/blackfin/Kconfig +++ b/arch/blackfin/Kconfig @@ -31,6 +31,7 @@ config BLACKFIN select HAVE_KERNEL_LZO if RAMKERNEL select HAVE_OPROFILE select HAVE_PERF_EVENTS + select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_WANT_OPTIONAL_GPIOLIB select HAVE_GENERIC_HARDIRQS select GENERIC_ATOMIC64 diff --git a/arch/ia64/include/asm/gpio.h b/arch/ia64/include/asm/gpio.h index 590a20d..b3799d8 100644 --- a/arch/ia64/include/asm/gpio.h +++ b/arch/ia64/include/asm/gpio.h @@ -1,55 +1,4 @@ -/* - * Generic GPIO API implementation for IA-64. - * - * A stright copy of that for PowerPC which was: - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_IA64_GPIO_H -#define _ASM_IA64_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * We don't (yet) implement inlined/rapid versions for on-chip gpios. - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_IA64_GPIO_H */ +#ifndef __LINUX_GPIO_H +#warning Include linux/gpio.h instead of asm/gpio.h +#include <linux/gpio.h> +#endif diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu index 8a9c767..8941af1 100644 --- a/arch/m68k/Kconfig.cpu +++ b/arch/m68k/Kconfig.cpu @@ -24,6 +24,7 @@ config COLDFIRE bool "Coldfire CPU family support" select GENERIC_GPIO select ARCH_REQUIRE_GPIOLIB + select ARCH_HAVE_CUSTOM_GPIO_H select CPU_HAS_NO_BITFIELDS select CPU_HAS_NO_MULDIV64 select GENERIC_CSUM diff --git a/arch/microblaze/include/asm/gpio.h b/arch/microblaze/include/asm/gpio.h index 2b2c18b..b3799d8 100644 --- a/arch/microblaze/include/asm/gpio.h +++ b/arch/microblaze/include/asm/gpio.h @@ -1,53 +1,4 @@ -/* - * Generic GPIO API implementation for PowerPC. - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_MICROBLAZE_GPIO_H -#define _ASM_MICROBLAZE_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * We don't (yet) implement inlined/rapid versions for on-chip gpios. - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_MICROBLAZE_GPIO_H */ +#ifndef __LINUX_GPIO_H +#warning Include linux/gpio.h instead of asm/gpio.h +#include <linux/gpio.h> +#endif diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index c4c1312..4918404 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -8,6 +8,7 @@ config MIPS select HAVE_PERF_EVENTS select PERF_USE_VMALLOC select HAVE_ARCH_KGDB + select ARCH_HAVE_CUSTOM_GPIO_H select HAVE_FUNCTION_TRACER select HAVE_FUNCTION_TRACE_MCOUNT_TEST select HAVE_DYNAMIC_FTRACE diff --git a/arch/openrisc/include/asm/gpio.h b/arch/openrisc/include/asm/gpio.h index 0b0d174..b3799d8 100644 --- a/arch/openrisc/include/asm/gpio.h +++ b/arch/openrisc/include/asm/gpio.h @@ -1,65 +1,4 @@ -/* - * OpenRISC Linux - * - * Linux architectural port borrowing liberally from similar works of - * others. All original copyrights apply as per the original source - * declaration. - * - * OpenRISC implementation: - * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> - * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> - * et al. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef __ASM_OPENRISC_GPIO_H -#define __ASM_OPENRISC_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * OpenRISC (or1k) does not have on-chip GPIO's so there is not really - * any standardized implementation that makes sense here. If passing - * through gpiolib becomes a bottleneck then it may make sense, on a - * case-by-case basis, to implement these inlined/rapid versions. - * - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -/* - * Not implemented, yet. - */ -static inline int gpio_to_irq(unsigned int gpio) -{ - return -ENOSYS; -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* __ASM_OPENRISC_GPIO_H */ +#ifndef __LINUX_GPIO_H +#warning Include linux/gpio.h instead of asm/gpio.h +#include <linux/gpio.h> +#endif diff --git a/arch/powerpc/include/asm/gpio.h b/arch/powerpc/include/asm/gpio.h index 38762ed..b3799d8 100644 --- a/arch/powerpc/include/asm/gpio.h +++ b/arch/powerpc/include/asm/gpio.h @@ -1,53 +1,4 @@ -/* - * Generic GPIO API implementation for PowerPC. - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef __ASM_POWERPC_GPIO_H -#define __ASM_POWERPC_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * We don't (yet) implement inlined/rapid versions for on-chip gpios. - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* __ASM_POWERPC_GPIO_H */ +#ifndef __LINUX_GPIO_H +#warning Include linux/gpio.h instead of asm/gpio.h +#include <linux/gpio.h> +#endif diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 3c8db65..f15181d 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -12,6 +12,7 @@ config SUPERH select HAVE_DMA_ATTRS select HAVE_IRQ_WORK select HAVE_PERF_EVENTS + select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_HAVE_NMI_SAFE_CMPXCHG if (GUSA_RB || CPU_SH4A) select PERF_USE_VMALLOC select HAVE_KERNEL_GZIP diff --git a/arch/sparc/include/asm/gpio.h b/arch/sparc/include/asm/gpio.h index a0e3ac0..b3799d8 100644 --- a/arch/sparc/include/asm/gpio.h +++ b/arch/sparc/include/asm/gpio.h @@ -1,36 +1,4 @@ -#ifndef __ASM_SPARC_GPIO_H -#define __ASM_SPARC_GPIO_H - -#include <linux/errno.h> -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return -ENOSYS; -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* __ASM_SPARC_GPIO_H */ +#ifndef __LINUX_GPIO_H +#warning Include linux/gpio.h instead of asm/gpio.h +#include <linux/gpio.h> +#endif diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig index eeb8054..7ff6d10 100644 --- a/arch/unicore32/Kconfig +++ b/arch/unicore32/Kconfig @@ -8,6 +8,7 @@ config UNICORE32 select HAVE_KERNEL_BZIP2 select HAVE_KERNEL_LZO select HAVE_KERNEL_LZMA + select ARCH_HAVE_CUSTOM_GPIO_H select GENERIC_FIND_FIRST_BIT select GENERIC_IRQ_PROBE select GENERIC_IRQ_SHOW diff --git a/arch/x86/include/asm/gpio.h b/arch/x86/include/asm/gpio.h index 91d915a..b3799d8 100644 --- a/arch/x86/include/asm/gpio.h +++ b/arch/x86/include/asm/gpio.h @@ -1,53 +1,4 @@ -/* - * Generic GPIO API implementation for x86. - * - * Derived from the generic GPIO API for powerpc: - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_X86_GPIO_H -#define _ASM_X86_GPIO_H - -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_X86_GPIO_H */ +#ifndef __LINUX_GPIO_H +#warning Include linux/gpio.h instead of asm/gpio.h +#include <linux/gpio.h> +#endif diff --git a/arch/xtensa/include/asm/gpio.h b/arch/xtensa/include/asm/gpio.h index a8c9fc4..b3799d8 100644 --- a/arch/xtensa/include/asm/gpio.h +++ b/arch/xtensa/include/asm/gpio.h @@ -1,56 +1,4 @@ -/* - * Generic GPIO API implementation for xtensa. - * - * Stolen from x86, which is derived from the generic GPIO API for powerpc: - * - * Copyright (c) 2007-2008 MontaVista Software, Inc. - * - * Author: Anton Vorontsov <avorontsov@ru.mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef _ASM_XTENSA_GPIO_H -#define _ASM_XTENSA_GPIO_H - -#include <asm-generic/gpio.h> - -#ifdef CONFIG_GPIOLIB - -/* - * Just call gpiolib. - */ -static inline int gpio_get_value(unsigned int gpio) -{ - return __gpio_get_value(gpio); -} - -static inline void gpio_set_value(unsigned int gpio, int value) -{ - __gpio_set_value(gpio, value); -} - -static inline int gpio_cansleep(unsigned int gpio) -{ - return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned int gpio) -{ - return __gpio_to_irq(gpio); -} - -/* - * Not implemented, yet. - */ -static inline int irq_to_gpio(unsigned int irq) -{ - return -EINVAL; -} - -#endif /* CONFIG_GPIOLIB */ - -#endif /* _ASM_XTENSA_GPIO_H */ +#ifndef __LINUX_GPIO_H +#warning Include linux/gpio.h instead of asm/gpio.h +#include <linux/gpio.h> +#endif diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index d0c4118..81befc0 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -2,6 +2,14 @@ # GPIO infrastructure and drivers # +config ARCH_HAVE_CUSTOM_GPIO_H + bool + help + Selecting this config option from the architecture Kconfig allows + the architecture to provide a custom asm/gpio.h implementation + overriding the default implementations. New uses of this are + strongly discouraged. + config ARCH_WANT_OPTIONAL_GPIOLIB bool help diff --git a/include/linux/gpio.h b/include/linux/gpio.h index 38ac48b..3149f68 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h @@ -1,6 +1,8 @@ #ifndef __LINUX_GPIO_H #define __LINUX_GPIO_H +#include <linux/errno.h> + /* see Documentation/gpio.txt */ /* make these flag values available regardless of GPIO kconfig options */ @@ -27,7 +29,39 @@ struct gpio { }; #ifdef CONFIG_GENERIC_GPIO + +#ifdef CONFIG_ARCH_HAVE_CUSTOM_GPIO_H #include <asm/gpio.h> +#else + +#include <asm-generic/gpio.h> + +static inline int gpio_get_value(unsigned int gpio) +{ + return __gpio_get_value(gpio); +} + +static inline void gpio_set_value(unsigned int gpio, int value) +{ + __gpio_set_value(gpio, value); +} + +static inline int gpio_cansleep(unsigned int gpio) +{ + return __gpio_cansleep(gpio); +} + +static inline int gpio_to_irq(unsigned int gpio) +{ + return __gpio_to_irq(gpio); +} + +static inline int irq_to_gpio(unsigned int irq) +{ + return -EINVAL; +} + +#endif #else -- 1.7.9.rc1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h 2012-02-04 15:54 ` [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h Mark Brown @ 2012-02-04 17:06 ` Sam Ravnborg 2012-02-04 17:21 ` Mark Brown 2012-02-04 17:41 ` Russell King - ARM Linux 0 siblings, 2 replies; 14+ messages in thread From: Sam Ravnborg @ 2012-02-04 17:06 UTC (permalink / raw) To: Mark Brown Cc: Guan Xuetao, Russell King, Ralf Baechle, Paul Mundt, Geert Uytterhoeven, Mike Frysinger, Haavard Skinnemoen, Hans-Christian Egtvedt, Grant Likely, linux-arch, linux-mips, uclinux-dist-devel, linux-m68k, linux-kernel, linux-sh On Sat, Feb 04, 2012 at 03:54:39PM +0000, Mark Brown wrote: > Rather than requiring architectures that use gpiolib but don't have any > need to define anything custom to copy an asm/gpio.h provide a Kconfig > symbol which architectures must select in order to include gpio.h and > for other architectures just provide the trivial implementation directly. Hi Mark. There is an even simpler solution. For each arch that uses asm-generic/gpio.h add a line to arch/$ARCH/include/asm/Kbuild like this: generic-y += gpio.h This will then make this arch pick up the asm-generic version when you do #include <asm/gpio.h>. And you avoid the kconfig games. iFor the archs which require their own asm/gpio.h file - just add it to the asm/ dir - and do not add the generic-y assignment. Sam ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h 2012-02-04 17:06 ` Sam Ravnborg @ 2012-02-04 17:21 ` Mark Brown 2012-02-04 17:41 ` Russell King - ARM Linux 1 sibling, 0 replies; 14+ messages in thread From: Mark Brown @ 2012-02-04 17:21 UTC (permalink / raw) To: Sam Ravnborg Cc: Guan Xuetao, Russell King, Ralf Baechle, Paul Mundt, Geert Uytterhoeven, Mike Frysinger, Haavard Skinnemoen, Hans-Christian Egtvedt, Grant Likely, linux-arch, linux-mips, uclinux-dist-devel, linux-m68k, linux-kernel, linux-sh [-- Attachment #1: Type: text/plain, Size: 646 bytes --] On Sat, Feb 04, 2012 at 06:06:32PM +0100, Sam Ravnborg wrote: > There is an even simpler solution. > For each arch that uses asm-generic/gpio.h add a line > to arch/$ARCH/include/asm/Kbuild like this: > generic-y += gpio.h > This will then make this arch pick up the asm-generic version when > you do #include <asm/gpio.h>. > And you avoid the kconfig games. Hrm, that would work but it does mean we still need to go round and manually enable GPIO support on all architectures which is what I had been trying to get away from. It is a lot simpler though so it should be much easier to persuade the architecture maintainers to do that. [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h 2012-02-04 17:06 ` Sam Ravnborg 2012-02-04 17:21 ` Mark Brown @ 2012-02-04 17:41 ` Russell King - ARM Linux 2012-02-06 11:37 ` Mark Brown 1 sibling, 1 reply; 14+ messages in thread From: Russell King - ARM Linux @ 2012-02-04 17:41 UTC (permalink / raw) To: Sam Ravnborg Cc: Mark Brown, Guan Xuetao, Ralf Baechle, Paul Mundt, Geert Uytterhoeven, Mike Frysinger, Haavard Skinnemoen, Hans-Christian Egtvedt, Grant Likely, linux-arch, linux-mips, uclinux-dist-devel, linux-m68k, linux-kernel, linux-sh On Sat, Feb 04, 2012 at 06:06:32PM +0100, Sam Ravnborg wrote: > On Sat, Feb 04, 2012 at 03:54:39PM +0000, Mark Brown wrote: > > Rather than requiring architectures that use gpiolib but don't have any > > need to define anything custom to copy an asm/gpio.h provide a Kconfig > > symbol which architectures must select in order to include gpio.h and > > for other architectures just provide the trivial implementation directly. > > Hi Mark. > > There is an even simpler solution. > > For each arch that uses asm-generic/gpio.h add a line > to arch/$ARCH/include/asm/Kbuild like this: > > > generic-y += gpio.h > > This will then make this arch pick up the asm-generic version when > you do #include <asm/gpio.h>. You're assuming that asm-generic/gpio.h was invented to be a replacement for an architecture asm/gpio.h. Unfortunately, things aren't that simple. It would have been a lot better if asm-generic/gpio.h was tacked on the bottom of linux/gpio.h - because that's what it really is. It's core code features, not platform stuff. What's platform specific about asm/gpio.h is the number of GPIOs in the system, and whether it wants to intercept the gpio_xxx() functions to provide fast access to on-chip GPIOs. What I'd suggest is moving asm-generic/gpio.h to linux/gpiolib.h, and making asm-generic/gpio.h include that as a patch until stuff is fixed for its new location. That should result in a proper asm-generic/gpio.h being: /* The trivial gpiolib dispatchers */ #define gpio_get_value __gpio_get_value #define gpio_set_value __gpio_set_value #define gpio_cansleep __gpio_cansleep #define gpio_to_irq __gpio_to_irq and nothing else. Alternatively, instead of linux/gpiolib.h, put it in linux/gpio.h instead, but that gets more icky because of the mess of asm/gpio.h includes (which I've been banging on for years about in ARM patches and they're _still_ coming.) ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h 2012-02-04 17:41 ` Russell King - ARM Linux @ 2012-02-06 11:37 ` Mark Brown 0 siblings, 0 replies; 14+ messages in thread From: Mark Brown @ 2012-02-06 11:37 UTC (permalink / raw) To: Russell King - ARM Linux Cc: Sam Ravnborg, Guan Xuetao, Ralf Baechle, Paul Mundt, Geert Uytterhoeven, Mike Frysinger, Haavard Skinnemoen, Hans-Christian Egtvedt, Grant Likely, linux-arch, linux-mips, uclinux-dist-devel, linux-m68k, linux-kernel, linux-sh [-- Attachment #1: Type: text/plain, Size: 1096 bytes --] On Sat, Feb 04, 2012 at 05:41:15PM +0000, Russell King - ARM Linux wrote: > What's platform specific about asm/gpio.h is the number of GPIOs in > the system, and whether it wants to intercept the gpio_xxx() functions > to provide fast access to on-chip GPIOs. Plus the fact that it might be a completely non-standard API, and might totally override the gpiolib implementation. > What I'd suggest is moving asm-generic/gpio.h to linux/gpiolib.h, and > making asm-generic/gpio.h include that as a patch until stuff is fixed > for its new location. That should result in a proper asm-generic/gpio.h > being: > Alternatively, instead of linux/gpiolib.h, put it in linux/gpio.h instead, > but that gets more icky because of the mess of asm/gpio.h includes (which > I've been banging on for years about in ARM patches and they're _still_ > coming.) Yeah, though it is a bit neater if it's all in gpio.h and everyone is using gpiolib. Perhaps something like the warnings I added on inclusion of asm/gpio.h without linux/gpio.h would help, though I certainly wouldn't expect it to solve anything. [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2012-02-06 11:37 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-10-25 7:33 [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h Mark Brown 2011-10-25 8:33 ` Grant Likely 2011-10-25 8:39 ` Mark Brown 2011-10-25 23:44 ` Mike Frysinger 2011-10-26 7:33 ` Mark Brown 2012-02-03 23:16 ` Grant Likely 2011-10-27 13:01 ` [PATCH] asm-generic/gpio.h: merge basic gpiolib wrappers Mike Frysinger 2011-10-27 22:52 ` [PATCH v2] " Mike Frysinger 2011-11-03 3:45 ` [PATCH v3] " Mike Frysinger 2012-02-04 15:54 ` [PATCH] gpiolib/arches: Centralise bolierplate asm/gpio.h Mark Brown 2012-02-04 17:06 ` Sam Ravnborg 2012-02-04 17:21 ` Mark Brown 2012-02-04 17:41 ` Russell King - ARM Linux 2012-02-06 11:37 ` Mark Brown
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).