2019-04-29 05:51:22

by Andrey Smirnov

[permalink] [raw]
Subject: [PATCH 1/2] gpio: vf610: Use devm_platform_ioremap_resource()

Replace calls to platform_get_resource() and devm_ioremap_resource()
with newly added devm_platform_ioremap_resource() for brevity. No
functional change intended.

Signed-off-by: Andrey Smirnov <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: Bartosz Golaszewski <[email protected]>
Cc: Chris Healy <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
drivers/gpio/gpio-vf610.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c
index 6f6558715b88..30aef41e3b7e 100644
--- a/drivers/gpio/gpio-vf610.c
+++ b/drivers/gpio/gpio-vf610.c
@@ -242,7 +242,6 @@ static int vf610_gpio_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
struct vf610_gpio_port *port;
- struct resource *iores;
struct gpio_chip *gc;
struct irq_chip *ic;
int i;
@@ -253,13 +252,11 @@ static int vf610_gpio_probe(struct platform_device *pdev)
return -ENOMEM;

port->sdata = of_device_get_match_data(dev);
- iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- port->base = devm_ioremap_resource(dev, iores);
+ port->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(port->base))
return PTR_ERR(port->base);

- iores = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- port->gpio_base = devm_ioremap_resource(dev, iores);
+ port->gpio_base = devm_platform_ioremap_resource(pdev, 1);
if (IS_ERR(port->gpio_base))
return PTR_ERR(port->gpio_base);

--
2.20.1


2019-04-29 05:51:42

by Andrey Smirnov

[permalink] [raw]
Subject: [PATCH 2/2] gpio: vf610: Use PTR_ERR_OR_ZERO() in vf610_gpio_probe()

Simplify error checking code by replacing multiple ERR macros with a
call to PTR_ERR_OR_ZERO. No functional change intended.

Signed-off-by: Andrey Smirnov <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: Bartosz Golaszewski <[email protected]>
Cc: Chris Healy <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
drivers/gpio/gpio-vf610.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c
index 30aef41e3b7e..7ba668db171b 100644
--- a/drivers/gpio/gpio-vf610.c
+++ b/drivers/gpio/gpio-vf610.c
@@ -265,7 +265,8 @@ static int vf610_gpio_probe(struct platform_device *pdev)
return port->irq;

port->clk_port = devm_clk_get(dev, "port");
- if (!IS_ERR(port->clk_port)) {
+ ret = PTR_ERR_OR_ZERO(port->clk_port);
+ if (!ret) {
ret = clk_prepare_enable(port->clk_port);
if (ret)
return ret;
@@ -273,16 +274,17 @@ static int vf610_gpio_probe(struct platform_device *pdev)
port->clk_port);
if (ret)
return ret;
- } else if (port->clk_port == ERR_PTR(-EPROBE_DEFER)) {
+ } else if (ret == -EPROBE_DEFER) {
/*
* Percolate deferrals, for anything else,
* just live without the clocking.
*/
- return PTR_ERR(port->clk_port);
+ return ret;
}

port->clk_gpio = devm_clk_get(dev, "gpio");
- if (!IS_ERR(port->clk_gpio)) {
+ ret = PTR_ERR_OR_ZERO(port->clk_gpio);
+ if (!ret) {
ret = clk_prepare_enable(port->clk_gpio);
if (ret)
return ret;
@@ -290,8 +292,8 @@ static int vf610_gpio_probe(struct platform_device *pdev)
port->clk_gpio);
if (ret)
return ret;
- } else if (port->clk_gpio == ERR_PTR(-EPROBE_DEFER)) {
- return PTR_ERR(port->clk_gpio);
+ } else if (ret == -EPROBE_DEFER) {
+ return ret;
}

gc = &port->gc;
--
2.20.1

2019-04-29 07:56:18

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH 1/2] gpio: vf610: Use devm_platform_ioremap_resource()

pon., 29 kwi 2019 o 07:50 Andrey Smirnov <[email protected]> napisał(a):
>
> Replace calls to platform_get_resource() and devm_ioremap_resource()
> with newly added devm_platform_ioremap_resource() for brevity. No
> functional change intended.
>
> Signed-off-by: Andrey Smirnov <[email protected]>
> Cc: Linus Walleij <[email protected]>
> Cc: Bartosz Golaszewski <[email protected]>
> Cc: Chris Healy <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> ---
> drivers/gpio/gpio-vf610.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c
> index 6f6558715b88..30aef41e3b7e 100644
> --- a/drivers/gpio/gpio-vf610.c
> +++ b/drivers/gpio/gpio-vf610.c
> @@ -242,7 +242,6 @@ static int vf610_gpio_probe(struct platform_device *pdev)
> struct device *dev = &pdev->dev;
> struct device_node *np = dev->of_node;
> struct vf610_gpio_port *port;
> - struct resource *iores;
> struct gpio_chip *gc;
> struct irq_chip *ic;
> int i;
> @@ -253,13 +252,11 @@ static int vf610_gpio_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> port->sdata = of_device_get_match_data(dev);
> - iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - port->base = devm_ioremap_resource(dev, iores);
> + port->base = devm_platform_ioremap_resource(pdev, 0);
> if (IS_ERR(port->base))
> return PTR_ERR(port->base);
>
> - iores = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> - port->gpio_base = devm_ioremap_resource(dev, iores);
> + port->gpio_base = devm_platform_ioremap_resource(pdev, 1);
> if (IS_ERR(port->gpio_base))
> return PTR_ERR(port->gpio_base);
>
> --
> 2.20.1
>

Reviewed-by: Bartosz Golaszewski <[email protected]>

2019-04-29 08:08:20

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH 2/2] gpio: vf610: Use PTR_ERR_OR_ZERO() in vf610_gpio_probe()

pon., 29 kwi 2019 o 07:50 Andrey Smirnov <[email protected]> napisał(a):
>
> Simplify error checking code by replacing multiple ERR macros with a
> call to PTR_ERR_OR_ZERO. No functional change intended.
>
> Signed-off-by: Andrey Smirnov <[email protected]>
> Cc: Linus Walleij <[email protected]>
> Cc: Bartosz Golaszewski <[email protected]>
> Cc: Chris Healy <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> ---
> drivers/gpio/gpio-vf610.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c
> index 30aef41e3b7e..7ba668db171b 100644
> --- a/drivers/gpio/gpio-vf610.c
> +++ b/drivers/gpio/gpio-vf610.c
> @@ -265,7 +265,8 @@ static int vf610_gpio_probe(struct platform_device *pdev)
> return port->irq;
>
> port->clk_port = devm_clk_get(dev, "port");
> - if (!IS_ERR(port->clk_port)) {
> + ret = PTR_ERR_OR_ZERO(port->clk_port);
> + if (!ret) {
> ret = clk_prepare_enable(port->clk_port);
> if (ret)
> return ret;
> @@ -273,16 +274,17 @@ static int vf610_gpio_probe(struct platform_device *pdev)
> port->clk_port);
> if (ret)
> return ret;
> - } else if (port->clk_port == ERR_PTR(-EPROBE_DEFER)) {
> + } else if (ret == -EPROBE_DEFER) {
> /*
> * Percolate deferrals, for anything else,
> * just live without the clocking.
> */
> - return PTR_ERR(port->clk_port);
> + return ret;
> }
>
> port->clk_gpio = devm_clk_get(dev, "gpio");
> - if (!IS_ERR(port->clk_gpio)) {
> + ret = PTR_ERR_OR_ZERO(port->clk_gpio);
> + if (!ret) {
> ret = clk_prepare_enable(port->clk_gpio);
> if (ret)
> return ret;
> @@ -290,8 +292,8 @@ static int vf610_gpio_probe(struct platform_device *pdev)
> port->clk_gpio);
> if (ret)
> return ret;
> - } else if (port->clk_gpio == ERR_PTR(-EPROBE_DEFER)) {
> - return PTR_ERR(port->clk_gpio);
> + } else if (ret == -EPROBE_DEFER) {
> + return ret;
> }
>
> gc = &port->gc;
> --
> 2.20.1
>

Reviewed-by: Bartosz Golaszewski <[email protected]>

2019-05-16 12:02:49

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 2/2] gpio: vf610: Use PTR_ERR_OR_ZERO() in vf610_gpio_probe()

On Mon, Apr 29, 2019 at 7:50 AM Andrey Smirnov <[email protected]> wrote:

> Simplify error checking code by replacing multiple ERR macros with a
> call to PTR_ERR_OR_ZERO. No functional change intended.
>
> Signed-off-by: Andrey Smirnov <[email protected]>
> Cc: Linus Walleij <[email protected]>
> Cc: Bartosz Golaszewski <[email protected]>
> Cc: Chris Healy <[email protected]>
> Cc: [email protected]
> Cc: [email protected]

Patch applied for v5.3.

Yours,
Linus Walleij