linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] gpio: Hide and obey valid_mask
@ 2025-02-28 12:35 Matti Vaittinen
  2025-02-28 12:35 ` [PATCH v2 1/4] gpio: Respect valid_mask when requesting GPIOs Matti Vaittinen
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Matti Vaittinen @ 2025-02-28 12:35 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen
  Cc: Linus Walleij, Bartosz Golaszewski, linux-gpio, linux-kernel,
	Biju Das, Geert Uytterhoeven

[-- Attachment #1: Type: text/plain, Size: 1942 bytes --]

GPIO controllers may have some pins which can be excluded from the GPIO
usage on certain hardware configurations. The valid_mask member of the
struct gpio_chip has been used to denote usable pins if some pins should
be excluded.

The GPIO request should fail for GPIOs which are masked. Under certain
conditions this was only done when GPIO chip provided the 'request'
callback. We fix this to be always done.

The valid_mask member of the gpio_chip should no longer be directly
populated by the drivers but GPIO core does this (unconditionally,
overwriting any mask set directly by the drivers). Drivers are intended
to populate the valid_mask using the init_valid_mask -callback.

This series enforces using the init_valid_mask by hiding the valid_mask
in structure which is internal to the GPIO core. A single in-tree driver
was found to access the valid_mask directly. This series also removes
those direct accesses as has been discussed [1]. Additionally, we
introduce a getter-function which can be used to obtain the valid_mask.

[1]: https://lore.kernel.org/all/TY3PR01MB11346EC54C8672C4D28F931F686CC2@TY3PR01MB11346.jpnprd01.prod.outlook.com/

Revision history:
v1 => v2:
 - Hide the 'valid_mask' instead of documenting it to be internal
 - Make the gpio_request() to obey the valid_mask whether the gpio_chip
   has the 'request' -callback populated or not.

---

Matti Vaittinen (4):
  gpio: Respect valid_mask when requesting GPIOs
  gpio: Add a valid_mask getter
  gpio: gpio-rcar: Drop direct use of valid_mask
  gpio: Hide valid_mask from direct assignments

 drivers/gpio/gpio-rcar.c    | 13 +++++-------
 drivers/gpio/gpiolib.c      | 40 ++++++++++++++++++++++++++-----------
 drivers/gpio/gpiolib.h      |  3 +++
 include/linux/gpio/driver.h |  9 +--------
 4 files changed, 37 insertions(+), 28 deletions(-)


base-commit: d082ecbc71e9e0bf49883ee4afd435a77a5101b6
-- 
2.48.1


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2025-03-05  9:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-28 12:35 [PATCH v2 0/4] gpio: Hide and obey valid_mask Matti Vaittinen
2025-02-28 12:35 ` [PATCH v2 1/4] gpio: Respect valid_mask when requesting GPIOs Matti Vaittinen
2025-03-04  7:55   ` Linus Walleij
2025-02-28 12:35 ` [PATCH v2 2/4] gpio: Add a valid_mask getter Matti Vaittinen
2025-03-04  7:56   ` Linus Walleij
2025-02-28 12:36 ` [PATCH v2 3/4] gpio: gpio-rcar: Drop direct use of valid_mask Matti Vaittinen
2025-03-04  7:57   ` Linus Walleij
2025-02-28 12:36 ` [PATCH v2 4/4] gpio: Hide valid_mask from direct assignments Matti Vaittinen
2025-03-04  7:57   ` Linus Walleij
2025-03-05  9:03 ` [PATCH v2 0/4] gpio: Hide and obey valid_mask 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).