netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/15] gpiolib: add gpiod_multi_set_value_cansleep
@ 2025-02-10 22:33 David Lechner
  2025-02-10 22:33 ` [PATCH v3 01/15] gpiolib: add gpiod_multi_set_value_cansleep() David Lechner
                   ` (19 more replies)
  0 siblings, 20 replies; 50+ messages in thread
From: David Lechner @ 2025-02-10 22:33 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko,
	Geert Uytterhoeven, Lars-Peter Clausen, Michael Hennerich,
	Jonathan Cameron, Ulf Hansson, Peter Rosin, Andrew Lunn,
	Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Vinod Koul, Kishon Vijay Abraham I,
	Nuno Sá, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai
  Cc: linux-gpio, linux-kernel, linux-iio, linux-mmc, netdev, linux-phy,
	linux-sound, David Lechner, Andy Shevchenko, Jonathan Cameron

This series was inspired by some minor annoyance I have experienced a
few times in recent reviews.

Calling gpiod_set_array_value_cansleep() can be quite verbose due to
having so many parameters. In most cases, we already have a struct
gpio_descs that contains the first 3 parameters so we end up with 3 (or
often even 6) pointer indirections at each call site. Also, people have
a tendency to want to hard-code the first argument instead of using
struct gpio_descs.ndescs, often without checking that ndescs >= the
hard-coded value.

So I'm proposing that we add a gpiod_multi_set_value_cansleep()
function that is a wrapper around gpiod_set_array_value_cansleep()
that has struct gpio_descs as the first parameter to make it a bit
easier to read the code and avoid the hard-coding temptation.

I've just done gpiod_multi_set_value_cansleep() for now since there
were over 10 callers of this one. There aren't as many callers of
the get and atomic variants, but we can add those too if this seems
like a useful thing to do.

Maintainers, if you prefer to have this go through the gpio tree, please
give your Acked-by:. Several maintainers have also requested an
immutable branch, so I expect that will be made available. And if there
is anything leftover after the next kernel release, I will resend it.

---
Changes in v3:
- Added IS_ERR_OR_NULL() check to gpiod_multi_set_value_cansleep()
- Added new patches to clean up accessing bitmap directly (ts-nbus, ad2s1210).
- Added function prefix for max3191x.
- Removed unnecessary braces in ad7606 patch.
- Picked up additional trailers.
- Link to v2: https://lore.kernel.org/r/20250206-gpio-set-array-helper-v2-0-1c5f048f79c3@baylibre.com

Changes in v2:
- Renamed new function from gpiods_multi_set_value_cansleep() to
  gpiod_multi_set_value_cansleep()
- Fixed typo in name of replaced function in all commit messages.
- Picked up trailers.
- Link to v1: https://lore.kernel.org/r/20250131-gpio-set-array-helper-v1-0-991c8ccb4d6e@baylibre.com

---
David Lechner (15):
      gpiolib: add gpiod_multi_set_value_cansleep()
      auxdisplay: seg-led-gpio: use gpiod_multi_set_value_cansleep
      bus: ts-nbus: validate ts,data-gpios array size
      bus: ts-nbus: use gpiod_multi_set_value_cansleep
      bus: ts-nbus: use bitmap_get_value8()
      gpio: max3191x: use gpiod_multi_set_value_cansleep
      iio: adc: ad7606: use gpiod_multi_set_value_cansleep
      iio: amplifiers: hmc425a: use gpiod_multi_set_value_cansleep
      iio: resolver: ad2s1210: use gpiod_multi_set_value_cansleep
      iio: resolver: ad2s1210: use bitmap_write
      mmc: pwrseq_simple: use gpiod_multi_set_value_cansleep
      mux: gpio: use gpiod_multi_set_value_cansleep
      net: mdio: mux-gpio: use gpiod_multi_set_value_cansleep
      phy: mapphone-mdm6600: use gpiod_multi_set_value_cansleep
      ASoC: adau1701: use gpiod_multi_set_value_cansleep

 drivers/auxdisplay/seg-led-gpio.c           |  3 +--
 drivers/bus/ts-nbus.c                       | 15 +++++++++------
 drivers/gpio/gpio-max3191x.c                | 18 +++++++-----------
 drivers/iio/adc/ad7606.c                    |  3 +--
 drivers/iio/adc/ad7606_spi.c                |  7 +++----
 drivers/iio/amplifiers/hmc425a.c            |  3 +--
 drivers/iio/resolver/ad2s1210.c             | 13 +++++--------
 drivers/mmc/core/pwrseq_simple.c            |  3 +--
 drivers/mux/gpio.c                          |  4 +---
 drivers/net/mdio/mdio-mux-gpio.c            |  3 +--
 drivers/phy/motorola/phy-mapphone-mdm6600.c |  4 +---
 include/linux/gpio/consumer.h               | 11 +++++++++++
 sound/soc/codecs/adau1701.c                 |  4 +---
 13 files changed, 43 insertions(+), 48 deletions(-)
---
base-commit: df4b2bbff898227db0c14264ac7edd634e79f755
change-id: 20250131-gpio-set-array-helper-bd4a328370d3

Best regards,
-- 
David Lechner <dlechner@baylibre.com>


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

end of thread, other threads:[~2025-02-22 11:51 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-10 22:33 [PATCH v3 00/15] gpiolib: add gpiod_multi_set_value_cansleep David Lechner
2025-02-10 22:33 ` [PATCH v3 01/15] gpiolib: add gpiod_multi_set_value_cansleep() David Lechner
2025-02-11  7:35   ` Geert Uytterhoeven
2025-02-11  9:39   ` Andy Shevchenko
2025-02-14  9:22   ` Linus Walleij
2025-02-10 22:33 ` [PATCH v3 02/15] auxdisplay: seg-led-gpio: use gpiod_multi_set_value_cansleep David Lechner
2025-02-12 10:51   ` Andy Shevchenko
2025-02-10 22:33 ` [PATCH v3 03/15] bus: ts-nbus: validate ts,data-gpios array size David Lechner
2025-02-10 22:33 ` [PATCH v3 04/15] bus: ts-nbus: use gpiod_multi_set_value_cansleep David Lechner
2025-02-10 22:33 ` [PATCH v3 05/15] bus: ts-nbus: use bitmap_get_value8() David Lechner
2025-02-11  9:40   ` Andy Shevchenko
2025-02-20 10:17   ` Simon Horman
2025-02-20 12:06     ` Andy Shevchenko
2025-02-20 17:16       ` David Lechner
2025-02-20 17:32     ` David Lechner
2025-02-21  9:24       ` Simon Horman
2025-02-10 22:33 ` [PATCH v3 06/15] gpio: max3191x: use gpiod_multi_set_value_cansleep David Lechner
2025-02-11  9:42   ` Andy Shevchenko
2025-02-10 22:33 ` [PATCH v3 07/15] iio: adc: ad7606: " David Lechner
2025-02-17 13:18   ` Jonathan Cameron
2025-02-10 22:33 ` [PATCH v3 08/15] iio: amplifiers: hmc425a: " David Lechner
2025-02-10 22:33 ` [PATCH v3 09/15] iio: resolver: ad2s1210: " David Lechner
2025-02-10 22:33 ` [PATCH v3 10/15] iio: resolver: ad2s1210: use bitmap_write David Lechner
2025-02-11 19:46   ` Jonathan Cameron
2025-02-20 20:54   ` David Lechner
2025-02-22 11:38     ` Jonathan Cameron
2025-02-22 11:51     ` Jonathan Cameron
2025-02-10 22:33 ` [PATCH v3 11/15] mmc: pwrseq_simple: use gpiod_multi_set_value_cansleep David Lechner
2025-02-10 22:33 ` [PATCH v3 12/15] mux: gpio: " David Lechner
2025-02-10 22:33 ` [PATCH v3 13/15] net: mdio: mux-gpio: " David Lechner
2025-02-10 22:33 ` [PATCH v3 14/15] phy: mapphone-mdm6600: " David Lechner
2025-02-13 17:21   ` Vinod Koul
2025-02-10 22:33 ` [PATCH v3 15/15] ASoC: adau1701: " David Lechner
2025-02-12  9:36 ` (subset) [PATCH v3 00/15] gpiolib: add gpiod_multi_set_value_cansleep Bartosz Golaszewski
2025-02-12  9:36 ` Bartosz Golaszewski
2025-02-13 17:25   ` David Lechner
2025-02-13 17:37     ` Andy Shevchenko
2025-02-13 17:42     ` Bartosz Golaszewski
2025-02-13 17:52       ` Mark Brown
2025-02-13 17:58         ` Bartosz Golaszewski
2025-02-13 18:04           ` Mark Brown
2025-02-13 18:26 ` Mark Brown
2025-02-14 10:20 ` Bartosz Golaszewski
2025-02-14 14:35   ` Andy Shevchenko
2025-02-14 14:37     ` Bartosz Golaszewski
2025-02-16 14:23       ` Jonathan Cameron
2025-02-16 15:55         ` Bartosz Golaszewski
2025-02-17 13:11           ` Jonathan Cameron
2025-02-17 13:24             ` Bartosz Golaszewski
2025-02-17 13:21 ` Jonathan Cameron

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).