[U-Boot] [PATCH 08/69] gpio: Use const where possible

Simon Glass sjg at chromium.org
Mon Mar 7 03:27:51 CET 2016


Some functions do not change the struct gpio_desc parameter. Update these to
use const so this is clear.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 drivers/gpio/gpio-uclass.c | 10 +++++-----
 include/asm-generic/gpio.h | 10 +++++-----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index b2a2ca8..b58d4e6 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -257,7 +257,7 @@ int gpio_free(unsigned gpio)
 	return _dm_gpio_free(desc.dev, desc.offset);
 }
 
-static int check_reserved(struct gpio_desc *desc, const char *func)
+static int check_reserved(const struct gpio_desc *desc, const char *func)
 {
 	struct gpio_dev_priv *uc_priv;
 
@@ -324,7 +324,7 @@ int gpio_direction_output(unsigned gpio, int value)
 							desc.offset, value);
 }
 
-int dm_gpio_get_value(struct gpio_desc *desc)
+int dm_gpio_get_value(const struct gpio_desc *desc)
 {
 	int value;
 	int ret;
@@ -338,7 +338,7 @@ int dm_gpio_get_value(struct gpio_desc *desc)
 	return desc->flags & GPIOD_ACTIVE_LOW ? !value : value;
 }
 
-int dm_gpio_set_value(struct gpio_desc *desc, int value)
+int dm_gpio_set_value(const struct gpio_desc *desc, int value)
 {
 	int ret;
 
@@ -577,7 +577,7 @@ int gpio_get_values_as_int(const int *gpio_list)
 	return vector;
 }
 
-int dm_gpio_get_values_as_int(struct gpio_desc *desc_list, int count)
+int dm_gpio_get_values_as_int(const struct gpio_desc *desc_list, int count)
 {
 	unsigned bitmask = 1;
 	unsigned vector = 0;
@@ -766,7 +766,7 @@ static int gpio_renumber(struct udevice *removed_dev)
 	return 0;
 }
 
-int gpio_get_number(struct gpio_desc *desc)
+int gpio_get_number(const struct gpio_desc *desc)
 {
 	struct udevice *dev = desc->dev;
 	struct gpio_dev_priv *uc_priv;
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index 059f339..68b5f0b 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -133,7 +133,7 @@ struct gpio_desc {
  *		previously returned by gpio_request_by_name()
  * @return true if valid, false if not
  */
-static inline bool dm_gpio_is_valid(struct gpio_desc *desc)
+static inline bool dm_gpio_is_valid(const struct gpio_desc *desc)
 {
 	return desc->dev != NULL;
 }
@@ -369,7 +369,7 @@ int gpio_get_values_as_int(const int *gpio_list);
  * @count: Number of GPIOs
  * @return resulting integer value, or -ve on error
  */
-int dm_gpio_get_values_as_int(struct gpio_desc *desc_list, int count);
+int dm_gpio_get_values_as_int(const struct gpio_desc *desc_list, int count);
 
 /**
  * gpio_claim_vector() - claim a number of GPIOs for input
@@ -536,9 +536,9 @@ int gpio_free_list_nodev(struct gpio_desc *desc, int count);
  *		previously returned by gpio_request_by_name()
  * @return GPIO value (0 for inactive, 1 for active) or -ve on error
  */
-int dm_gpio_get_value(struct gpio_desc *desc);
+int dm_gpio_get_value(const struct gpio_desc *desc);
 
-int dm_gpio_set_value(struct gpio_desc *desc, int value);
+int dm_gpio_set_value(const struct gpio_desc *desc, int value);
 
 /**
  * dm_gpio_set_dir() - Set the direction for a GPIO
@@ -577,6 +577,6 @@ int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags);
  *		previously returned by gpio_request_by_name()
  * @return GPIO number, or -ve if not found
  */
-int gpio_get_number(struct gpio_desc *desc);
+int gpio_get_number(const struct gpio_desc *desc);
 
 #endif	/* _ASM_GENERIC_GPIO_H_ */
-- 
2.7.0.rc3.207.g0ac5344



More information about the U-Boot mailing list