diff options
Diffstat (limited to 'include/asm-generic')
| -rw-r--r-- | include/asm-generic/gpio.h | 14 | ||||
| -rw-r--r-- | include/asm-generic/percpu.h | 15 |
2 files changed, 23 insertions, 6 deletions
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index c7376bf80b06..8ca18e26d7e3 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h | |||
| @@ -16,15 +16,27 @@ | |||
| 16 | * While the GPIO programming interface defines valid GPIO numbers | 16 | * While the GPIO programming interface defines valid GPIO numbers |
| 17 | * to be in the range 0..MAX_INT, this library restricts them to the | 17 | * to be in the range 0..MAX_INT, this library restricts them to the |
| 18 | * smaller range 0..ARCH_NR_GPIOS-1. | 18 | * smaller range 0..ARCH_NR_GPIOS-1. |
| 19 | * | ||
| 20 | * ARCH_NR_GPIOS is somewhat arbitrary; it usually reflects the sum of | ||
| 21 | * builtin/SoC GPIOs plus a number of GPIOs on expanders; the latter is | ||
| 22 | * actually an estimate of a board-specific value. | ||
| 19 | */ | 23 | */ |
| 20 | 24 | ||
| 21 | #ifndef ARCH_NR_GPIOS | 25 | #ifndef ARCH_NR_GPIOS |
| 22 | #define ARCH_NR_GPIOS 256 | 26 | #define ARCH_NR_GPIOS 256 |
| 23 | #endif | 27 | #endif |
| 24 | 28 | ||
| 29 | /* | ||
| 30 | * "valid" GPIO numbers are nonnegative and may be passed to | ||
| 31 | * setup routines like gpio_request(). only some valid numbers | ||
| 32 | * can successfully be requested and used. | ||
| 33 | * | ||
| 34 | * Invalid GPIO numbers are useful for indicating no-such-GPIO in | ||
| 35 | * platform data and other tables. | ||
| 36 | */ | ||
| 37 | |||
| 25 | static inline int gpio_is_valid(int number) | 38 | static inline int gpio_is_valid(int number) |
| 26 | { | 39 | { |
| 27 | /* only some non-negative numbers are valid */ | ||
| 28 | return ((unsigned)number) < ARCH_NR_GPIOS; | 40 | return ((unsigned)number) < ARCH_NR_GPIOS; |
| 29 | } | 41 | } |
| 30 | 42 | ||
diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h index b5043a9890d8..08923b684768 100644 --- a/include/asm-generic/percpu.h +++ b/include/asm-generic/percpu.h | |||
| @@ -70,11 +70,16 @@ extern void setup_per_cpu_areas(void); | |||
| 70 | 70 | ||
| 71 | #else /* ! SMP */ | 71 | #else /* ! SMP */ |
| 72 | 72 | ||
| 73 | #define per_cpu(var, cpu) (*((void)(cpu), &(var))) | 73 | #define VERIFY_PERCPU_PTR(__p) ({ \ |
| 74 | #define __get_cpu_var(var) (var) | 74 | __verify_pcpu_ptr((__p)); \ |
| 75 | #define __raw_get_cpu_var(var) (var) | 75 | (typeof(*(__p)) __kernel __force *)(__p); \ |
| 76 | #define this_cpu_ptr(ptr) per_cpu_ptr(ptr, 0) | 76 | }) |
| 77 | #define __this_cpu_ptr(ptr) this_cpu_ptr(ptr) | 77 | |
| 78 | #define per_cpu(var, cpu) (*((void)(cpu), VERIFY_PERCPU_PTR(&(var)))) | ||
| 79 | #define __get_cpu_var(var) (*VERIFY_PERCPU_PTR(&(var))) | ||
| 80 | #define __raw_get_cpu_var(var) (*VERIFY_PERCPU_PTR(&(var))) | ||
| 81 | #define this_cpu_ptr(ptr) per_cpu_ptr(ptr, 0) | ||
| 82 | #define __this_cpu_ptr(ptr) this_cpu_ptr(ptr) | ||
| 78 | 83 | ||
| 79 | #endif /* SMP */ | 84 | #endif /* SMP */ |
| 80 | 85 | ||
