pinctrl: don't use gpiod_to_chip()
Subsystems (2)
cover pinctrl: don't use gpiod_to_chip()
From: Bartosz Golaszewski <[email protected]>
Let's start working towards removing gpiod_to_chip() from the kernel. Start with pinctrl. The first patch should go through the GPIO tree and become available through an immutable tag so that we can get more conversions in this cycle elsewhere.
Bartosz Golaszewski (3):
gpiolib: provide gpio_devie_get_label()
pinctrl: stop using gpiod_to_chip()
pinctrl: don't include GPIOLIB private header
drivers/gpio/gpiolib.c | 14 ++++++++++++++ drivers/pinctrl/core.c | 18 ++++++++---------- include/linux/gpio/driver.h | 1 + 3 files changed, 23 insertions(+), 10 deletions(-)
Signature · 1 line
2.40.1
PATCH 1/3 gpiolib: provide gpio_devie_get_label()
From: Bartosz Golaszewski <[email protected]>
Provide a getter for the GPIO device label string so that users don't have to dereference struct gpio_chip directly.
--- drivers/gpio/gpiolib.c | 14 ++++++++++++++ include/linux/gpio/driver.h | 1 + 2 files changed, 15 insertions(+)
drivers/gpio/gpiolib.c +14 -0
@@ -254,6 +254,20 @@ int gpio_device_get_base(struct gpio_device *gdev) }EXPORT_SYMBOL_GPL (gpio_device_get_base); +/** +* gpio_device_get_label() - Get the label of this GPIO device +* @gdev: GPIO device +* +* Returns: +* Pointer to the string containing the GPIO device label. The string's +* lifetime is tied to that of the underlying GPIO device. +*/ +const char *gpio_device_get_label (struct gpio_device *gdev) +{ +return gdev->label; +} +EXPORT_SYMBOL (gpio_device_get_label); +/** * gpio_device_get_chip() - Get the gpio_chip implementation of this GPIO device * @gdev: GPIO device
include/linux/gpio/driver.h +1 -0
@@ -786,6 +786,7 @@ struct gpio_device *gpiod_to_gpio_device(struct gpio_desc *desc);/* struct gpio_device getters */ int gpio_device_get_base (struct gpio_device *gdev); +const char *gpio_device_get_label (struct gpio_device *gdev);#else /* CONFIG_GPIOLIB */
Signature · 1 line
2.40.1
PATCH 2/3 pinctrl: stop using gpiod_to_chip()
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Don't dereference struct gpio_chip directly, use dedicated gpio_device getters instead.
--- drivers/pinctrl/core.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/pinctrl/core.c +7 -6
@@ -13,6 +13,7 @@#define pr_fmt (fmt) "pinctrl core: " fmt#include <linux/array_size.h> +#include <linux/cleanup.h> #include <linux/debugfs.h> #include <linux/device.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;unsigned i, pin;#ifdef CONFIG_GPIOLIB + struct gpio_device *gdev __free(gpio_device_put) = NULL;struct pinctrl_gpio_range *range; -struct gpio_chip *chip;int gpio_num;#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 * get the descriptor directly from the gpio_chip. */ - chip =gpiod_to_chip (gpio_to_desc (gpio_num)); - else - chip =NULL ; -if (chip) -seq_printf (s,"%u:%s " , gpio_num - chip->gpiodev->base, chip->label); + gdev =gpiod_to_gpio_device (gpio_to_desc (gpio_num)); +if (gdev) +seq_printf (s,"%u:%s " , + gpio_num -gpio_device_get_base (gdev), +gpio_device_get_label (gdev));else seq_puts (s,"0:? " );#endif
Signature · 1 line
2.40.1
PATCH 3/3 pinctrl: don't include GPIOLIB private header
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
gpio_to_desc() is declared in linux/gpio.h so there's no need to include gpiolib.h directly.
--- drivers/pinctrl/core.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/pinctrl/core.c +1 -4
@@ -24,6 +24,7 @@#include <linux/seq_file.h> #include <linux/slab.h> +#include <linux/gpio.h> #include <linux/gpio/driver.h> #include <linux/pinctrl/consumer.h>
@@ -31,10 +32,6 @@#include <linux/pinctrl/machine.h> #include <linux/pinctrl/pinctrl.h> -#ifdef CONFIG_GPIOLIB -#include "../gpio/gpiolib.h" -#endif -#include "core.h" #include "devicetree.h" #include "pinconf.h"
Signature · 1 line
2.40.1
Re: [PATCH 3/3] pinctrl: don't include GPIOLIB private header
Quoted 4 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
gpio_to_desc()is declared inlinux/gpio.hso there's no need to includegpiolib.hdirectly.
Oh, this is unfortunate we need it...
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 6 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Let's start working towards removing
gpiod_to_chip()from the kernel. Start with pinctrl. The first patch should go through the GPIO tree and become available through an immutable tag so that we can get more conversions in this cycle elsewhere.
Fair enough, maybe an immutable branch with all three patches? Probably best to merga all three into both subsystems I think.
Yours,
Linus Walleij
Quoted 5 lines · Linus Walleij
Quoted 2 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Quoted 8 lines
Quoted 4 lines
Let's start working towards removing
gpiod_to_chip()from the kernel. Start with pinctrl. The first patch should go through the GPIO tree and become available through an immutable tag so that we can get more conversions in this cycle elsewhere.Fair enough, maybe an immutable branch with all three patches? Probably best to merga all three into both subsystems I think.
Nah, I don't think I need to pollute the GPIO tree with every pinctrl patch. It's enough to just merge the first one into GPIO and you do the same in pinctrl.
Bart
Quoted 4 lines
Acked-by Linus Walleij <[email protected]>Yours,
Linus Walleij
Quoted 10 lines · Bartosz Golaszewski
Quoted 9 lines · Linus Walleij
Quoted 6 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Let's start working towards removing
gpiod_to_chip()from the kernel. Start with pinctrl. The first patch should go through the GPIO tree and become available through an immutable tag so that we can get more conversions in this cycle elsewhere.
Quoted 7 lines
Quoted 3 lines
Fair enough, maybe an immutable branch with all three patches? Probably best to merga all three into both subsystems I think.
Nah, I don't think I need to pollute the GPIO tree with every pinctrl patch. It's enough to just merge the first one into GPIO and you do the same in pinctrl.
Fair enough, but I need that immutable branch for patch 1 so I can merge the rest on top.
Yours,
Linus Walleij
Quoted 20 lines · Linus Walleij
Quoted 10 lines · Bartosz Golaszewski
Quoted 9 lines · Linus Walleij
Quoted 6 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Let's start working towards removing
gpiod_to_chip()from the kernel. Start with pinctrl. The first patch should go through the GPIO tree and become available through an immutable tag so that we can get more conversions in this cycle elsewhere.Quoted 7 lines
Quoted 3 lines
Fair enough, maybe an immutable branch with all three patches? Probably best to merga all three into both subsystems I think.
Nah, I don't think I need to pollute the GPIO tree with every pinctrl patch. It's enough to just merge the first one into GPIO and you do the same in pinctrl.
Quoted 5 lines
Fair enough, but I need that immutable branch for patch 1 so I can merge the rest on top.
Yours,
Linus Walleij
I applied the first patch (after fixing the typo in the commit message) and sent you the immutable branch to pull. Please apply the remaining patches to the pinctrl tree directly.
Thanks!
Bart
Quoted 24 lines · Bartosz Golaszewski
Quoted 23 lines · Linus Walleij
Quoted 10 lines · Bartosz Golaszewski
Quoted 9 lines · Linus Walleij
Quoted 6 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Let's start working towards removing
gpiod_to_chip()from the kernel. Start with pinctrl. The first patch should go through the GPIO tree and become available through an immutable tag so that we can get more conversions in this cycle elsewhere.Quoted 7 lines
Quoted 3 lines
Fair enough, maybe an immutable branch with all three patches? Probably best to merga all three into both subsystems I think.
Nah, I don't think I need to pollute the GPIO tree with every pinctrl patch. It's enough to just merge the first one into GPIO and you do the same in pinctrl.
Fair enough, but I need that immutable branch for patch 1 so I can merge the rest on top.
Quoted 6 lines
Quoted 2 lines
Yours,
Linus WalleijI applied the first patch (after fixing the typo in the commit message) and sent you the immutable branch to pull. Please apply the remaining patches to the pinctrl tree directly.
Pulled it and applied the other two patches on top, thanks!
Yours,
Linus Walleij