public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] i2c: mux: don't access GPIOLIB internal structures
@ 2023-10-11 13:02 Bartosz Golaszewski
  2023-10-11 13:02 ` [PATCH 1/3] gpiolib: provide gpio_device_to_device() Bartosz Golaszewski
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Bartosz Golaszewski @ 2023-10-11 13:02 UTC (permalink / raw)
  To: Linus Walleij, Andy Shevchenko, Peter Korsgaard, Peter Rosin
  Cc: linux-gpio, linux-kernel, linux-i2c, Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

The backstory for this short series is that we are identyfing and
removing all unauthorized uses of GPIOLIB structures across the kernel.

For example: there are many users that access struct gpio_chip when the
only user allowed to safely do this is the provider of that chip.

We are very close to removing gpiochip_find(). Another function that
poses a similar problem is gpiod_to_chip() which also returns the
address of the underlying gpio_chip without assuring that it will not go
away e.g. due to a hot-unplug event or a device unbind.

We'll need to replace it with gpiod_to_gpio_device() across the entire
tree. Let's start by actually providing it and adding the first user:
the i2c-mux-gpio driver which dereferences the otherwise opaque struct
gpio_desc.

Let's also add a helper that allows to retrieve the address of the
struct device backing the GPIO device as this is another valid use-case.

Finally, let's un-include the GPIO private header and fix the code to
access the device in a safe way.

As the change is pretty minor, it would be best if patch 3/3 could be
acked by the I2C mux maintainers and went through the GPIO tree.
Otherwise, I can apply patches 1 and 2 and provide an immutable branch.

Bartosz Golaszewski (3):
  gpiolib: provide gpio_device_to_device()
  gpiolib: provide gpiod_to_gpio_device()
  i2c: mux: gpio: don't fiddle with GPIOLIB internals

 drivers/gpio/gpiolib.c           | 38 ++++++++++++++++++++++++++++++++
 drivers/i2c/muxes/i2c-mux-gpio.c | 12 +++++-----
 include/linux/gpio/driver.h      |  3 +++
 3 files changed, 47 insertions(+), 6 deletions(-)

-- 
2.39.2


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

end of thread, other threads:[~2023-10-13  6:50 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-11 13:02 [PATCH 0/3] i2c: mux: don't access GPIOLIB internal structures Bartosz Golaszewski
2023-10-11 13:02 ` [PATCH 1/3] gpiolib: provide gpio_device_to_device() Bartosz Golaszewski
2023-10-11 14:57   ` Peter Rosin
2023-10-11 15:18   ` Andy Shevchenko
2023-10-11 13:02 ` [PATCH 2/3] gpiolib: provide gpiod_to_gpio_device() Bartosz Golaszewski
2023-10-11 14:58   ` Peter Rosin
2023-10-11 15:23   ` Andy Shevchenko
2023-10-11 15:39     ` Bartosz Golaszewski
2023-10-12  6:57       ` Linus Walleij
2023-10-11 15:28   ` Andy Shevchenko
2023-10-11 13:02 ` [PATCH 3/3] i2c: mux: gpio: don't fiddle with GPIOLIB internals Bartosz Golaszewski
2023-10-11 14:59   ` Peter Rosin
2023-10-11 15:03     ` Bartosz Golaszewski
2023-10-11 16:41       ` Wolfram Sang
2023-10-11 15:18     ` Andy Shevchenko
2023-10-12  6:59 ` [PATCH 0/3] i2c: mux: don't access GPIOLIB internal structures Linus Walleij
2023-10-13  6:50 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox