[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250211-gpio-set-retval-v1-0-52d3d613d7d3@linaro.org>
Date: Tue, 11 Feb 2025 13:09:34 +0100
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <brgl@...ev.pl>, Michael Walle <mwalle@...nel.org>,
Bamvor Jian Zhang <bamv2005@...il.com>,
Geert Uytterhoeven <geert+renesas@...der.be>, Keerthy <j-keerthy@...com>,
Uwe Kleine-König <ukleinek@...nel.org>
Cc: linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-pwm@...r.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Subject: [PATCH 00/14] gpiolib: indicate errors in value setters
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@...aro.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@...aro.org>
Powered by blists - more mailing lists