mfd: stmpe: switch to using gpiod API
Subsystems (2)
PATCH 1/1 mfd: stmpe: switch to using gpiod API
This patch switches the driver away from legacy gpio/of_gpio API to gpiod API, and removes use of of_get_named_gpio_flags() which I want to make private to gpiolib.
--- drivers/mfd/stmpe.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-)
drivers/mfd/stmpe.c +13 -23
@@ -8,14 +8,13 @@*/ #include <linux/err.h> -#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/export.h> #include <linux/kernel.h> #include <linux/interrupt.h> #include <linux/irq.h> #include <linux/irqdomain.h> #include <linux/of.h> -#include <linux/of_gpio.h> #include <linux/pm.h> #include <linux/slab.h> #include <linux/mfd/core.h>
@@ -30,17 +29,12 @@* @irq_trigger: IRQ trigger to use for the interrupt to the host * @autosleep: bool to enable/disable stmpe autosleep * @autosleep_timeout: inactivity timeout in milliseconds for autosleep -* @irq_over_gpio: true if gpio is used to get irq -* @irq_gpio: gpio number over which irq will be requested (significant only if -* irq_over_gpio is true) */ struct stmpe_platform_data {int id;unsigned int blocks;unsigned int irq_trigger;bool autosleep; -bool irq_over_gpio; -int irq_gpio;int autosleep_timeout; };
@@ -1349,13 +1343,6 @@ static void stmpe_of_probe(struct stmpe_platform_data *pdata,if (pdata->id <0 ) pdata->id =-1 ; - pdata->irq_gpio =of_get_named_gpio_flags (np,"irq-gpio" ,0 , - &pdata->irq_trigger); -if (gpio_is_valid (pdata->irq_gpio)) - pdata->irq_over_gpio =1 ; -else - pdata->irq_trigger =IRQF_TRIGGER_NONE ; -of_property_read_u32 (np,"st,autosleep-timeout" , &pdata->autosleep_timeout);
@@ -1381,6 +1368,7 @@ int stmpe_probe(struct stmpe_client_info *ci, enum stmpe_partnum partnum)struct stmpe_platform_data *pdata;struct device_node *np = ci->dev->of_node;struct stmpe *stmpe; +struct gpio_desc *irq_gpio;int ret;u32 val;
@@ -1434,18 +1422,20 @@ int stmpe_probe(struct stmpe_client_info *ci, enum stmpe_partnum partnum)if (ci->init) ci->init (stmpe); -if (pdata->irq_over_gpio) { - ret =devm_gpio_request_one (ci->dev, pdata->irq_gpio, -GPIOF_DIR_IN ,"stmpe" ); -if (ret) { -dev_err (stmpe->dev,"failed to request IRQ GPIO: %d\n" , - ret); -return ret; - } + irq_gpio =devm_gpiod_get_optional (ci->dev,"irq" ,GPIOD_ASIS ); + ret =PTR_ERR_OR_ZERO (irq_gpio); +if (ret) { +dev_err (stmpe->dev,"failed to request IRQ GPIO: %d\n" , ret); +return ret; + } - stmpe->irq =gpio_to_irq (pdata->irq_gpio); +if (irq_gpio) { + stmpe->irq =gpiod_to_irq (irq_gpio); + pdata->irq_trigger =gpiod_is_active_low (irq_gpio) ? +IRQF_TRIGGER_LOW :IRQF_TRIGGER_HIGH ; }else { stmpe->irq = ci->irq; + pdata->irq_trigger =IRQF_TRIGGER_NONE ; }if (stmpe->irq <0 ) {
Signature · 5 lines
2.37.2.789.g6183377224-goog -- Dmitry
Quoted 16 lines · Dmitry Torokhov
This patch switches the driver away from legacy gpio/of_gpio API to gpiod API, and removes use of
of_get_named_gpio_flags()which I want to make private to gpiolib.Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/mfd/stmpe.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-)drivers/mfd/stmpe.c +0
-0@@ -8,14 +8,13 @@*/
<snip>
Quoted 1 line
drivers/mfd/stmpe.c +0
-1- pdata->irq_gpio = of_get_named_gpio_flags(np, "irq-gpio", 0,
<snip>
drivers/mfd/stmpe.c int stmpe_probe(struct stmpe_client_info *ci, enum stmpe_partnum partnum) · line 1425
Quoted 1 line
drivers/mfd/stmpe.c +1
-0+ irq_gpio =devm_gpiod_get_optional (ci->dev,"irq" ,GPIOD_ASIS );
isn't this changing from irq-gpio to irq-gpios property name?
in the DTS files we do have something like that:
irq-gpio = <&gpio TEGRA_GPIO(V, 0) IRQ_TYPE_LEVEL_LOW>;
Francesco
Quoted 20 lines · Francesco Dolcini
Quoted 16 lines · Dmitry Torokhov
This patch switches the driver away from legacy gpio/of_gpio API to gpiod API, and removes use of
of_get_named_gpio_flags()which I want to make private to gpiolib.Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/mfd/stmpe.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-)drivers/mfd/stmpe.c +0
-0@@ -8,14 +8,13 @@*/ <snip>
Quoted 4 lines
Quoted 1 line
-
pdata->irq_gpio= of_get_named_gpio_flags(np, "irq-gpio", 0,<snip>
Quoted 1 line
+
irq_gpio=devm_gpiod_get_optional(ci->dev, "irq", GPIOD_ASIS);isn't this changing from irq-gpio to irq-gpios property name?
The gpiolib core will automatically append and test the strings *-gpios and *-gpio (in that order)
Quoted 3 lines
in the DTS files we do have something like that:
irq-gpio = <&gpio
TEGRA_GPIO(V, 0)IRQ_TYPE_LEVEL_LOW>;
This seems to be an orthogonal bug.
That flag in the last cell is invalid for a GPIO, the DT schema should scream at you if you have one. GPIO flags are GPIO_ACTIVE_LOW, GPIO_OPEN_DRAIN etc. That looks more
like an IRQ, and then the property should be irqs = <...>.
Yours,
Linus Walleij
Quoted 32 lines · Linus Walleij
Quoted 20 lines · Francesco Dolcini
Quoted 16 lines · Dmitry Torokhov
This patch switches the driver away from legacy gpio/of_gpio API to gpiod API, and removes use of
of_get_named_gpio_flags()which I want to make private to gpiolib.Signed-off-by Dmitry Torokhov <[email protected]>--- drivers/mfd/stmpe.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-)drivers/mfd/stmpe.c +0
-0@@ -8,14 +8,13 @@*/ <snip>
Quoted 4 lines
Quoted 1 line
-
pdata->irq_gpio= of_get_named_gpio_flags(np, "irq-gpio", 0,<snip>
Quoted 1 line
+
irq_gpio=devm_gpiod_get_optional(ci->dev, "irq", GPIOD_ASIS);isn't this changing from irq-gpio to irq-gpios property name?
The gpiolib core will automatically append and test the strings *-gpios and *-gpio (in that order)
Quoted 2 lines
in the DTS files we do have something like that:
Quoted 8 lines
Quoted 1 line
irq-gpio = <&gpio
TEGRA_GPIO(V, 0)IRQ_TYPE_LEVEL_LOW>;This seems to be an orthogonal bug.
That flag in the last cell is invalid for a GPIO, the DT schema should scream at you if you have one. GPIO flags are
GPIO_ACTIVE_LOW,GPIO_OPEN_DRAINetc. That looks more
like an IRQ, and then the property should be irqs = <...>.
Francesco is right though in the sense that we need to update DTS together with the patch, or we will break the driver... The original code relied on the fact that flags returned by of_get_named_gpio_flags() could contain anything, not necessarily valid GPIO flags.
Thanks.
Signature · 1 line
Dmitry