Skip to content

Commit 7563bbf

Browse files
broonieglikely
authored andcommitted
gpiolib/arches: Centralise bolierplate asm/gpio.h
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> Acked-by: Jonas Bonn <jonas@southpole.se> Acked-by: Tony Luck <tony.luck@intel.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
1 parent 25cf250 commit 7563bbf

17 files changed

Lines changed: 81 additions & 426 deletions

File tree

‎arch/alpha/include/asm/gpio.h‎

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,4 @@
1-
/*
2-
* Generic GPIO API implementation for Alpha.
3-
*
4-
* A stright copy of that for PowerPC which was:
5-
*
6-
* Copyright (c) 2007-2008 MontaVista Software, Inc.
7-
*
8-
* Author: Anton Vorontsov <avorontsov@ru.mvista.com>
9-
*
10-
* This program is free software; you can redistribute it and/or modify
11-
* it under the terms of the GNU General Public License as published by
12-
* the Free Software Foundation; either version 2 of the License, or
13-
* (at your option) any later version.
14-
*/
15-
16-
#ifndef _ASM_ALPHA_GPIO_H
17-
#define _ASM_ALPHA_GPIO_H
18-
19-
#include <linux/errno.h>
20-
#include <asm-generic/gpio.h>
21-
22-
#ifdef CONFIG_GPIOLIB
23-
24-
/*
25-
* We don't (yet) implement inlined/rapid versions for on-chip gpios.
26-
* Just call gpiolib.
27-
*/
28-
static inline int gpio_get_value(unsigned int gpio)
29-
{
30-
return __gpio_get_value(gpio);
31-
}
32-
33-
static inline void gpio_set_value(unsigned int gpio, int value)
34-
{
35-
__gpio_set_value(gpio, value);
36-
}
37-
38-
static inline int gpio_cansleep(unsigned int gpio)
39-
{
40-
return __gpio_cansleep(gpio);
41-
}
42-
43-
static inline int gpio_to_irq(unsigned int gpio)
44-
{
45-
return __gpio_to_irq(gpio);
46-
}
47-
48-
static inline int irq_to_gpio(unsigned int irq)
49-
{
50-
return -EINVAL;
51-
}
52-
53-
#endif /* CONFIG_GPIOLIB */
54-
55-
#endif /* _ASM_ALPHA_GPIO_H */
1+
#ifndef __LINUX_GPIO_H
2+
#warning Include linux/gpio.h instead of asm/gpio.h
3+
#include <linux/gpio.h>
4+
#endif

‎arch/arm/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
config ARM
22
bool
33
default y
4+
select ARCH_HAVE_CUSTOM_GPIO_H
45
select HAVE_AOUT
56
select HAVE_DMA_API_DEBUG
67
select HAVE_IDE if PCI || ISA || PCMCIA

‎arch/avr32/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ config AVR32
1111
select GENERIC_ATOMIC64
1212
select HARDIRQS_SW_RESEND
1313
select GENERIC_IRQ_SHOW
14+
select ARCH_HAVE_CUSTOM_GPIO_H
1415
select ARCH_HAVE_NMI_SAFE_CMPXCHG
1516
help
1617
AVR32 is a high-performance 32-bit RISC microprocessor core,

‎arch/blackfin/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ config BLACKFIN
3131
select HAVE_KERNEL_LZO if RAMKERNEL
3232
select HAVE_OPROFILE
3333
select HAVE_PERF_EVENTS
34+
select ARCH_HAVE_CUSTOM_GPIO_H
3435
select ARCH_WANT_OPTIONAL_GPIOLIB
3536
select HAVE_GENERIC_HARDIRQS
3637
select GENERIC_ATOMIC64

‎arch/ia64/include/asm/gpio.h‎

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,4 @@
1-
/*
2-
* Generic GPIO API implementation for IA-64.
3-
*
4-
* A stright copy of that for PowerPC which was:
5-
*
6-
* Copyright (c) 2007-2008 MontaVista Software, Inc.
7-
*
8-
* Author: Anton Vorontsov <avorontsov@ru.mvista.com>
9-
*
10-
* This program is free software; you can redistribute it and/or modify
11-
* it under the terms of the GNU General Public License as published by
12-
* the Free Software Foundation; either version 2 of the License, or
13-
* (at your option) any later version.
14-
*/
15-
16-
#ifndef _ASM_IA64_GPIO_H
17-
#define _ASM_IA64_GPIO_H
18-
19-
#include <linux/errno.h>
20-
#include <asm-generic/gpio.h>
21-
22-
#ifdef CONFIG_GPIOLIB
23-
24-
/*
25-
* We don't (yet) implement inlined/rapid versions for on-chip gpios.
26-
* Just call gpiolib.
27-
*/
28-
static inline int gpio_get_value(unsigned int gpio)
29-
{
30-
return __gpio_get_value(gpio);
31-
}
32-
33-
static inline void gpio_set_value(unsigned int gpio, int value)
34-
{
35-
__gpio_set_value(gpio, value);
36-
}
37-
38-
static inline int gpio_cansleep(unsigned int gpio)
39-
{
40-
return __gpio_cansleep(gpio);
41-
}
42-
43-
static inline int gpio_to_irq(unsigned int gpio)
44-
{
45-
return __gpio_to_irq(gpio);
46-
}
47-
48-
static inline int irq_to_gpio(unsigned int irq)
49-
{
50-
return -EINVAL;
51-
}
52-
53-
#endif /* CONFIG_GPIOLIB */
54-
55-
#endif /* _ASM_IA64_GPIO_H */
1+
#ifndef __LINUX_GPIO_H
2+
#warning Include linux/gpio.h instead of asm/gpio.h
3+
#include <linux/gpio.h>
4+
#endif

‎arch/m68k/Kconfig.cpu‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ config COLDFIRE
2424
bool "Coldfire CPU family support"
2525
select GENERIC_GPIO
2626
select ARCH_REQUIRE_GPIOLIB
27+
select ARCH_HAVE_CUSTOM_GPIO_H
2728
select CPU_HAS_NO_BITFIELDS
2829
select CPU_HAS_NO_MULDIV64
2930
select GENERIC_CSUM

‎arch/microblaze/include/asm/gpio.h‎

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,4 @@
1-
/*
2-
* Generic GPIO API implementation for PowerPC.
3-
*
4-
* Copyright (c) 2007-2008 MontaVista Software, Inc.
5-
*
6-
* Author: Anton Vorontsov <avorontsov@ru.mvista.com>
7-
*
8-
* This program is free software; you can redistribute it and/or modify
9-
* it under the terms of the GNU General Public License as published by
10-
* the Free Software Foundation; either version 2 of the License, or
11-
* (at your option) any later version.
12-
*/
13-
14-
#ifndef _ASM_MICROBLAZE_GPIO_H
15-
#define _ASM_MICROBLAZE_GPIO_H
16-
17-
#include <linux/errno.h>
18-
#include <asm-generic/gpio.h>
19-
20-
#ifdef CONFIG_GPIOLIB
21-
22-
/*
23-
* We don't (yet) implement inlined/rapid versions for on-chip gpios.
24-
* Just call gpiolib.
25-
*/
26-
static inline int gpio_get_value(unsigned int gpio)
27-
{
28-
return __gpio_get_value(gpio);
29-
}
30-
31-
static inline void gpio_set_value(unsigned int gpio, int value)
32-
{
33-
__gpio_set_value(gpio, value);
34-
}
35-
36-
static inline int gpio_cansleep(unsigned int gpio)
37-
{
38-
return __gpio_cansleep(gpio);
39-
}
40-
41-
static inline int gpio_to_irq(unsigned int gpio)
42-
{
43-
return __gpio_to_irq(gpio);
44-
}
45-
46-
static inline int irq_to_gpio(unsigned int irq)
47-
{
48-
return -EINVAL;
49-
}
50-
51-
#endif /* CONFIG_GPIOLIB */
52-
53-
#endif /* _ASM_MICROBLAZE_GPIO_H */
1+
#ifndef __LINUX_GPIO_H
2+
#warning Include linux/gpio.h instead of asm/gpio.h
3+
#include <linux/gpio.h>
4+
#endif

‎arch/mips/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ config MIPS
88
select HAVE_PERF_EVENTS
99
select PERF_USE_VMALLOC
1010
select HAVE_ARCH_KGDB
11+
select ARCH_HAVE_CUSTOM_GPIO_H
1112
select HAVE_FUNCTION_TRACER
1213
select HAVE_FUNCTION_TRACE_MCOUNT_TEST
1314
select HAVE_DYNAMIC_FTRACE

‎arch/openrisc/include/asm/gpio.h‎

Lines changed: 4 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,4 @@
1-
/*
2-
* OpenRISC Linux
3-
*
4-
* Linux architectural port borrowing liberally from similar works of
5-
* others. All original copyrights apply as per the original source
6-
* declaration.
7-
*
8-
* OpenRISC implementation:
9-
* Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
10-
* Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
11-
* et al.
12-
*
13-
* This program is free software; you can redistribute it and/or modify
14-
* it under the terms of the GNU General Public License as published by
15-
* the Free Software Foundation; either version 2 of the License, or
16-
* (at your option) any later version.
17-
*/
18-
19-
#ifndef __ASM_OPENRISC_GPIO_H
20-
#define __ASM_OPENRISC_GPIO_H
21-
22-
#include <linux/errno.h>
23-
#include <asm-generic/gpio.h>
24-
25-
#ifdef CONFIG_GPIOLIB
26-
27-
/*
28-
* OpenRISC (or1k) does not have on-chip GPIO's so there is not really
29-
* any standardized implementation that makes sense here. If passing
30-
* through gpiolib becomes a bottleneck then it may make sense, on a
31-
* case-by-case basis, to implement these inlined/rapid versions.
32-
*
33-
* Just call gpiolib.
34-
*/
35-
static inline int gpio_get_value(unsigned int gpio)
36-
{
37-
return __gpio_get_value(gpio);
38-
}
39-
40-
static inline void gpio_set_value(unsigned int gpio, int value)
41-
{
42-
__gpio_set_value(gpio, value);
43-
}
44-
45-
static inline int gpio_cansleep(unsigned int gpio)
46-
{
47-
return __gpio_cansleep(gpio);
48-
}
49-
50-
/*
51-
* Not implemented, yet.
52-
*/
53-
static inline int gpio_to_irq(unsigned int gpio)
54-
{
55-
return -ENOSYS;
56-
}
57-
58-
static inline int irq_to_gpio(unsigned int irq)
59-
{
60-
return -EINVAL;
61-
}
62-
63-
#endif /* CONFIG_GPIOLIB */
64-
65-
#endif /* __ASM_OPENRISC_GPIO_H */
1+
#ifndef __LINUX_GPIO_H
2+
#warning Include linux/gpio.h instead of asm/gpio.h
3+
#include <linux/gpio.h>
4+
#endif

‎arch/powerpc/include/asm/gpio.h‎

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,4 @@
1-
/*
2-
* Generic GPIO API implementation for PowerPC.
3-
*
4-
* Copyright (c) 2007-2008 MontaVista Software, Inc.
5-
*
6-
* Author: Anton Vorontsov <avorontsov@ru.mvista.com>
7-
*
8-
* This program is free software; you can redistribute it and/or modify
9-
* it under the terms of the GNU General Public License as published by
10-
* the Free Software Foundation; either version 2 of the License, or
11-
* (at your option) any later version.
12-
*/
13-
14-
#ifndef __ASM_POWERPC_GPIO_H
15-
#define __ASM_POWERPC_GPIO_H
16-
17-
#include <linux/errno.h>
18-
#include <asm-generic/gpio.h>
19-
20-
#ifdef CONFIG_GPIOLIB
21-
22-
/*
23-
* We don't (yet) implement inlined/rapid versions for on-chip gpios.
24-
* Just call gpiolib.
25-
*/
26-
static inline int gpio_get_value(unsigned int gpio)
27-
{
28-
return __gpio_get_value(gpio);
29-
}
30-
31-
static inline void gpio_set_value(unsigned int gpio, int value)
32-
{
33-
__gpio_set_value(gpio, value);
34-
}
35-
36-
static inline int gpio_cansleep(unsigned int gpio)
37-
{
38-
return __gpio_cansleep(gpio);
39-
}
40-
41-
static inline int gpio_to_irq(unsigned int gpio)
42-
{
43-
return __gpio_to_irq(gpio);
44-
}
45-
46-
static inline int irq_to_gpio(unsigned int irq)
47-
{
48-
return -EINVAL;
49-
}
50-
51-
#endif /* CONFIG_GPIOLIB */
52-
53-
#endif /* __ASM_POWERPC_GPIO_H */
1+
#ifndef __LINUX_GPIO_H
2+
#warning Include linux/gpio.h instead of asm/gpio.h
3+
#include <linux/gpio.h>
4+
#endif

0 commit comments

Comments
 (0)