linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/14] gpiolib: indicate errors in value setters
@ 2025-02-11 12:09 Bartosz Golaszewski
  2025-02-11 12:09 ` [PATCH 01/14] gpiolib: make value setters have return values Bartosz Golaszewski
                   ` (14 more replies)
  0 siblings, 15 replies; 22+ messages in thread
From: Bartosz Golaszewski @ 2025-02-11 12:09 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Michael Walle,
	Bamvor Jian Zhang, Geert Uytterhoeven, Keerthy,
	Uwe Kleine-König
  Cc: linux-gpio, linux-kernel, linux-pwm, Bartosz Golaszewski

The value setter callbacks (both for single and multiple lines) return
void even though we have many types of controllers that can fail to set
a line's value: i2c, SPI, USB, etc.

For the consumer API: single line setters return void. Multiple line
setters do have an integer return value but due to the above, they still
cannot be used to indicate problems within the driver.

This series proposes to start the process of converting the setters to
returning int thus making it possible to propagate any errors to the
user.

The first patch changes the consumer interfaces. This has no impact on
any user (even though they don't currently check the retval) except for
places where any of the functions are passed as function pointer
arguments in which case we need to update the affected callers. I only
identified one such place - the gpio-latch module. I guess we may find
more when the series gets into next.

The second patch adds a wrapper around gpio_chip::set() to limit the
number of places where this pointer is dereferenced to one making
further work easier. Next we make the existing wrapper around
gpio_chip::set_multiple() consistent with the one for set() in terms of
the return value as well as SRCU and callback checks.

Finally in patch 4 we add new variants of the set callbacks suffixed
with "_rv" indicating that they return a value. We privilege them in the
code only falling back to the old ones if the new ones aren't present.

Patches that follow convert several drivers to using the new callbacks
to start the process.

My long term plan for this rework is the following:
1. Get this intitial series into the GPIO tree and next. Make sure it
   doesn't cause problems.
2. Start to convert drivers under drivers/gpio/ until the end of this
   cycle.
3. After v6.15-rc1 is tagged and the new callbacks are available
   upstream, start converting drivers outside of drivers/gpio/. For most
   part, this concerns drivers/pinctrl/ but we also have GPIO drivers
   scattered in media, sound, iio and old board files.
4. Once all GPIO chips are converted to using the new setters, remove
   the old callbacks and rename the new ones to the old name in one
   swift move across the tree (similarly to how the remove_new() was
   changed back to remove().

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
Bartosz Golaszewski (14):
      gpiolib: make value setters have return values
      gpiolib: wrap gpio_chip::set()
      gpiolib: rework the wrapper around gpio_chip::set_multiple()
      gpiolib: introduce gpio_chip setters that return values
      gpio: sim: use value returning setters
      gpio: regmap: use value returning setters
      gpio: pca953x: use value returning setters
      gpio: mockup: use value returning setters
      gpio: aggregator: use value returning setters
      gpio: max77650: use value returning setters
      gpio: latch: use lock guards
      gpio: latch: use value returning setters
      gpio: davinci: use value returning setters
      gpio: mvebu: use value returning setters

 drivers/gpio/gpio-aggregator.c |  38 +++++++-----
 drivers/gpio/gpio-davinci.c    |   6 +-
 drivers/gpio/gpio-latch.c      |  53 ++++++++--------
 drivers/gpio/gpio-max77650.c   |  14 ++---
 drivers/gpio/gpio-mockup.c     |  14 +++--
 drivers/gpio/gpio-mvebu.c      |   8 +--
 drivers/gpio/gpio-pca953x.c    |  17 ++---
 drivers/gpio/gpio-regmap.c     |  21 ++++---
 drivers/gpio/gpio-sim.c        |  14 +++--
 drivers/gpio/gpiolib.c         | 137 +++++++++++++++++++++++++++++------------
 include/linux/gpio.h           |   4 +-
 include/linux/gpio/consumer.h  |  22 ++++---
 include/linux/gpio/driver.h    |  10 +++
 13 files changed, 228 insertions(+), 130 deletions(-)
---
base-commit: df5d6180169ae06a2eac57e33b077ad6f6252440
change-id: 20250210-gpio-set-retval-41cd6baeead3

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2025-02-17  7:49 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-11 12:09 [PATCH 00/14] gpiolib: indicate errors in value setters Bartosz Golaszewski
2025-02-11 12:09 ` [PATCH 01/14] gpiolib: make value setters have return values Bartosz Golaszewski
2025-02-12  8:03   ` kernel test robot
2025-02-12 13:26   ` kernel test robot
2025-02-12 13:57   ` kernel test robot
2025-02-14  9:24     ` Bartosz Golaszewski
2025-02-11 12:09 ` [PATCH 02/14] gpiolib: wrap gpio_chip::set() Bartosz Golaszewski
2025-02-11 12:09 ` [PATCH 03/14] gpiolib: rework the wrapper around gpio_chip::set_multiple() Bartosz Golaszewski
2025-02-11 12:09 ` [PATCH 04/14] gpiolib: introduce gpio_chip setters that return values Bartosz Golaszewski
2025-02-11 12:09 ` [PATCH 05/14] gpio: sim: use value returning setters Bartosz Golaszewski
2025-02-11 12:09 ` [PATCH 06/14] gpio: regmap: " Bartosz Golaszewski
2025-02-17  7:49   ` Michael Walle
2025-02-11 12:09 ` [PATCH 07/14] gpio: pca953x: " Bartosz Golaszewski
2025-02-11 12:09 ` [PATCH 08/14] gpio: mockup: " Bartosz Golaszewski
2025-02-11 12:09 ` [PATCH 09/14] gpio: aggregator: " Bartosz Golaszewski
2025-02-11 12:09 ` [PATCH 10/14] gpio: max77650: " Bartosz Golaszewski
2025-02-11 12:09 ` [PATCH 11/14] gpio: latch: use lock guards Bartosz Golaszewski
2025-02-11 12:09 ` [PATCH 12/14] gpio: latch: use value returning setters Bartosz Golaszewski
2025-02-11 12:09 ` [PATCH 13/14] gpio: davinci: " Bartosz Golaszewski
2025-02-11 12:09 ` [PATCH 14/14] gpio: mvebu: " Bartosz Golaszewski
2025-02-14  9:56 ` [PATCH 00/14] gpiolib: indicate errors in value setters Linus Walleij
2025-02-14 10:14   ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).