Skip to contentSkip to conversation

gpiolib: deprecate gpio_chip::set and gpio_chip::set_multiple

PATCH Applied Bartosz Golaszewski 1 participant 3 messages Feb 27, 2025 – Mar 3, 2025 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 gpiolib: deprecate gpio_chip::set and gpio_chip::set_multiple

From: Bartosz Golaszewski <[email protected]>

We now have setter callbacks that allow us to indicate success or failure using the integer return value. Deprecate the older callbacks so that no new code is tempted to use them.

---
 include/linux/gpio/driver.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/gpio/driver.h +2 -2
index a2a1b6434321..783897d94be8 100644
@@ -346,8 +346,8 @@ struct gpio_irq_chip {
  * @get: returns value for signal "offset", 0=low, 1=high, or negative error
  * @get_multiple: reads values for multiple signals defined by "mask" and
  *	stores them in "bits", returns 0 on success or negative error
- * @set: assigns output value for signal "offset"
- * @set_multiple: assigns output values for multiple signals defined by "mask"
+ * @set: **DEPRECATED** - please use set_rv() instead
+ * @set_multiple: **DEPRECATED** - please use set_multiple_rv() instead
  * @set_rv: assigns output value for signal "offset", returns 0 on success or
  *          negative error value
  * @set_multiple_rv: assigns output values for multiple signals defined by
Signature · 1 line
2.45.2
#1 lore raw

PATCH 2/2 gpiolib: update kerneldocs for value setters

From: Bartosz Golaszewski <[email protected]>

Value setters now return int and can indicate failure. Update the kerneldocs.

---
 drivers/gpio/gpiolib.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/gpio/gpiolib.c +15 -0
index d0108cf2ee0b..4671a66f5672 100644
@@ -3764,6 +3764,9 @@ int gpiod_set_array_value_complex(bool raw, bool can_sleep,
  *
  * This function can be called from contexts where we cannot sleep, and will
  * complain if the GPIO chip functions potentially sleep.
+ *
+ * Returns:
+ * 0 on success, negative error number on failure.
  */
 int gpiod_set_raw_value(struct gpio_desc *desc, int value)
 {
@@ -3782,6 +3785,9 @@ EXPORT_SYMBOL_GPL(gpiod_set_raw_value);
  * This sets the value of a GPIO line backing a descriptor, applying
  * different semantic quirks like active low and open drain/source
  * handling.
+ *
+ * Returns:
+ * 0 on success, negative error number on failure.
  */
 static int gpiod_set_value_nocheck(struct gpio_desc *desc, int value)
 {
@@ -3806,6 +3812,9 @@ static int gpiod_set_value_nocheck(struct gpio_desc *desc, int value)
  *
  * This function can be called from contexts where we cannot sleep, and will
  * complain if the GPIO chip functions potentially sleep.
+ *
+ * Returns:
+ * 0 on success, negative error number on failure.
  */
 int gpiod_set_value(struct gpio_desc *desc, int value)
 {
@@ -4230,6 +4239,9 @@ EXPORT_SYMBOL_GPL(gpiod_get_array_value_cansleep);
  * regard for its ACTIVE_LOW status.
  *
  * This function is to be called from contexts that can sleep.
+ *
+ * Returns:
+ * 0 on success, negative error number on failure.
  */
 int gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value)
 {
@@ -4248,6 +4260,9 @@ EXPORT_SYMBOL_GPL(gpiod_set_raw_value_cansleep);
  * account
  *
  * This function is to be called from contexts that can sleep.
+ *
+ * Returns:
+ * 0 on success, negative error number on failure.
  */
 int gpiod_set_value_cansleep(struct gpio_desc *desc, int value)
 {
Signature · 1 line
2.45.2
author Applied
#2 lore raw
In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Quoted 5 lines · Bartosz Golaszewski

We now have setter callbacks that allow us to indicate success or failure using the integer return value. Deprecate the older callbacks so that no new code is tempted to use them.

Applied, thanks!

[1/2] gpiolib: deprecate gpio_chip::set and gpio_chip::set_multiple

      commit: 6224e7fc1ce75edcd03b56a2e0fd4c1765d5888e
[2/2] gpiolib: update kerneldocs for value setters
      commit: 9778568dede2166c7bd124d473f9ec365f782935

Best regards,

Signature · 1 line
Bartosz Golaszewski <[email protected]>