gpiolib: of: remove of_gpio_count()
Subsystems (2)
PATCH 1/5 gpiolib: of: remove of_gpio_count()
There are no more users of of_gpio_count() in the mainline kernel, remove it.
---
After 6.2-rc1 there should be no more users of the APIs mentioned in this series.
include/linux/of_gpio.h | 11 ----------- 1 file changed, 11 deletions(-)
include/linux/of_gpio.h +0 -11
@@ -105,17 +105,6 @@ static inline int of_gpio_named_count(const struct device_node *np,return of_count_phandle_with_args (np, propname,"#gpio-cells" ); } -/** -* of_gpio_count() - Count GPIOs for a device -* @np: device node to count GPIOs for -* -* Same as of_gpio_named_count, but hard coded to use the 'gpios' property -*/ -static inline int of_gpio_count (const struct device_node *np) -{ -return of_gpio_named_count (np,"gpios" ); -} -static inline int of_get_gpio_flags (const struct device_node *np,int index,enum of_gpio_flags *flags) {
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
PATCH 2/5 gpiolib: of: stop exporting of_gpio_named_count()
The only user of this function is gpiolib-of.c so move it there.
--- drivers/gpio/gpiolib-of.c | 26 ++++++++++++++++++++++++++ include/linux/of_gpio.h | 26 -------------------------- 2 files changed, 26 insertions(+), 26 deletions(-)
drivers/gpio/gpiolib-of.c +26 -0
@@ -23,6 +23,32 @@#include "gpiolib.h" #include "gpiolib-of.h" +/** +* of_gpio_named_count() - Count GPIOs for a device +* @np: device node to count GPIOs for +* @propname: property name containing gpio specifier(s) +* +* The function returns the count of GPIOs specified for a node. +* Note that the empty GPIO specifiers count too. Returns either +* Number of gpios defined in property, +* -EINVAL for an incorrectly formed gpios property, or +* -ENOENT for a missing gpios property +* +* Example: +* gpios = <0 +* &gpio1 1 2 +* 0 +* &gpio2 3 4>; +* +* The above example defines four GPIOs, two of which are not specified. +* This function will return '4' +*/ +static int of_gpio_named_count (const struct device_node *np, +const char *propname) +{ +return of_count_phandle_with_args (np, propname,"#gpio-cells" ); +} +/** * of_gpio_spi_cs_get_count() - special GPIO counting for SPI * @dev: Consuming device
include/linux/of_gpio.h +0 -26
@@ -79,32 +79,6 @@ static inline int of_get_named_gpio_flags(const struct device_node *np,#endif /* CONFIG_OF_GPIO */ -/** -* of_gpio_named_count() - Count GPIOs for a device -* @np: device node to count GPIOs for -* @propname: property name containing gpio specifier(s) -* -* The function returns the count of GPIOs specified for a node. -* Note that the empty GPIO specifiers count too. Returns either -* Number of gpios defined in property, -* -EINVAL for an incorrectly formed gpios property, or -* -ENOENT for a missing gpios property -* -* Example: -* gpios = <0 -* &gpio1 1 2 -* 0 -* &gpio2 3 4>; -* -* The above example defines four GPIOs, two of which are not specified. -* This function will return '4' -*/ -static inline int of_gpio_named_count (const struct device_node *np, -const char *propname) -{ -return of_count_phandle_with_args (np, propname,"#gpio-cells" ); -} -static inline int of_get_gpio_flags (const struct device_node *np,int index,enum of_gpio_flags *flags) {
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Re: [PATCH 2/5] gpiolib: of: stop exporting of_gpio_named_count()
Quoted 1 line · Dmitry Torokhov
The only user of this function is
gpiolib-of.cso move it there.
It's one liner used a single file, can we kill it completely?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 2/5] gpiolib: of: stop exporting of_gpio_named_count()
Quoted 4 lines · Andy Shevchenko
Quoted 1 line · Dmitry Torokhov
The only user of this function is
gpiolib-of.cso move it there.It's one liner used a single file, can we kill it completely?
It is being called from a couple of places there and documents how exactly we are counting GPIOs, so I would prefer to leave this helper as is.
Thanks.
Signature · 1 line
Dmitry
Andy Shevchenko
Reviewed-byRe: [PATCH 2/5] gpiolib: of: stop exporting of_gpio_named_count()
Quoted 9 lines · Dmitry Torokhov
Quoted 4 lines · Andy Shevchenko
Quoted 1 line · Dmitry Torokhov
The only user of this function is
gpiolib-of.cso move it there.It's one liner used a single file, can we kill it completely?
It is being called from a couple of places there and documents how exactly we are counting GPIOs, so I would prefer to leave this helper as is.
Fair enough. However I think that even so it may be killed in the future.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 3/5 gpiolib: of: remove obsolete comment for of_gpio_get_count()
In reply to Dmitry TorokhovThe function is only being called form the main gpiolib module, so remove comment saying that it is also used by external callers.
--- drivers/gpio/gpiolib-of.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/gpio/gpiolib-of.c +0 -6
@@ -76,12 +76,6 @@ static int of_gpio_spi_cs_get_count(struct device *dev, const char *con_id)return of_gpio_named_count (np,"gpios" ); } -/* -* This is used by external users of of_gpio_count() from <linux/of_gpio.h> -* -* FIXME: get rid of those external users by converting them to GPIO -* descriptors and let them all use gpiod_count() -*/ int of_gpio_get_count (struct device *dev,const char *con_id) {int ret;
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Re: [PATCH 3/5] gpiolib: of: remove obsolete comment for of_gpio_get_count()
Quoted 2 lines · Dmitry Torokhov
The function is only being called form the main gpiolib module, so remove comment saying that it is also used by external callers.
Quoted 25 lines
Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/gpio/gpiolib-of.c | 6 ------ 1 file changed, 6 deletions(-)drivers/gpio/gpiolib-of.c +0
-6@@ -76,12 +76,6 @@ static int of_gpio_spi_cs_get_count(struct device *dev, const char *con_id)return of_gpio_named_count (np,"gpios" ); } -/* -* This is used by external users of of_gpio_count() from <linux/of_gpio.h> -* -* FIXME: get rid of those external users by converting them to GPIO -* descriptors and let them all use gpiod_count() -*/ int of_gpio_get_count (struct device *dev,const char *con_id) {int ret;Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 3/5] gpiolib: of: remove obsolete comment for of_gpio_get_count()
In reply to Dmitry TorokhovQuoted 4 lines · Dmitry Torokhov
The function is only being called form the main gpiolib module, so remove comment saying that it is also used by external callers.
Signed-off-by Dmitry Torokhov <[email protected]>
BTW: good work on this, much appreciated!
Yours,
Linus Walleij
PATCH 4/5 gpiolib: of: remove of_get_gpio[_flags]() and of_get_named_gpio_flags()
In reply to Dmitry TorokhovThere are no more users of these APIs in the mainline kernel, remove them. This leaves of_get_named_gpio() as the only legacy OF-specific API.
--- drivers/gpio/gpiolib-of.c | 17 +++++++++++---- include/linux/of_gpio.h | 45 ++++----------------------------------- 2 files changed, 17 insertions(+), 45 deletions(-)
drivers/gpio/gpiolib-of.c +13 -4
@@ -365,19 +365,28 @@ static struct gpio_desc *of_get_named_gpiod_flags(const struct device_node *np,return desc; } -int of_get_named_gpio_flags (const struct device_node *np,const char *list_name, -int index,enum of_gpio_flags *flags) +/** +* of_get_named_gpio() - Get a GPIO number to use with GPIO API +* @np: device node to get GPIO from +* @propname: Name of property containing gpio specifier(s) +* @index: index of the GPIO +* +* Returns GPIO number to use with Linux generic GPIO API, or one of the errno +* value on the error condition. +*/ +int of_get_named_gpio (const struct device_node *np,const char *propname, +int index) {struct gpio_desc *desc; - desc =of_get_named_gpiod_flags (np, list_name, index, flags); + desc =of_get_named_gpiod_flags (np, propname, index,NULL );if (IS_ERR (desc))return PTR_ERR (desc);else return desc_to_gpio (desc); } -EXPORT_SYMBOL_GPL (of_get_named_gpio_flags); +EXPORT_SYMBOL_GPL (of_get_named_gpio);/* Converts gpio_lookup_flags into bitmask of GPIO_* values */ static unsigned long of_convert_gpio_flags (enum of_gpio_flags flags)
include/linux/of_gpio.h +4 -41
61 lines not on this page · raw message
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Re: [PATCH 4/5] gpiolib: of: remove of_get_gpio[_flags]() and of_get_named_gpio_flags()
Quoted 3 lines · Dmitry Torokhov
There are no more users of these APIs in the mainline kernel, remove them. This leaves
of_get_named_gpio()as the only legacy OF-specific API.
...
drivers/gpio/gpiolib-of.c static struct gpio_desc *of_get_named_gpiod_flags(const struct device_node *np, · line 382
Quoted 2 lines
drivers/gpio/gpiolib-of.c +1
-1- desc =of_get_named_gpiod_flags (np, list_name, index, flags); + desc =of_get_named_gpiod_flags (np, propname, index,NULL );
I didn't get it. The commit message and the subject says there are no more users of these APIs, why is it still here? How is it compiled?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 4/5] gpiolib: of: remove of_get_gpio[_flags]() and of_get_named_gpio_flags()
Quoted 5 lines · Andy Shevchenko
Quoted 3 lines · Dmitry Torokhov
There are no more users of these APIs in the mainline kernel, remove them. This leaves
of_get_named_gpio()as the only legacy OF-specific API.
Quoted 7 lines
...
drivers/gpio/gpiolib-of.c static struct gpio_desc *of_get_named_gpiod_flags(const struct device_node *np, · line 382
Quoted 2 lines
drivers/gpio/gpiolib-of.c +1
-1- desc =of_get_named_gpiod_flags (np, list_name, index, flags); + desc =of_get_named_gpiod_flags (np, propname, index,NULL );I didn't get it. The commit message and the subject says there are no more users of these APIs, why is it still here? How is it compiled?
gpio vs gpiod strikes again ;) We are removing of_get_named_gpio_flags(), but of_get_named_gpiod_flags() is a local helper in gpiolib-of.c and is still very much in use there and I have no plans removing it.
Thanks.
Signature · 1 line
Dmitry
Andy Shevchenko
Reviewed-byRe: [PATCH 4/5] gpiolib: of: remove of_get_gpio[_flags]() and of_get_named_gpio_flags()
Quoted 5 lines · Dmitry Torokhov
Quoted 4 lines · Andy Shevchenko
Quoted 3 lines · Dmitry Torokhov
There are no more users of these APIs in the mainline kernel, remove them. This leaves
of_get_named_gpio()as the only legacy OF-specific API.
...
Quoted 10 lines
Quoted 5 lines
drivers/gpio/gpiolib-of.c static struct gpio_desc *of_get_named_gpiod_flags(const struct device_node *np, · line 382
Quoted 2 lines
drivers/gpio/gpiolib-of.c +1
-1- desc =of_get_named_gpiod_flags (np, list_name, index, flags); + desc =of_get_named_gpiod_flags (np, propname, index,NULL );I didn't get it. The commit message and the subject says there are no more users of these APIs, why is it still here? How is it compiled?
gpio vs gpiod strikes again ;) We are removing
of_get_named_gpio_flags(), butof_get_named_gpiod_flags()is a local helper ingpiolib-of.cand is still very much in use there and I have no plans removing it.
Right, thank you for clarification.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 5/5 gpiolib: of: remove [devm_]gpiod_get_from_of_node() APIs
In reply to Dmitry TorokhovNow that everyone is using [devm_]fwnode_gpiod_get[_index]() APIs, remove OF-specific [devm_]gpiod_get_from_of_node().
--- drivers/gpio/gpiolib-devres.c | 55 ----------------------------------- drivers/gpio/gpiolib-of.c | 46 ----------------------------- include/linux/gpio/consumer.h | 48 ------------------------------ 3 files changed, 149 deletions(-)
drivers/gpio/gpiolib-devres.c +0 -55
@@ -129,61 +129,6 @@ struct gpio_desc *__must_check devm_gpiod_get_index(struct device *dev, }EXPORT_SYMBOL_GPL (devm_gpiod_get_index); -/** -* devm_gpiod_get_from_of_node() - obtain a GPIO from an OF node -* @dev: device for lifecycle management -* @node: handle of the OF node -* @propname: name of the DT property representing the GPIO -* @index: index of the GPIO to obtain for the consumer -* @dflags: GPIO initialization flags -* @label: label to attach to the requested GPIO -* -* Returns: -* On successful request the GPIO pin is configured in accordance with -* provided @dflags. -* -* In case of error an ERR_PTR() is returned. -*/ -struct gpio_desc *devm_gpiod_get_from_of_node (struct device *dev, -const struct device_node *node, -const char *propname,int index, -enum gpiod_flags dflags, -const char *label) -{ -struct gpio_desc **dr; -struct gpio_desc *desc; - - desc =gpiod_get_from_of_node (node, propname, index, dflags, label); -if (IS_ERR (desc)) -return desc; - -/* -* For non-exclusive GPIO descriptors, check if this descriptor is -* already under resource management by this device. -*/ -if (dflags &GPIOD_FLAGS_BIT_NONEXCLUSIVE ) { -struct devres *dres; - - dres =devres_find (dev, devm_gpiod_release, - devm_gpiod_match, &desc); -if (dres) -return desc; - } - - dr =devres_alloc (devm_gpiod_release,sizeof (struct gpio_desc *), -GFP_KERNEL ); -if (!dr) { -gpiod_put (desc); -return ERR_PTR (-ENOMEM ); - } - - *dr = desc; -devres_add (dev, dr); - -return desc; -} -EXPORT_SYMBOL_GPL (devm_gpiod_get_from_of_node); -/** * devm_fwnode_gpiod_get_index - get a GPIO descriptor from a given node * @dev: GPIO consumer
drivers/gpio/gpiolib-of.c +0 -46
52 lines not on this page · raw message
include/linux/gpio/consumer.h +0 -48
54 lines not on this page · raw message
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Re: [PATCH 5/5] gpiolib: of: remove [devm_]gpiod_get_from_of_node() APIs
Quoted 2 lines · Dmitry Torokhov
Now that everyone is using [devm_]fwnode_gpiod_get[_index]() APIs, remove OF-specific [devm_]gpiod_get_from_of_node().
I very much in favour of this change!
But the same question reminds, how this is possible to exists with the removed of_get_named_gpiod_flags()?
Quoted 192 lines
Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/gpio/gpiolib-devres.c | 55 ----------------------------------- drivers/gpio/gpiolib-of.c | 46 ----------------------------- include/linux/gpio/consumer.h | 48 ------------------------------ 3 files changed, 149 deletions(-)drivers/gpio/gpiolib-devres.c +0
-55@@ -129,61 +129,6 @@ struct gpio_desc *__must_check devm_gpiod_get_index(struct device *dev, }EXPORT_SYMBOL_GPL (devm_gpiod_get_index); -/** -* devm_gpiod_get_from_of_node() - obtain a GPIO from an OF node -* @dev: device for lifecycle management -* @node: handle of the OF node -* @propname: name of the DT property representing the GPIO -* @index: index of the GPIO to obtain for the consumer -* @dflags: GPIO initialization flags -* @label: label to attach to the requested GPIO -* -* Returns: -* On successful request the GPIO pin is configured in accordance with -* provided @dflags. -* -* In case of error an ERR_PTR() is returned. -*/ -struct gpio_desc *devm_gpiod_get_from_of_node (struct device *dev, -const struct device_node *node, -const char *propname,int index, -enum gpiod_flags dflags, -const char *label) -{ -struct gpio_desc **dr; -struct gpio_desc *desc; - - desc =gpiod_get_from_of_node (node, propname, index, dflags, label); -if (IS_ERR (desc)) -return desc; - -/* -* For non-exclusive GPIO descriptors, check if this descriptor is -* already under resource management by this device. -*/ -if (dflags &GPIOD_FLAGS_BIT_NONEXCLUSIVE ) { -struct devres *dres; - - dres =devres_find (dev, devm_gpiod_release, - devm_gpiod_match, &desc); -if (dres) -return desc; - } - - dr =devres_alloc (devm_gpiod_release,sizeof (struct gpio_desc *), -GFP_KERNEL ); -if (!dr) { -gpiod_put (desc); -return ERR_PTR (-ENOMEM ); - } - - *dr = desc; -devres_add (dev, dr); - -return desc; -} -EXPORT_SYMBOL_GPL (devm_gpiod_get_from_of_node); -/** * devm_fwnode_gpiod_get_index - get a GPIO descriptor from a given node * @dev: GPIO consumer drivers/gpio/gpiolib-of.c +0
-46@@ -418,52 +418,6 @@ static unsigned long of_convert_gpio_flags(enum of_gpio_flags flags)return lflags; } -/** -* gpiod_get_from_of_node() - obtain a GPIO from an OF node -* @node: handle of the OF node -* @propname: name of the DT property representing the GPIO -* @index: index of the GPIO to obtain for the consumer -* @dflags: GPIO initialization flags -* @label: label to attach to the requested GPIO -* -* Returns: -* On successful request the GPIO pin is configured in accordance with -* provided @dflags. -* -* In case of error an ERR_PTR() is returned. -*/ -struct gpio_desc *gpiod_get_from_of_node (const struct device_node *node, -const char *propname,int index, -enum gpiod_flags dflags, -const char *label) -{ -unsigned long lflags; -struct gpio_desc *desc; -enum of_gpio_flags of_flags; -int ret; - - desc =of_get_named_gpiod_flags (node, propname, index, &of_flags); -if (!desc ||IS_ERR (desc)) -return desc; - - ret =gpiod_request (desc, label); -if (ret == -EBUSY && (dflags &GPIOD_FLAGS_BIT_NONEXCLUSIVE )) -return desc; -if (ret) -return ERR_PTR (ret); - - lflags =of_convert_gpio_flags (of_flags); - - ret =gpiod_configure_flags (desc, propname, lflags, dflags); -if (ret <0 ) { -gpiod_put (desc); -return ERR_PTR (ret); - } - -return desc; -} -EXPORT_SYMBOL_GPL (gpiod_get_from_of_node); - static struct gpio_desc *of_find_gpio_rename(struct device_node *np, const char *con_id, unsigned int idx,include/linux/gpio/consumer.h +0
-48@@ -581,54 +581,6 @@ struct gpio_desc *devm_fwnode_gpiod_get(struct device *dev, flags, label); } -#if IS_ENABLED (CONFIG_GPIOLIB ) &&IS_ENABLED (CONFIG_OF_GPIO ) -struct device_node ; - -struct gpio_desc *gpiod_get_from_of_node (const struct device_node *node, -const char *propname,int index, -enum gpiod_flags dflags, -const char *label); - -#else /* CONFIG_GPIOLIB && CONFIG_OF_GPIO */ - -struct device_node ; - -static inline -struct gpio_desc *gpiod_get_from_of_node (const struct device_node *node, -const char *propname,int index, -enum gpiod_flags dflags, -const char *label) -{ -return ERR_PTR (-ENOSYS ); -} - -#endif /* CONFIG_GPIOLIB && CONFIG_OF_GPIO */ - -#ifdef CONFIG_GPIOLIB -struct device_node ; - -struct gpio_desc *devm_gpiod_get_from_of_node (struct device *dev, -const struct device_node *node, -const char *propname,int index, -enum gpiod_flags dflags, -const char *label); - -#else /* CONFIG_GPIOLIB */ - -struct device_node ; - -static inline -struct gpio_desc *devm_gpiod_get_from_of_node (struct device *dev, -const struct device_node *node, -const char *propname,int index, -enum gpiod_flags dflags, -const char *label) -{ -return ERR_PTR (-ENOSYS ); -} - -#endif /* CONFIG_GPIOLIB */ -struct acpi_gpio_params {unsigned int crs_entry_index;unsigned int line_index;Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 5/5] gpiolib: of: remove [devm_]gpiod_get_from_of_node() APIs
Quoted 10 lines · Andy Shevchenko
Quoted 2 lines · Dmitry Torokhov
Now that everyone is using [devm_]fwnode_gpiod_get[_index]() APIs, remove OF-specific [devm_]gpiod_get_from_of_node().
I very much in favour of this change!
Reviewed-by Andy Shevchenko <[email protected]>But the same question reminds, how this is possible to exists with the removed
of_get_named_gpiod_flags()?
As I mentioned in the other email of_get_named_gpiod_flags() is still present, it is of_get_named_gpio_flags (without the "d") that was removed.
Thanks.
Signature · 1 line
Dmitry
Quoted 2 lines · Dmitry Torokhov
There are no more users of
of_gpio_count()in the mainline kernel, remove it.
Quoted 5 lines
Signed-off-by Dmitry Torokhov <[email protected]>---
After 6.2-rc1 there should be no more users of the APIs mentioned in this series.
I believe you probably want to have this patch applied immediately to the GPIO subsystem after v6.2-rc1 to avoid new users.
Quoted 28 lines
include/linux/of_gpio.h | 11 ----------- 1 file changed, 11 deletions(-)include/linux/of_gpio.h +0
-11@@ -105,17 +105,6 @@ static inline int of_gpio_named_count(const struct device_node *np,return of_count_phandle_with_args (np, propname,"#gpio-cells" ); } -/** -* of_gpio_count() - Count GPIOs for a device -* @np: device node to count GPIOs for -* -* Same as of_gpio_named_count, but hard coded to use the 'gpios' property -*/ -static inline int of_gpio_count (const struct device_node *np) -{ -return of_gpio_named_count (np,"gpios" ); -} -static inline int of_get_gpio_flags (const struct device_node *np,int index,enum of_gpio_flags *flags) {Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · Dmitry Torokhov
There are no more users of
of_gpio_count()in the mainline kernel, remove it.Reviewed-by Andy Shevchenko <[email protected]>
Quoted 8 lines
Quoted 5 lines
Signed-off-by Dmitry Torokhov <[email protected]>---
After 6.2-rc1 there should be no more users of the APIs mentioned in this series.
I believe you probably want to have this patch applied immediately to the GPIO subsystem after v6.2-rc1 to avoid new users.
Thanks for the reviews Andy.
I think Linus pulled all the changes removing these all APIs into mainline, so it is possible to get it into 6.2 right away. Since everything is supposed to go through 'next' we will probably catch new users regardless, but I indeed would not mind having this in 6.2 and not wait for 6.3.
Thanks.
Signature · 1 line
Dmitry
Bartosz Golaszewski
AppliedQuoted 36 lines · Dmitry Torokhov
There are no more users of
of_gpio_count()in the mainline kernel, remove it.Signed-off-by Dmitry Torokhov <[email protected]>---
After 6.2-rc1 there should be no more users of the APIs mentioned in this series.
include/linux/of_gpio.h | 11 ----------- 1 file changed, 11 deletions(-)include/linux/of_gpio.h +0
-12@@ -105,17 +105,6 @@ static inline int of_gpio_named_count(const struct device_node *np,return of_count_phandle_with_args (np, propname,"#gpio-cells" ); } -/** -* of_gpio_count() - Count GPIOs for a device -* @np: device node to count GPIOs for -* -* Same as of_gpio_named_count, but hard coded to use the 'gpios' property -*/ -static inline int of_gpio_count (const struct device_node *np) -{ -return of_gpio_named_count (np,"gpios" ); -} -static inline int of_get_gpio_flags (const struct device_node *np,int index,enum of_gpio_flags *flags) { --
Quoted 2 lines
2.39.0.314.g84b9a713c41-goog
I applied the entire series, thanks a lot for doing that!
Bart