2020-08-26 14:49:31

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 1/6] pwm: bcm2835: Simplify with dev_err_probe()

Common pattern of handling deferred probe can be simplified with
dev_err_probe(). Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/pwm/pwm-bcm2835.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
index d78f86f8e462..6841dcfe27fc 100644
--- a/drivers/pwm/pwm-bcm2835.c
+++ b/drivers/pwm/pwm-bcm2835.c
@@ -152,13 +152,9 @@ static int bcm2835_pwm_probe(struct platform_device *pdev)
return PTR_ERR(pc->base);

pc->clk = devm_clk_get(&pdev->dev, NULL);
- if (IS_ERR(pc->clk)) {
- ret = PTR_ERR(pc->clk);
- if (ret != -EPROBE_DEFER)
- dev_err(&pdev->dev, "clock not found: %d\n", ret);
-
- return ret;
- }
+ if (IS_ERR(pc->clk))
+ return dev_err_probe(&pdev->dev, PTR_ERR(pc->clk),
+ "clock not found\n");

ret = clk_prepare_enable(pc->clk);
if (ret)
--
2.17.1


2020-08-26 14:50:43

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 6/6] pwm: sun4i: Simplify with dev_err_probe()

Common pattern of handling deferred probe can be simplified with
dev_err_probe(). Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/pwm/pwm-sun4i.c | 36 ++++++++++++------------------------
1 file changed, 12 insertions(+), 24 deletions(-)

diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c
index 961c59c99bb3..38a4c5c1317b 100644
--- a/drivers/pwm/pwm-sun4i.c
+++ b/drivers/pwm/pwm-sun4i.c
@@ -423,38 +423,26 @@ static int sun4i_pwm_probe(struct platform_device *pdev)
* back to the first clock of the PWM.
*/
pwm->clk = devm_clk_get_optional(&pdev->dev, "mod");
- if (IS_ERR(pwm->clk)) {
- if (PTR_ERR(pwm->clk) != -EPROBE_DEFER)
- dev_err(&pdev->dev, "get mod clock failed %pe\n",
- pwm->clk);
- return PTR_ERR(pwm->clk);
- }
+ if (IS_ERR(pwm->clk))
+ return dev_err_probe(&pdev->dev, PTR_ERR(pwm->clk),
+ "get mod clock failed\n");

if (!pwm->clk) {
pwm->clk = devm_clk_get(&pdev->dev, NULL);
- if (IS_ERR(pwm->clk)) {
- if (PTR_ERR(pwm->clk) != -EPROBE_DEFER)
- dev_err(&pdev->dev, "get unnamed clock failed %pe\n",
- pwm->clk);
- return PTR_ERR(pwm->clk);
- }
+ if (IS_ERR(pwm->clk))
+ return dev_err_probe(&pdev->dev, PTR_ERR(pwm->clk),
+ "get unnamed clock failed\n");
}

pwm->bus_clk = devm_clk_get_optional(&pdev->dev, "bus");
- if (IS_ERR(pwm->bus_clk)) {
- if (PTR_ERR(pwm->bus_clk) != -EPROBE_DEFER)
- dev_err(&pdev->dev, "get bus clock failed %pe\n",
- pwm->bus_clk);
- return PTR_ERR(pwm->bus_clk);
- }
+ if (IS_ERR(pwm->bus_clk))
+ return dev_err_probe(&pdev->dev, PTR_ERR(pwm->bus_clk),
+ "get bus clock failed\n");

pwm->rst = devm_reset_control_get_optional_shared(&pdev->dev, NULL);
- if (IS_ERR(pwm->rst)) {
- if (PTR_ERR(pwm->rst) != -EPROBE_DEFER)
- dev_err(&pdev->dev, "get reset failed %pe\n",
- pwm->rst);
- return PTR_ERR(pwm->rst);
- }
+ if (IS_ERR(pwm->rst))
+ return dev_err_probe(&pdev->dev, PTR_ERR(pwm->rst),
+ "get reset failed\n");

/* Deassert reset */
ret = reset_control_deassert(pwm->rst);
--
2.17.1

2020-08-26 14:50:54

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 5/6] pwm: sprd: Simplify with dev_err_probe()

Common pattern of handling deferred probe can be simplified with
dev_err_probe(). Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/pwm/pwm-sprd.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/pwm/pwm-sprd.c b/drivers/pwm/pwm-sprd.c
index be2394227423..5123d948efd6 100644
--- a/drivers/pwm/pwm-sprd.c
+++ b/drivers/pwm/pwm-sprd.c
@@ -228,11 +228,8 @@ static int sprd_pwm_clk_init(struct sprd_pwm_chip *spc)
if (ret == -ENOENT)
break;

- if (ret != -EPROBE_DEFER)
- dev_err(spc->dev,
- "failed to get channel clocks\n");
-
- return ret;
+ return dev_err_probe(spc->dev, ret,
+ "failed to get channel clocks\n");
}

clk_pwm = chn->clks[SPRD_PWM_CHN_OUTPUT_CLK].clk;
--
2.17.1

2020-08-26 14:51:35

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 2/6] pwm: jz4740: Simplify with dev_err_probe()

Common pattern of handling deferred probe can be simplified with
dev_err_probe(). Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/pwm/pwm-jz4740.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c
index 5830ac2bdf6a..00c642fa2eed 100644
--- a/drivers/pwm/pwm-jz4740.c
+++ b/drivers/pwm/pwm-jz4740.c
@@ -60,12 +60,9 @@ static int jz4740_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
snprintf(name, sizeof(name), "timer%u", pwm->hwpwm);

clk = clk_get(chip->dev, name);
- if (IS_ERR(clk)) {
- if (PTR_ERR(clk) != -EPROBE_DEFER)
- dev_err(chip->dev, "Failed to get clock: %pe", clk);
-
- return PTR_ERR(clk);
- }
+ if (IS_ERR(clk))
+ return dev_err_probe(chip->dev, PTR_ERR(clk),
+ "Failed to get clock\n");

err = clk_prepare_enable(clk);
if (err < 0) {
--
2.17.1

2020-08-26 14:52:30

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 3/6] pwm: rockchip: Simplify with dev_err_probe()

Common pattern of handling deferred probe can be simplified with
dev_err_probe(). Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/pwm/pwm-rockchip.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/pwm/pwm-rockchip.c b/drivers/pwm/pwm-rockchip.c
index eb8c9cb645a6..4773969346e0 100644
--- a/drivers/pwm/pwm-rockchip.c
+++ b/drivers/pwm/pwm-rockchip.c
@@ -306,13 +306,9 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
pc->clk = devm_clk_get(&pdev->dev, "pwm");
if (IS_ERR(pc->clk)) {
pc->clk = devm_clk_get(&pdev->dev, NULL);
- if (IS_ERR(pc->clk)) {
- ret = PTR_ERR(pc->clk);
- if (ret != -EPROBE_DEFER)
- dev_err(&pdev->dev, "Can't get bus clk: %d\n",
- ret);
- return ret;
- }
+ if (IS_ERR(pc->clk))
+ return dev_err_probe(&pdev->dev, PTR_ERR(pc->clk),
+ "Can't get bus clk\n");
}

count = of_count_phandle_with_args(pdev->dev.of_node,
--
2.17.1

2020-08-26 17:24:48

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH 1/6] pwm: bcm2835: Simplify with dev_err_probe()

On 8/26/20 7:47 AM, Krzysztof Kozlowski wrote:
> Common pattern of handling deferred probe can be simplified with
> dev_err_probe(). Less code and also it prints the error value.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>

Acked-by: Florian Fainelli <[email protected]>
--
Florian

2020-08-26 17:44:27

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 4/6] pwm: sifive: Simplify with dev_err_probe()

Common pattern of handling deferred probe can be simplified with
dev_err_probe(). Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/pwm/pwm-sifive.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/pwm/pwm-sifive.c b/drivers/pwm/pwm-sifive.c
index 62de0bb85921..2485fbaaead2 100644
--- a/drivers/pwm/pwm-sifive.c
+++ b/drivers/pwm/pwm-sifive.c
@@ -254,11 +254,9 @@ static int pwm_sifive_probe(struct platform_device *pdev)
return PTR_ERR(ddata->regs);

ddata->clk = devm_clk_get(dev, NULL);
- if (IS_ERR(ddata->clk)) {
- if (PTR_ERR(ddata->clk) != -EPROBE_DEFER)
- dev_err(dev, "Unable to find controller clock\n");
- return PTR_ERR(ddata->clk);
- }
+ if (IS_ERR(ddata->clk))
+ return dev_err_probe(dev, PTR_ERR(ddata->clk),
+ "Unable to find controller clock\n");

ret = clk_prepare_enable(ddata->clk);
if (ret) {
--
2.17.1

2020-08-27 02:04:34

by Chunyan Zhang

[permalink] [raw]
Subject: Re: [PATCH 5/6] pwm: sprd: Simplify with dev_err_probe()

On Wed, 26 Aug 2020 at 22:48, Krzysztof Kozlowski <[email protected]> wrote:
>
> Common pattern of handling deferred probe can be simplified with
> dev_err_probe(). Less code and also it prints the error value.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>

Acked-by: Chunyan Zhang <[email protected]>

Thanks!

> ---
> drivers/pwm/pwm-sprd.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pwm/pwm-sprd.c b/drivers/pwm/pwm-sprd.c
> index be2394227423..5123d948efd6 100644
> --- a/drivers/pwm/pwm-sprd.c
> +++ b/drivers/pwm/pwm-sprd.c
> @@ -228,11 +228,8 @@ static int sprd_pwm_clk_init(struct sprd_pwm_chip *spc)
> if (ret == -ENOENT)
> break;
>
> - if (ret != -EPROBE_DEFER)
> - dev_err(spc->dev,
> - "failed to get channel clocks\n");
> -
> - return ret;
> + return dev_err_probe(spc->dev, ret,
> + "failed to get channel clocks\n");
> }
>
> clk_pwm = chn->clks[SPRD_PWM_CHN_OUTPUT_CLK].clk;
> --
> 2.17.1
>

2020-09-02 07:13:56

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH 1/6] pwm: bcm2835: Simplify with dev_err_probe()

On Wed, Aug 26, 2020 at 04:47:42PM +0200, Krzysztof Kozlowski wrote:
> Common pattern of handling deferred probe can be simplified with
> dev_err_probe(). Less code and also it prints the error value.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>

Acked-by: Uwe Kleine-K?nig <[email protected]>

Thanks
Uwe


Attachments:
(No filename) (343.00 B)
signature.asc (499.00 B)
Download all attachments

2020-09-02 07:14:20

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH 2/6] pwm: jz4740: Simplify with dev_err_probe()

On Wed, Aug 26, 2020 at 04:47:43PM +0200, Krzysztof Kozlowski wrote:
> Common pattern of handling deferred probe can be simplified with
> dev_err_probe(). Less code and also it prints the error value.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>

Acked-by: Uwe Kleine-K?nig <[email protected]>

Thanks
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | https://www.pengutronix.de/ |


Attachments:
(No filename) (502.00 B)
signature.asc (499.00 B)
Download all attachments

2020-09-02 07:16:43

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH 4/6] pwm: sifive: Simplify with dev_err_probe()

On Wed, Aug 26, 2020 at 04:47:45PM +0200, Krzysztof Kozlowski wrote:
> Common pattern of handling deferred probe can be simplified with
> dev_err_probe(). Less code and also it prints the error value.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
Acked-by: Uwe Kleine-K?nig <[email protected]>

Thanks
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | https://www.pengutronix.de/ |


Attachments:
(No filename) (500.00 B)
signature.asc (499.00 B)
Download all attachments

2020-09-02 07:17:00

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH 3/6] pwm: rockchip: Simplify with dev_err_probe()

On Wed, Aug 26, 2020 at 04:47:44PM +0200, Krzysztof Kozlowski wrote:
> Common pattern of handling deferred probe can be simplified with
> dev_err_probe(). Less code and also it prints the error value.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>

Acked-by: Uwe Kleine-K?nig <[email protected]>

Thanks
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | https://www.pengutronix.de/ |


Attachments:
(No filename) (502.00 B)
signature.asc (499.00 B)
Download all attachments

2020-09-02 07:17:04

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH 5/6] pwm: sprd: Simplify with dev_err_probe()

Hello,

On Wed, Aug 26, 2020 at 04:47:46PM +0200, Krzysztof Kozlowski wrote:
> Common pattern of handling deferred probe can be simplified with
> dev_err_probe(). Less code and also it prints the error value.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>

Acked-by: Uwe Kleine-K?nig <[email protected]>

Thanks
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | https://www.pengutronix.de/ |


Attachments:
(No filename) (512.00 B)
signature.asc (499.00 B)
Download all attachments

2020-09-02 07:19:11

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH 6/6] pwm: sun4i: Simplify with dev_err_probe()

On Wed, Aug 26, 2020 at 04:47:47PM +0200, Krzysztof Kozlowski wrote:
> Common pattern of handling deferred probe can be simplified with
> dev_err_probe(). Less code and also it prints the error value.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>

Acked-by: Uwe Kleine-K?nig <[email protected]>

Thanks
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | https://www.pengutronix.de/ |


Attachments:
(No filename) (502.00 B)
signature.asc (499.00 B)
Download all attachments

2020-09-23 12:02:17

by Thierry Reding

[permalink] [raw]
Subject: Re: [PATCH 1/6] pwm: bcm2835: Simplify with dev_err_probe()

On Wed, Aug 26, 2020 at 04:47:42PM +0200, Krzysztof Kozlowski wrote:
> Common pattern of handling deferred probe can be simplified with
> dev_err_probe(). Less code and also it prints the error value.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> ---
> drivers/pwm/pwm-bcm2835.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)

Applied, thanks.

Thierry


Attachments:
(No filename) (401.00 B)
signature.asc (849.00 B)
Download all attachments