* [PATCH v2] soc: fsl: qe: Avoid using gpio_to_desc()
@ 2022-10-26 8:33 Linus Walleij
0 siblings, 0 replies; only message in thread
From: Linus Walleij @ 2022-10-26 8:33 UTC (permalink / raw)
To: Michael Ellerman, Nicholas Piggin, Christophe Leroy, Qiang Zhao,
Li Yang
Cc: linux-gpio, Linus Walleij, linuxppc-dev, Bartosz Golaszewski
We want to get rid of the old GPIO numberspace, so instead of
calling gpio_to_desc() we get the gpio descriptor for the requested
line from the device tree directly without passing through the
GPIO numberspace, and then we get the gpiochip from the descriptor.
Cc: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: linux-gpio@vger.kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Add back the <linux/of_gpio.h> include: we are using the
mm_of_gpio_chip, which should be fixed, but not now.
---
drivers/soc/fsl/qe/gpio.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/drivers/soc/fsl/qe/gpio.c b/drivers/soc/fsl/qe/gpio.c
index 99f7de43c3c6..68d48430ab33 100644
--- a/drivers/soc/fsl/qe/gpio.c
+++ b/drivers/soc/fsl/qe/gpio.c
@@ -14,9 +14,8 @@
#include <linux/io.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/gpio/driver.h>
-/* FIXME: needed for gpio_to_chip() get rid of this */
-#include <linux/gpio.h>
#include <linux/slab.h>
#include <linux/export.h>
#include <soc/fsl/qe/qe.h>
@@ -161,6 +160,7 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index)
struct qe_pin *qe_pin;
struct gpio_chip *gc;
struct qe_gpio_chip *qe_gc;
+ struct gpio_desc *gpiod;
int err;
unsigned long flags;
@@ -170,14 +170,21 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index)
return ERR_PTR(-ENOMEM);
}
- err = of_get_gpio(np, index);
- if (err < 0)
+ gpiod = fwnode_gpiod_get_index(of_fwnode_handle(np), NULL, index, GPIOD_ASIS, "qe");
+ if (IS_ERR(gpiod)) {
+ err = PTR_ERR(gpiod);
goto err0;
- gc = gpio_to_chip(err);
+ }
+ if (!gpiod) {
+ err = -EINVAL;
+ goto err0;
+ }
+ gc = gpiod_to_chip(gpiod);
if (WARN_ON(!gc)) {
err = -ENODEV;
goto err0;
}
+ gpiod_put(gpiod);
if (!of_device_is_compatible(gc->of_node, "fsl,mpc8323-qe-pario-bank")) {
pr_debug("%s: tried to get a non-qe pin\n", __func__);
--
2.34.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-10-26 8:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-26 8:33 [PATCH v2] soc: fsl: qe: Avoid using gpio_to_desc() Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).