* [PATCH] soc: fsl: qe: drop GPIOD_FLAGS_BIT_NONEXCLUSIVE
@ 2026-09-08 9:27 Bartosz Golaszewski
2026-09-08 11:58 ` Christophe Leroy (CS GROUP)
2026-09-11 5:22 ` Christophe Leroy (CS GROUP)
0 siblings, 2 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2026-09-08 9:27 UTC (permalink / raw)
To: Qiang Zhao, Christophe Leroy (CS GROUP), Greg Kroah-Hartman,
Linus Walleij, Bartosz Golaszewski
Cc: linuxppc-dev, linux-arm-kernel, linux-kernel, linux-usb,
linux-gpio, Bartosz Golaszewski
The GPIOD_FLAGS_BIT_NONEXCLUSIVE flag for gpiod_get() is deprecated. For
actually shared GPIOs, it should be replaced by using the functionality
provided by gpio-shared-proxy. The Freescale QUICC Engine GPIO driver
uses it as a workaround to access the GPIO descriptor already requested
by the caller of qe_pin_request() in order to access the private GPIO
chip data.
As the existing comment itself states, the user already requested this
GPIO and the only user in tree is the FHCI USB driver which does in fact
request it, we can safely modify the function to take the *exclusive*
GPIO descriptor as argument and stop using the deprecated flag.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/soc/fsl/qe/gpio.c | 29 +++++++----------------------
drivers/usb/host/fhci-hcd.c | 2 +-
include/soc/fsl/qe/qe.h | 6 ++++--
3 files changed, 12 insertions(+), 25 deletions(-)
diff --git a/drivers/soc/fsl/qe/gpio.c b/drivers/soc/fsl/qe/gpio.c
index 5cd59cfbf22fa68d39ad00b8f73ad389ac8860a3..5a3a1d5df669b1e0a084a0ebfd2aef91e15f126e 100644
--- a/drivers/soc/fsl/qe/gpio.c
+++ b/drivers/soc/fsl/qe/gpio.c
@@ -196,18 +196,17 @@ struct qe_pin {
/**
* qe_pin_request - Request a QE pin
* @dev: device to get the pin from
- * @index: index of the pin in the device tree
+ * @gpiod: GPIO descriptor associated with this pin
* Context: non-atomic
*
* This function return qe_pin so that you could use it with the rest of
* the QE Pin Multiplexing API.
*/
-struct qe_pin *qe_pin_request(struct device *dev, int index)
+struct qe_pin *qe_pin_request(struct device *dev, struct gpio_desc *gpiod)
{
+ struct gpio_device *gdev;
struct qe_pin *qe_pin;
struct gpio_chip *gc;
- struct gpio_desc *gpiod;
- int gpio_num;
int err;
qe_pin = kzalloc_obj(*qe_pin);
@@ -216,34 +215,20 @@ struct qe_pin *qe_pin_request(struct device *dev, int index)
return ERR_PTR(-ENOMEM);
}
- /*
- * Request gpio as nonexclusive as it was likely reserved by the
- * caller, and we are not planning on controlling it, we only need
- * the descriptor to the to the gpio chip structure.
- */
- gpiod = gpiod_get_index(dev, NULL, index,
- GPIOD_ASIS | GPIOD_FLAGS_BIT_NONEXCLUSIVE);
- err = PTR_ERR_OR_ZERO(gpiod);
- if (err)
- goto err0;
-
- gc = gpiod_to_chip(gpiod);
- gpio_num = desc_to_gpio(gpiod);
- /* We no longer need this descriptor */
- gpiod_put(gpiod);
-
- if (WARN_ON(!gc)) {
+ gdev = gpiod_to_gpio_device(gpiod);
+ if (WARN_ON(!gdev)) {
err = -ENODEV;
goto err0;
}
+ gc = gpio_device_get_chip(gdev);
qe_pin->controller = gpiochip_get_data(gc);
/*
* FIXME: this gets the local offset on the gpio_chip so that the driver
* can manipulate pin control settings through its custom API. The real
* solution is to create a real pin control driver for this.
*/
- qe_pin->num = gpio_num - gc->base;
+ qe_pin->num = desc_to_gpio(gpiod) - gc->base;
if (!fwnode_device_is_compatible(gc->fwnode, "fsl,mpc8323-qe-pario-bank")) {
dev_dbg(dev, "%s: tried to get a non-qe pin\n", __func__);
diff --git a/drivers/usb/host/fhci-hcd.c b/drivers/usb/host/fhci-hcd.c
index 71e785f445a30e116a9cb421d417deaf24389174..d572f0c1dffaf3a40b2fe4326ba8ab021fefb986 100644
--- a/drivers/usb/host/fhci-hcd.c
+++ b/drivers/usb/host/fhci-hcd.c
@@ -643,7 +643,7 @@ static int of_fhci_probe(struct platform_device *ofdev)
}
for (j = 0; j < NUM_PINS; j++) {
- fhci->pins[j] = qe_pin_request(dev, j);
+ fhci->pins[j] = qe_pin_request(dev, fhci->gpiods[j]);
if (IS_ERR(fhci->pins[j])) {
ret = PTR_ERR(fhci->pins[j]);
dev_err(dev, "can't get pin %d: %d\n", j, ret);
diff --git a/include/soc/fsl/qe/qe.h b/include/soc/fsl/qe/qe.h
index 8f967d15e479792219333264c2a463d26e5edae9..7f0e4165c3b0cafdf401be20862aa1bf28047102 100644
--- a/include/soc/fsl/qe/qe.h
+++ b/include/soc/fsl/qe/qe.h
@@ -24,6 +24,7 @@
#include <linux/types.h>
struct device;
+struct gpio_desc;
#define QE_NUM_OF_SNUM 256 /* There are 256 serial number in QE */
#define QE_NUM_OF_BRGS 16
@@ -193,12 +194,13 @@ static inline int par_io_data_set(u8 port, u8 pin, u8 val) { return -ENOSYS; }
*/
struct qe_pin;
#ifdef CONFIG_QE_GPIO
-extern struct qe_pin *qe_pin_request(struct device *dev, int index);
+extern struct qe_pin *qe_pin_request(struct device *dev, struct gpio_desc *gpiod);
extern void qe_pin_free(struct qe_pin *qe_pin);
extern void qe_pin_set_gpio(struct qe_pin *qe_pin);
extern void qe_pin_set_dedicated(struct qe_pin *pin);
#else
-static inline struct qe_pin *qe_pin_request(struct device *dev, int index)
+static inline struct qe_pin *
+qe_pin_request(struct device *dev, struct gpio_desc *gpiod)
{
return ERR_PTR(-ENOSYS);
}
---
base-commit: af5f12805e5cefa4fe68d6127c7e1fb78cd5535c
change-id: 20260907-usb-fhci-drop-gpio-nonexclusive-584c5c808a30
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] soc: fsl: qe: drop GPIOD_FLAGS_BIT_NONEXCLUSIVE
2026-09-08 9:27 [PATCH] soc: fsl: qe: drop GPIOD_FLAGS_BIT_NONEXCLUSIVE Bartosz Golaszewski
@ 2026-09-08 11:58 ` Christophe Leroy (CS GROUP)
2026-09-10 12:34 ` Greg Kroah-Hartman
2026-09-11 5:22 ` Christophe Leroy (CS GROUP)
1 sibling, 1 reply; 4+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-09-08 11:58 UTC (permalink / raw)
To: Bartosz Golaszewski, Greg Kroah-Hartman, Bartosz Golaszewski
Cc: linuxppc-dev, linux-arm-kernel, Qiang Zhao, Linus Walleij,
linux-kernel, linux-usb, linux-gpio
Hi,
Le 08/09/2026 à 11:27, Bartosz Golaszewski a écrit :
> The GPIOD_FLAGS_BIT_NONEXCLUSIVE flag for gpiod_get() is deprecated. For
> actually shared GPIOs, it should be replaced by using the functionality
> provided by gpio-shared-proxy. The Freescale QUICC Engine GPIO driver
> uses it as a workaround to access the GPIO descriptor already requested
> by the caller of qe_pin_request() in order to access the private GPIO
> chip data.
>
> As the existing comment itself states, the user already requested this
> GPIO and the only user in tree is the FHCI USB driver which does in fact
> request it, we can safely modify the function to take the *exclusive*
> GPIO descriptor as argument and stop using the deprecated flag.
This change seems sensible. I will take it via soc/fsl tree unless you
have other plans.
Greg, can you ack the change to drivers/usb/host/fhci-hcd.c ?
Thanks
Christophe
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> ---
> drivers/soc/fsl/qe/gpio.c | 29 +++++++----------------------
> drivers/usb/host/fhci-hcd.c | 2 +-
> include/soc/fsl/qe/qe.h | 6 ++++--
> 3 files changed, 12 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/soc/fsl/qe/gpio.c b/drivers/soc/fsl/qe/gpio.c
> index 5cd59cfbf22fa68d39ad00b8f73ad389ac8860a3..5a3a1d5df669b1e0a084a0ebfd2aef91e15f126e 100644
> --- a/drivers/soc/fsl/qe/gpio.c
> +++ b/drivers/soc/fsl/qe/gpio.c
> @@ -196,18 +196,17 @@ struct qe_pin {
> /**
> * qe_pin_request - Request a QE pin
> * @dev: device to get the pin from
> - * @index: index of the pin in the device tree
> + * @gpiod: GPIO descriptor associated with this pin
> * Context: non-atomic
> *
> * This function return qe_pin so that you could use it with the rest of
> * the QE Pin Multiplexing API.
> */
> -struct qe_pin *qe_pin_request(struct device *dev, int index)
> +struct qe_pin *qe_pin_request(struct device *dev, struct gpio_desc *gpiod)
> {
> + struct gpio_device *gdev;
> struct qe_pin *qe_pin;
> struct gpio_chip *gc;
> - struct gpio_desc *gpiod;
> - int gpio_num;
> int err;
>
> qe_pin = kzalloc_obj(*qe_pin);
> @@ -216,34 +215,20 @@ struct qe_pin *qe_pin_request(struct device *dev, int index)
> return ERR_PTR(-ENOMEM);
> }
>
> - /*
> - * Request gpio as nonexclusive as it was likely reserved by the
> - * caller, and we are not planning on controlling it, we only need
> - * the descriptor to the to the gpio chip structure.
> - */
> - gpiod = gpiod_get_index(dev, NULL, index,
> - GPIOD_ASIS | GPIOD_FLAGS_BIT_NONEXCLUSIVE);
> - err = PTR_ERR_OR_ZERO(gpiod);
> - if (err)
> - goto err0;
> -
> - gc = gpiod_to_chip(gpiod);
> - gpio_num = desc_to_gpio(gpiod);
> - /* We no longer need this descriptor */
> - gpiod_put(gpiod);
> -
> - if (WARN_ON(!gc)) {
> + gdev = gpiod_to_gpio_device(gpiod);
> + if (WARN_ON(!gdev)) {
> err = -ENODEV;
> goto err0;
> }
>
> + gc = gpio_device_get_chip(gdev);
> qe_pin->controller = gpiochip_get_data(gc);
> /*
> * FIXME: this gets the local offset on the gpio_chip so that the driver
> * can manipulate pin control settings through its custom API. The real
> * solution is to create a real pin control driver for this.
> */
> - qe_pin->num = gpio_num - gc->base;
> + qe_pin->num = desc_to_gpio(gpiod) - gc->base;
>
> if (!fwnode_device_is_compatible(gc->fwnode, "fsl,mpc8323-qe-pario-bank")) {
> dev_dbg(dev, "%s: tried to get a non-qe pin\n", __func__);
> diff --git a/drivers/usb/host/fhci-hcd.c b/drivers/usb/host/fhci-hcd.c
> index 71e785f445a30e116a9cb421d417deaf24389174..d572f0c1dffaf3a40b2fe4326ba8ab021fefb986 100644
> --- a/drivers/usb/host/fhci-hcd.c
> +++ b/drivers/usb/host/fhci-hcd.c
> @@ -643,7 +643,7 @@ static int of_fhci_probe(struct platform_device *ofdev)
> }
>
> for (j = 0; j < NUM_PINS; j++) {
> - fhci->pins[j] = qe_pin_request(dev, j);
> + fhci->pins[j] = qe_pin_request(dev, fhci->gpiods[j]);
> if (IS_ERR(fhci->pins[j])) {
> ret = PTR_ERR(fhci->pins[j]);
> dev_err(dev, "can't get pin %d: %d\n", j, ret);
> diff --git a/include/soc/fsl/qe/qe.h b/include/soc/fsl/qe/qe.h
> index 8f967d15e479792219333264c2a463d26e5edae9..7f0e4165c3b0cafdf401be20862aa1bf28047102 100644
> --- a/include/soc/fsl/qe/qe.h
> +++ b/include/soc/fsl/qe/qe.h
> @@ -24,6 +24,7 @@
> #include <linux/types.h>
>
> struct device;
> +struct gpio_desc;
>
> #define QE_NUM_OF_SNUM 256 /* There are 256 serial number in QE */
> #define QE_NUM_OF_BRGS 16
> @@ -193,12 +194,13 @@ static inline int par_io_data_set(u8 port, u8 pin, u8 val) { return -ENOSYS; }
> */
> struct qe_pin;
> #ifdef CONFIG_QE_GPIO
> -extern struct qe_pin *qe_pin_request(struct device *dev, int index);
> +extern struct qe_pin *qe_pin_request(struct device *dev, struct gpio_desc *gpiod);
> extern void qe_pin_free(struct qe_pin *qe_pin);
> extern void qe_pin_set_gpio(struct qe_pin *qe_pin);
> extern void qe_pin_set_dedicated(struct qe_pin *pin);
> #else
> -static inline struct qe_pin *qe_pin_request(struct device *dev, int index)
> +static inline struct qe_pin *
> +qe_pin_request(struct device *dev, struct gpio_desc *gpiod)
> {
> return ERR_PTR(-ENOSYS);
> }
>
> ---
> base-commit: af5f12805e5cefa4fe68d6127c7e1fb78cd5535c
> change-id: 20260907-usb-fhci-drop-gpio-nonexclusive-584c5c808a30
>
> Best regards,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] soc: fsl: qe: drop GPIOD_FLAGS_BIT_NONEXCLUSIVE
2026-09-08 11:58 ` Christophe Leroy (CS GROUP)
@ 2026-09-10 12:34 ` Greg Kroah-Hartman
0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2026-09-10 12:34 UTC (permalink / raw)
To: Christophe Leroy (CS GROUP)
Cc: Bartosz Golaszewski, Bartosz Golaszewski, linuxppc-dev,
linux-arm-kernel, Qiang Zhao, Linus Walleij, linux-kernel,
linux-usb, linux-gpio
On Tue, Sep 08, 2026 at 01:58:18PM +0200, Christophe Leroy (CS GROUP) wrote:
> Hi,
>
> Le 08/09/2026 à 11:27, Bartosz Golaszewski a écrit :
> > The GPIOD_FLAGS_BIT_NONEXCLUSIVE flag for gpiod_get() is deprecated. For
> > actually shared GPIOs, it should be replaced by using the functionality
> > provided by gpio-shared-proxy. The Freescale QUICC Engine GPIO driver
> > uses it as a workaround to access the GPIO descriptor already requested
> > by the caller of qe_pin_request() in order to access the private GPIO
> > chip data.
> >
> > As the existing comment itself states, the user already requested this
> > GPIO and the only user in tree is the FHCI USB driver which does in fact
> > request it, we can safely modify the function to take the *exclusive*
> > GPIO descriptor as argument and stop using the deprecated flag.
>
> This change seems sensible. I will take it via soc/fsl tree unless you have
> other plans.
>
> Greg, can you ack the change to drivers/usb/host/fhci-hcd.c ?
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] soc: fsl: qe: drop GPIOD_FLAGS_BIT_NONEXCLUSIVE
2026-09-08 9:27 [PATCH] soc: fsl: qe: drop GPIOD_FLAGS_BIT_NONEXCLUSIVE Bartosz Golaszewski
2026-09-08 11:58 ` Christophe Leroy (CS GROUP)
@ 2026-09-11 5:22 ` Christophe Leroy (CS GROUP)
1 sibling, 0 replies; 4+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-09-11 5:22 UTC (permalink / raw)
To: Qiang Zhao, Greg Kroah-Hartman, Linus Walleij,
Bartosz Golaszewski, Bartosz Golaszewski
Cc: Christophe Leroy, linuxppc-dev, linux-arm-kernel, linux-kernel,
linux-usb, linux-gpio
On Tue, 08 Sep 2026 11:27:46 +0200, Bartosz Golaszewski wrote:
> The GPIOD_FLAGS_BIT_NONEXCLUSIVE flag for gpiod_get() is deprecated. For
> actually shared GPIOs, it should be replaced by using the functionality
> provided by gpio-shared-proxy. The Freescale QUICC Engine GPIO driver
> uses it as a workaround to access the GPIO descriptor already requested
> by the caller of qe_pin_request() in order to access the private GPIO
> chip data.
>
> [...]
Applied, thanks!
[1/1] soc: fsl: qe: drop GPIOD_FLAGS_BIT_NONEXCLUSIVE
commit: 31d42d67c6eb66efc058069f426d69abb48ec0dd
Best regards,
--
Christophe Leroy (CS GROUP) <chleroy@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-11 5:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-08 9:27 [PATCH] soc: fsl: qe: drop GPIOD_FLAGS_BIT_NONEXCLUSIVE Bartosz Golaszewski
2026-09-08 11:58 ` Christophe Leroy (CS GROUP)
2026-09-10 12:34 ` Greg Kroah-Hartman
2026-09-11 5:22 ` Christophe Leroy (CS GROUP)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox