gpio: Make gpio_{request,free}_array gpio array parameter const
Subsystems (2)
PATCH 1/1 gpio: Make gpio_{request,free}_array gpio array parameter const
gpio_{request,free}_array should not (and do not) modify the passed gpio array, so make the parameter const.
--- drivers/gpio/gpiolib.c | 4 ++-- include/asm-generic/gpio.h | 4 ++-- include/linux/gpio.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/gpio/gpiolib.c +2 -2
@@ -1293,7 +1293,7 @@ EXPORT_SYMBOL_GPL(gpio_request_one);* @array: array of the 'struct gpio' * @num: how many GPIOs in the array */ -int gpio_request_array (struct gpio *array,size_t num) +int gpio_request_array (const struct gpio *array,size_t num) {int i, err;
@@ -1316,7 +1316,7 @@ EXPORT_SYMBOL_GPL(gpio_request_array);* @array: array of the 'struct gpio' * @num: how many GPIOs in the array */ -void gpio_free_array (struct gpio *array,size_t num) +void gpio_free_array (const struct gpio *array,size_t num) {while (num--)gpio_free ((array++)->gpio);
include/asm-generic/gpio.h +2 -2
@@ -193,8 +193,8 @@ struct gpio { };extern int gpio_request_one (unsigned gpio,unsigned long flags,const char *label); -extern int gpio_request_array (struct gpio *array,size_t num); -extern void gpio_free_array (struct gpio *array,size_t num); +extern int gpio_request_array (const struct gpio *array,size_t num); +extern void gpio_free_array (const struct gpio *array,size_t num);#ifdef CONFIG_GPIO_SYSFS
include/linux/gpio.h +2 -2
@@ -41,7 +41,7 @@ static inline int gpio_request_one(unsigned gpio,return -ENOSYS ; } -static inline int gpio_request_array (struct gpio *array,size_t num) +static inline int gpio_request_array (const struct gpio *array,size_t num) {return -ENOSYS ; }
@@ -54,7 +54,7 @@ static inline void gpio_free(unsigned gpio)WARN_ON (1 ); } -static inline void gpio_free_array (struct gpio *array,size_t num) +static inline void gpio_free_array (const struct gpio *array,size_t num) {might_sleep ();
Signature · 1 line
1.7.2.3
Quoted 4 lines · Lars-Peter Clausen
gpio_{request,free}_array should not (and do not) modify the passed gpio array, so make the parameter const.
Signed-off-by Lars-Peter Clausen <[email protected]>
Quoted 69 lines
---
drivers/gpio/gpiolib.c | 4 ++--
include/asm-generic/gpio.h | 4 ++--
include/linux/gpio.h | 4 ++--3 files changed, 6 insertions(+), 6 deletions(-)drivers/gpio/gpiolib.c +2
-2@@ -1293,7 +1293,7 @@ EXPORT_SYMBOL_GPL(gpio_request_one);* @array: array of the 'struct gpio' * @num: how many GPIOs in the array */ -int gpio_request_array (struct gpio *array,size_t num) +int gpio_request_array (const struct gpio *array,size_t num) { int i, err;@@ -1316,7 +1316,7 @@ EXPORT_SYMBOL_GPL(gpio_request_array);* @array: array of the 'struct gpio' * @num: how many GPIOs in the array */ -void gpio_free_array (struct gpio *array,size_t num) +void gpio_free_array (const struct gpio *array,size_t num) { while (num--) gpio_free((array++)->gpio);include/asm-generic/gpio.h +2
-2@@ -193,8 +193,8 @@ struct gpio { }; extern int gpio_request_one(unsigned gpio, unsigned long flags, const char *label); -extern int gpio_request_array (struct gpio *array,size_t num); -extern void gpio_free_array (struct gpio *array,size_t num); +extern int gpio_request_array (const struct gpio *array,size_t num); +extern void gpio_free_array (const struct gpio *array,size_t num); #ifdef CONFIG_GPIO_SYSFSinclude/linux/gpio.h +2
-3@@ -41,7 +41,7 @@ static inline int gpio_request_one(unsigned gpio, return -ENOSYS; } -static inline int gpio_request_array (struct gpio *array,size_t num) +static inline int gpio_request_array (const struct gpio *array,size_t num) { return -ENOSYS; }@@ -54,7 +54,7 @@ static inline void gpio_free(unsigned gpio) WARN_ON(1); } -static inline void gpio_free_array (struct gpio *array,size_t num) +static inline void gpio_free_array (const struct gpio *array,size_t num) { might_sleep(); --1.7.2.3
Quoted 4 lines · Lars-Peter Clausen
gpio_{request,free}_array should not (and do not) modify the passed gpio array, so make the parameter const.
Signed-off-by Lars-Peter Clausen <[email protected]>
Looks good to me. What about the users of these calls (luckily there don't seem to be many)?
Kind regards,
Wolfram
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
Quoted 4 lines · Wolfram Sang
Quoted 3 lines · Lars-Peter Clausen
gpio_{request,free}_array should not (and do not) modify the passed gpio array, so make the parameter const.
Quoted 9 lines
Quoted 1 line
Signed-off-by Lars-Peter Clausen <[email protected]>Looks good to me. What about the users of these calls (luckily there don't seem to be many)?
Kind regards,
Wolfram
Hi
Well, they could, but don't have to, make their gpio array const now, if it is not otherwise modified. But I guess that is something for a follow-up patch.
- Lars