pinctrl: stop using gpiod_to_chip()

Don't dereference struct gpio_chip directly, use dedicated gpio_device
getters instead.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20231115165001.2932350-3-brgl@bgdev.pl
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Bartosz Golaszewski 2023-11-15 17:50:00 +01:00 committed by Linus Walleij
parent 16048722db
commit 524fc108b8

View File

@ -13,6 +13,7 @@
#define pr_fmt(fmt) "pinctrl core: " fmt #define pr_fmt(fmt) "pinctrl core: " fmt
#include <linux/array_size.h> #include <linux/array_size.h>
#include <linux/cleanup.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/err.h> #include <linux/err.h>
@ -1649,8 +1650,8 @@ static int pinctrl_pins_show(struct seq_file *s, void *what)
const struct pinctrl_ops *ops = pctldev->desc->pctlops; const struct pinctrl_ops *ops = pctldev->desc->pctlops;
unsigned i, pin; unsigned i, pin;
#ifdef CONFIG_GPIOLIB #ifdef CONFIG_GPIOLIB
struct gpio_device *gdev __free(gpio_device_put) = NULL;
struct pinctrl_gpio_range *range; struct pinctrl_gpio_range *range;
struct gpio_chip *chip;
int gpio_num; int gpio_num;
#endif #endif
@ -1685,11 +1686,11 @@ static int pinctrl_pins_show(struct seq_file *s, void *what)
* we need to get rid of the range->base eventually and * we need to get rid of the range->base eventually and
* get the descriptor directly from the gpio_chip. * get the descriptor directly from the gpio_chip.
*/ */
chip = gpiod_to_chip(gpio_to_desc(gpio_num)); gdev = gpiod_to_gpio_device(gpio_to_desc(gpio_num));
else if (gdev)
chip = NULL; seq_printf(s, "%u:%s ",
if (chip) gpio_num - gpio_device_get_base(gdev),
seq_printf(s, "%u:%s ", gpio_num - chip->gpiodev->base, chip->label); gpio_device_get_label(gdev));
else else
seq_puts(s, "0:? "); seq_puts(s, "0:? ");
#endif #endif