Commit 3fff99bc authored by Rojhalat Ibrahim's avatar Rojhalat Ibrahim Committed by Linus Walleij

gpiolib: rename gpiod_set_array to gpiod_set_array_value

There have been concerns that the function names gpiod_set_array() and
gpiod_get_array() might be confusing to users. One might expect
gpiod_get_array() to return array values, while it is actually the array
counterpart of gpiod_get(). To be consistent with the single descriptor API
we could rename gpiod_set_array() to gpiod_set_array_value(). This makes
some function names a bit lengthy: gpiod_set_raw_array_value_cansleep().
Signed-off-by: default avatarRojhalat Ibrahim <imr@rtschenk.de>
Acked-by: default avatarAlexandre Courbot <acourbot@nvidia.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 20a8a968
...@@ -1316,10 +1316,10 @@ static void gpio_chip_set_multiple(struct gpio_chip *chip, ...@@ -1316,10 +1316,10 @@ static void gpio_chip_set_multiple(struct gpio_chip *chip,
} }
} }
static void gpiod_set_array_priv(bool raw, bool can_sleep, static void gpiod_set_array_value_priv(bool raw, bool can_sleep,
unsigned int array_size, unsigned int array_size,
struct gpio_desc **desc_array, struct gpio_desc **desc_array,
int *value_array) int *value_array)
{ {
int i = 0; int i = 0;
...@@ -1412,7 +1412,7 @@ void gpiod_set_value(struct gpio_desc *desc, int value) ...@@ -1412,7 +1412,7 @@ void gpiod_set_value(struct gpio_desc *desc, int value)
EXPORT_SYMBOL_GPL(gpiod_set_value); EXPORT_SYMBOL_GPL(gpiod_set_value);
/** /**
* gpiod_set_raw_array() - assign values to an array of GPIOs * gpiod_set_raw_array_value() - assign values to an array of GPIOs
* @array_size: number of elements in the descriptor / value arrays * @array_size: number of elements in the descriptor / value arrays
* @desc_array: array of GPIO descriptors whose values will be assigned * @desc_array: array of GPIO descriptors whose values will be assigned
* @value_array: array of values to assign * @value_array: array of values to assign
...@@ -1423,17 +1423,18 @@ EXPORT_SYMBOL_GPL(gpiod_set_value); ...@@ -1423,17 +1423,18 @@ EXPORT_SYMBOL_GPL(gpiod_set_value);
* This function should be called from contexts where we cannot sleep, and will * This function should be called from contexts where we cannot sleep, and will
* complain if the GPIO chip functions potentially sleep. * complain if the GPIO chip functions potentially sleep.
*/ */
void gpiod_set_raw_array(unsigned int array_size, void gpiod_set_raw_array_value(unsigned int array_size,
struct gpio_desc **desc_array, int *value_array) struct gpio_desc **desc_array, int *value_array)
{ {
if (!desc_array) if (!desc_array)
return; return;
gpiod_set_array_priv(true, false, array_size, desc_array, value_array); gpiod_set_array_value_priv(true, false, array_size, desc_array,
value_array);
} }
EXPORT_SYMBOL_GPL(gpiod_set_raw_array); EXPORT_SYMBOL_GPL(gpiod_set_raw_array_value);
/** /**
* gpiod_set_array() - assign values to an array of GPIOs * gpiod_set_array_value() - assign values to an array of GPIOs
* @array_size: number of elements in the descriptor / value arrays * @array_size: number of elements in the descriptor / value arrays
* @desc_array: array of GPIO descriptors whose values will be assigned * @desc_array: array of GPIO descriptors whose values will be assigned
* @value_array: array of values to assign * @value_array: array of values to assign
...@@ -1444,14 +1445,15 @@ EXPORT_SYMBOL_GPL(gpiod_set_raw_array); ...@@ -1444,14 +1445,15 @@ EXPORT_SYMBOL_GPL(gpiod_set_raw_array);
* This function should be called from contexts where we cannot sleep, and will * This function should be called from contexts where we cannot sleep, and will
* complain if the GPIO chip functions potentially sleep. * complain if the GPIO chip functions potentially sleep.
*/ */
void gpiod_set_array(unsigned int array_size, void gpiod_set_array_value(unsigned int array_size,
struct gpio_desc **desc_array, int *value_array) struct gpio_desc **desc_array, int *value_array)
{ {
if (!desc_array) if (!desc_array)
return; return;
gpiod_set_array_priv(false, false, array_size, desc_array, value_array); gpiod_set_array_value_priv(false, false, array_size, desc_array,
value_array);
} }
EXPORT_SYMBOL_GPL(gpiod_set_array); EXPORT_SYMBOL_GPL(gpiod_set_array_value);
/** /**
* gpiod_cansleep() - report whether gpio value access may sleep * gpiod_cansleep() - report whether gpio value access may sleep
...@@ -1613,7 +1615,7 @@ void gpiod_set_value_cansleep(struct gpio_desc *desc, int value) ...@@ -1613,7 +1615,7 @@ void gpiod_set_value_cansleep(struct gpio_desc *desc, int value)
EXPORT_SYMBOL_GPL(gpiod_set_value_cansleep); EXPORT_SYMBOL_GPL(gpiod_set_value_cansleep);
/** /**
* gpiod_set_raw_array_cansleep() - assign values to an array of GPIOs * gpiod_set_raw_array_value_cansleep() - assign values to an array of GPIOs
* @array_size: number of elements in the descriptor / value arrays * @array_size: number of elements in the descriptor / value arrays
* @desc_array: array of GPIO descriptors whose values will be assigned * @desc_array: array of GPIO descriptors whose values will be assigned
* @value_array: array of values to assign * @value_array: array of values to assign
...@@ -1623,19 +1625,20 @@ EXPORT_SYMBOL_GPL(gpiod_set_value_cansleep); ...@@ -1623,19 +1625,20 @@ EXPORT_SYMBOL_GPL(gpiod_set_value_cansleep);
* *
* This function is to be called from contexts that can sleep. * This function is to be called from contexts that can sleep.
*/ */
void gpiod_set_raw_array_cansleep(unsigned int array_size, void gpiod_set_raw_array_value_cansleep(unsigned int array_size,
struct gpio_desc **desc_array, struct gpio_desc **desc_array,
int *value_array) int *value_array)
{ {
might_sleep_if(extra_checks); might_sleep_if(extra_checks);
if (!desc_array) if (!desc_array)
return; return;
gpiod_set_array_priv(true, true, array_size, desc_array, value_array); gpiod_set_array_value_priv(true, true, array_size, desc_array,
value_array);
} }
EXPORT_SYMBOL_GPL(gpiod_set_raw_array_cansleep); EXPORT_SYMBOL_GPL(gpiod_set_raw_array_value_cansleep);
/** /**
* gpiod_set_array_cansleep() - assign values to an array of GPIOs * gpiod_set_array_value_cansleep() - assign values to an array of GPIOs
* @array_size: number of elements in the descriptor / value arrays * @array_size: number of elements in the descriptor / value arrays
* @desc_array: array of GPIO descriptors whose values will be assigned * @desc_array: array of GPIO descriptors whose values will be assigned
* @value_array: array of values to assign * @value_array: array of values to assign
...@@ -1645,16 +1648,17 @@ EXPORT_SYMBOL_GPL(gpiod_set_raw_array_cansleep); ...@@ -1645,16 +1648,17 @@ EXPORT_SYMBOL_GPL(gpiod_set_raw_array_cansleep);
* *
* This function is to be called from contexts that can sleep. * This function is to be called from contexts that can sleep.
*/ */
void gpiod_set_array_cansleep(unsigned int array_size, void gpiod_set_array_value_cansleep(unsigned int array_size,
struct gpio_desc **desc_array, struct gpio_desc **desc_array,
int *value_array) int *value_array)
{ {
might_sleep_if(extra_checks); might_sleep_if(extra_checks);
if (!desc_array) if (!desc_array)
return; return;
gpiod_set_array_priv(false, true, array_size, desc_array, value_array); gpiod_set_array_value_priv(false, true, array_size, desc_array,
value_array);
} }
EXPORT_SYMBOL_GPL(gpiod_set_array_cansleep); EXPORT_SYMBOL_GPL(gpiod_set_array_value_cansleep);
/** /**
* gpiod_add_lookup_table() - register GPIO device consumers * gpiod_add_lookup_table() - register GPIO device consumers
......
...@@ -35,7 +35,8 @@ static int mdio_mux_gpio_switch_fn(int current_child, int desired_child, ...@@ -35,7 +35,8 @@ static int mdio_mux_gpio_switch_fn(int current_child, int desired_child,
for (n = 0; n < s->gpios->ndescs; n++) for (n = 0; n < s->gpios->ndescs; n++)
values[n] = (desired_child >> n) & 1; values[n] = (desired_child >> n) & 1;
gpiod_set_array_cansleep(s->gpios->ndescs, s->gpios->desc, values); gpiod_set_array_value_cansleep(s->gpios->ndescs, s->gpios->desc,
values);
return 0; return 0;
} }
......
...@@ -55,7 +55,7 @@ void mctrl_gpio_set(struct mctrl_gpios *gpios, unsigned int mctrl) ...@@ -55,7 +55,7 @@ void mctrl_gpio_set(struct mctrl_gpios *gpios, unsigned int mctrl)
value_array[count] = !!(mctrl & mctrl_gpios_desc[i].mctrl); value_array[count] = !!(mctrl & mctrl_gpios_desc[i].mctrl);
count++; count++;
} }
gpiod_set_array(count, desc_array, value_array); gpiod_set_array_value(count, desc_array, value_array);
} }
EXPORT_SYMBOL_GPL(mctrl_gpio_set); EXPORT_SYMBOL_GPL(mctrl_gpio_set);
......
...@@ -100,24 +100,25 @@ int gpiod_direction_output_raw(struct gpio_desc *desc, int value); ...@@ -100,24 +100,25 @@ int gpiod_direction_output_raw(struct gpio_desc *desc, int value);
/* Value get/set from non-sleeping context */ /* Value get/set from non-sleeping context */
int gpiod_get_value(const struct gpio_desc *desc); int gpiod_get_value(const struct gpio_desc *desc);
void gpiod_set_value(struct gpio_desc *desc, int value); void gpiod_set_value(struct gpio_desc *desc, int value);
void gpiod_set_array(unsigned int array_size, void gpiod_set_array_value(unsigned int array_size,
struct gpio_desc **desc_array, int *value_array); struct gpio_desc **desc_array, int *value_array);
int gpiod_get_raw_value(const struct gpio_desc *desc); int gpiod_get_raw_value(const struct gpio_desc *desc);
void gpiod_set_raw_value(struct gpio_desc *desc, int value); void gpiod_set_raw_value(struct gpio_desc *desc, int value);
void gpiod_set_raw_array(unsigned int array_size, void gpiod_set_raw_array_value(unsigned int array_size,
struct gpio_desc **desc_array, int *value_array); struct gpio_desc **desc_array,
int *value_array);
/* Value get/set from sleeping context */ /* Value get/set from sleeping context */
int gpiod_get_value_cansleep(const struct gpio_desc *desc); int gpiod_get_value_cansleep(const struct gpio_desc *desc);
void gpiod_set_value_cansleep(struct gpio_desc *desc, int value); void gpiod_set_value_cansleep(struct gpio_desc *desc, int value);
void gpiod_set_array_cansleep(unsigned int array_size, void gpiod_set_array_value_cansleep(unsigned int array_size,
struct gpio_desc **desc_array, struct gpio_desc **desc_array,
int *value_array); int *value_array);
int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc); int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc);
void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value); void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value);
void gpiod_set_raw_array_cansleep(unsigned int array_size, void gpiod_set_raw_array_value_cansleep(unsigned int array_size,
struct gpio_desc **desc_array, struct gpio_desc **desc_array,
int *value_array); int *value_array);
int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce); int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce);
...@@ -304,9 +305,9 @@ static inline void gpiod_set_value(struct gpio_desc *desc, int value) ...@@ -304,9 +305,9 @@ static inline void gpiod_set_value(struct gpio_desc *desc, int value)
/* GPIO can never have been requested */ /* GPIO can never have been requested */
WARN_ON(1); WARN_ON(1);
} }
static inline void gpiod_set_array(unsigned int array_size, static inline void gpiod_set_array_value(unsigned int array_size,
struct gpio_desc **desc_array, struct gpio_desc **desc_array,
int *value_array) int *value_array)
{ {
/* GPIO can never have been requested */ /* GPIO can never have been requested */
WARN_ON(1); WARN_ON(1);
...@@ -322,9 +323,9 @@ static inline void gpiod_set_raw_value(struct gpio_desc *desc, int value) ...@@ -322,9 +323,9 @@ static inline void gpiod_set_raw_value(struct gpio_desc *desc, int value)
/* GPIO can never have been requested */ /* GPIO can never have been requested */
WARN_ON(1); WARN_ON(1);
} }
static inline void gpiod_set_raw_array(unsigned int array_size, static inline void gpiod_set_raw_array_value(unsigned int array_size,
struct gpio_desc **desc_array, struct gpio_desc **desc_array,
int *value_array) int *value_array)
{ {
/* GPIO can never have been requested */ /* GPIO can never have been requested */
WARN_ON(1); WARN_ON(1);
...@@ -341,7 +342,7 @@ static inline void gpiod_set_value_cansleep(struct gpio_desc *desc, int value) ...@@ -341,7 +342,7 @@ static inline void gpiod_set_value_cansleep(struct gpio_desc *desc, int value)
/* GPIO can never have been requested */ /* GPIO can never have been requested */
WARN_ON(1); WARN_ON(1);
} }
static inline void gpiod_set_array_cansleep(unsigned int array_size, static inline void gpiod_set_array_value_cansleep(unsigned int array_size,
struct gpio_desc **desc_array, struct gpio_desc **desc_array,
int *value_array) int *value_array)
{ {
...@@ -360,7 +361,7 @@ static inline void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, ...@@ -360,7 +361,7 @@ static inline void gpiod_set_raw_value_cansleep(struct gpio_desc *desc,
/* GPIO can never have been requested */ /* GPIO can never have been requested */
WARN_ON(1); WARN_ON(1);
} }
static inline void gpiod_set_raw_array_cansleep(unsigned int array_size, static inline void gpiod_set_raw_array_value_cansleep(unsigned int array_size,
struct gpio_desc **desc_array, struct gpio_desc **desc_array,
int *value_array) int *value_array)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment