Skip to contentSkip to conversation

gpio: Make gpio_{request,free}_array gpio array parameter const

PATCH In review Lars-Peter Clausen 3 participants 4 messages Jan 29, 2011 – Jan 30, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
index 649550e..27016c4 100644
@@ -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
index ff5c660..05119e7 100644
@@ -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
index 32720ba..b2b610f 100644
@@ -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
Acked-by on v1 1/1
#1 lore raw
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.

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
index 649550e..27016c4 100644
@@ -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
index ff5c660..05119e7 100644
@@ -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 -3
index 32720ba..b2b610f 100644
@@ -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

#2 lore raw
In reply to Lars-Peter Clausen
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.

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/  |
#3 lore raw
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

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