* [PATCH v2] pwm: rockchip: Convert to use dev_err_probe()
@ 2022-08-18 7:55 ` zhaoxiao
0 siblings, 0 replies; 9+ messages in thread
From: zhaoxiao @ 2022-08-18 7:55 UTC (permalink / raw)
To: thierry.reding, heiko
Cc: u.kleine-koenig, linux-pwm, linux-arm-kernel, linux-rockchip,
linux-kernel, zhaoxiao
It's fine to call dev_err_probe() in ->probe() when error code is known.
Convert the driver to use dev_err_probe().
Signed-off-by: zhaoxiao <zhaoxiao@uniontech.com>
---
v2: remove the %d in the message.
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 f3647b317152..c6e088c1a6bf 100644
--- a/drivers/pwm/pwm-rockchip.c
+++ b/drivers/pwm/pwm-rockchip.c
@@ -330,16 +330,12 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
if (IS_ERR(pc->pclk)) {
ret = PTR_ERR(pc->pclk);
- if (ret != -EPROBE_DEFER)
- dev_err(&pdev->dev, "Can't get APB clk: %d\n", ret);
- return ret;
+ return dev_err_probe(&pdev->dev, ret, "Can't get APB clk\n");
}
ret = clk_prepare_enable(pc->clk);
- if (ret) {
- dev_err(&pdev->dev, "Can't prepare enable PWM clk: %d\n", ret);
- return ret;
- }
+ if (ret)
+ dev_err_probe(&pdev->dev, ret, "Can't prepare enable PWM clk\n");
ret = clk_prepare_enable(pc->pclk);
if (ret) {
--
2.20.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2] pwm: rockchip: Convert to use dev_err_probe()
@ 2022-08-18 7:55 ` zhaoxiao
0 siblings, 0 replies; 9+ messages in thread
From: zhaoxiao @ 2022-08-18 7:55 UTC (permalink / raw)
To: thierry.reding, heiko
Cc: u.kleine-koenig, linux-pwm, linux-arm-kernel, linux-rockchip,
linux-kernel, zhaoxiao
It's fine to call dev_err_probe() in ->probe() when error code is known.
Convert the driver to use dev_err_probe().
Signed-off-by: zhaoxiao <zhaoxiao@uniontech.com>
---
v2: remove the %d in the message.
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 f3647b317152..c6e088c1a6bf 100644
--- a/drivers/pwm/pwm-rockchip.c
+++ b/drivers/pwm/pwm-rockchip.c
@@ -330,16 +330,12 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
if (IS_ERR(pc->pclk)) {
ret = PTR_ERR(pc->pclk);
- if (ret != -EPROBE_DEFER)
- dev_err(&pdev->dev, "Can't get APB clk: %d\n", ret);
- return ret;
+ return dev_err_probe(&pdev->dev, ret, "Can't get APB clk\n");
}
ret = clk_prepare_enable(pc->clk);
- if (ret) {
- dev_err(&pdev->dev, "Can't prepare enable PWM clk: %d\n", ret);
- return ret;
- }
+ if (ret)
+ dev_err_probe(&pdev->dev, ret, "Can't prepare enable PWM clk\n");
ret = clk_prepare_enable(pc->pclk);
if (ret) {
--
2.20.1
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2] pwm: rockchip: Convert to use dev_err_probe()
@ 2022-08-18 7:55 ` zhaoxiao
0 siblings, 0 replies; 9+ messages in thread
From: zhaoxiao @ 2022-08-18 7:55 UTC (permalink / raw)
To: thierry.reding, heiko
Cc: u.kleine-koenig, linux-pwm, linux-arm-kernel, linux-rockchip,
linux-kernel, zhaoxiao
It's fine to call dev_err_probe() in ->probe() when error code is known.
Convert the driver to use dev_err_probe().
Signed-off-by: zhaoxiao <zhaoxiao@uniontech.com>
---
v2: remove the %d in the message.
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 f3647b317152..c6e088c1a6bf 100644
--- a/drivers/pwm/pwm-rockchip.c
+++ b/drivers/pwm/pwm-rockchip.c
@@ -330,16 +330,12 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
if (IS_ERR(pc->pclk)) {
ret = PTR_ERR(pc->pclk);
- if (ret != -EPROBE_DEFER)
- dev_err(&pdev->dev, "Can't get APB clk: %d\n", ret);
- return ret;
+ return dev_err_probe(&pdev->dev, ret, "Can't get APB clk\n");
}
ret = clk_prepare_enable(pc->clk);
- if (ret) {
- dev_err(&pdev->dev, "Can't prepare enable PWM clk: %d\n", ret);
- return ret;
- }
+ if (ret)
+ dev_err_probe(&pdev->dev, ret, "Can't prepare enable PWM clk\n");
ret = clk_prepare_enable(pc->pclk);
if (ret) {
--
2.20.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2] pwm: rockchip: Convert to use dev_err_probe()
2022-08-18 7:55 ` zhaoxiao
(?)
@ 2022-08-18 9:26 ` Uwe Kleine-König
-1 siblings, 0 replies; 9+ messages in thread
From: Uwe Kleine-König @ 2022-08-18 9:26 UTC (permalink / raw)
To: zhaoxiao
Cc: thierry.reding, heiko, linux-pwm, linux-arm-kernel,
linux-rockchip, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2034 bytes --]
Hello,
On Thu, Aug 18, 2022 at 03:55:03PM +0800, zhaoxiao wrote:
> It's fine to call dev_err_probe() in ->probe() when error code is known.
> Convert the driver to use dev_err_probe().
>
> Signed-off-by: zhaoxiao <zhaoxiao@uniontech.com>
Is zhaoxiao your real name, or is that a nickname/pseudonym? If the
latter please use your real name here. See
Documentation/process/submitting-patches.rst for the justification.
> ---
> v2: remove the %d in the message.
>
> 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 f3647b317152..c6e088c1a6bf 100644
> --- a/drivers/pwm/pwm-rockchip.c
> +++ b/drivers/pwm/pwm-rockchip.c
> @@ -330,16 +330,12 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
>
> if (IS_ERR(pc->pclk)) {
> ret = PTR_ERR(pc->pclk);
> - if (ret != -EPROBE_DEFER)
> - dev_err(&pdev->dev, "Can't get APB clk: %d\n", ret);
> - return ret;
> + return dev_err_probe(&pdev->dev, ret, "Can't get APB clk\n");
> }
This could be further simplified (as pointed out in the (implicit) v1)
to:
if (IS_ERR(pc->pclk))
return dev_err_probe(&pdev->dev, PTR_ERR(pc->pclk), "Can't get APB clk\n");
but I wouldn't insist on that one as it's somewhat subjective if you
like it better on two lines.
>
> ret = clk_prepare_enable(pc->clk);
> - if (ret) {
> - dev_err(&pdev->dev, "Can't prepare enable PWM clk: %d\n", ret);
> - return ret;
> - }
> + if (ret)
> + dev_err_probe(&pdev->dev, ret, "Can't prepare enable PWM clk\n");
>
> ret = clk_prepare_enable(pc->pclk);
> if (ret) {
The context here continues with:
dev_err(&pdev->dev, "Can't prepare enable APB clk: %d\n", ret);
this could benefit from dev_err_probe(), too.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] pwm: rockchip: Convert to use dev_err_probe()
@ 2022-08-18 9:26 ` Uwe Kleine-König
0 siblings, 0 replies; 9+ messages in thread
From: Uwe Kleine-König @ 2022-08-18 9:26 UTC (permalink / raw)
To: zhaoxiao
Cc: thierry.reding, heiko, linux-pwm, linux-arm-kernel,
linux-rockchip, linux-kernel
[-- Attachment #1.1: Type: text/plain, Size: 2034 bytes --]
Hello,
On Thu, Aug 18, 2022 at 03:55:03PM +0800, zhaoxiao wrote:
> It's fine to call dev_err_probe() in ->probe() when error code is known.
> Convert the driver to use dev_err_probe().
>
> Signed-off-by: zhaoxiao <zhaoxiao@uniontech.com>
Is zhaoxiao your real name, or is that a nickname/pseudonym? If the
latter please use your real name here. See
Documentation/process/submitting-patches.rst for the justification.
> ---
> v2: remove the %d in the message.
>
> 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 f3647b317152..c6e088c1a6bf 100644
> --- a/drivers/pwm/pwm-rockchip.c
> +++ b/drivers/pwm/pwm-rockchip.c
> @@ -330,16 +330,12 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
>
> if (IS_ERR(pc->pclk)) {
> ret = PTR_ERR(pc->pclk);
> - if (ret != -EPROBE_DEFER)
> - dev_err(&pdev->dev, "Can't get APB clk: %d\n", ret);
> - return ret;
> + return dev_err_probe(&pdev->dev, ret, "Can't get APB clk\n");
> }
This could be further simplified (as pointed out in the (implicit) v1)
to:
if (IS_ERR(pc->pclk))
return dev_err_probe(&pdev->dev, PTR_ERR(pc->pclk), "Can't get APB clk\n");
but I wouldn't insist on that one as it's somewhat subjective if you
like it better on two lines.
>
> ret = clk_prepare_enable(pc->clk);
> - if (ret) {
> - dev_err(&pdev->dev, "Can't prepare enable PWM clk: %d\n", ret);
> - return ret;
> - }
> + if (ret)
> + dev_err_probe(&pdev->dev, ret, "Can't prepare enable PWM clk\n");
>
> ret = clk_prepare_enable(pc->pclk);
> if (ret) {
The context here continues with:
dev_err(&pdev->dev, "Can't prepare enable APB clk: %d\n", ret);
this could benefit from dev_err_probe(), too.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] pwm: rockchip: Convert to use dev_err_probe()
@ 2022-08-18 9:26 ` Uwe Kleine-König
0 siblings, 0 replies; 9+ messages in thread
From: Uwe Kleine-König @ 2022-08-18 9:26 UTC (permalink / raw)
To: zhaoxiao
Cc: thierry.reding, heiko, linux-pwm, linux-arm-kernel,
linux-rockchip, linux-kernel
[-- Attachment #1.1: Type: text/plain, Size: 2034 bytes --]
Hello,
On Thu, Aug 18, 2022 at 03:55:03PM +0800, zhaoxiao wrote:
> It's fine to call dev_err_probe() in ->probe() when error code is known.
> Convert the driver to use dev_err_probe().
>
> Signed-off-by: zhaoxiao <zhaoxiao@uniontech.com>
Is zhaoxiao your real name, or is that a nickname/pseudonym? If the
latter please use your real name here. See
Documentation/process/submitting-patches.rst for the justification.
> ---
> v2: remove the %d in the message.
>
> 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 f3647b317152..c6e088c1a6bf 100644
> --- a/drivers/pwm/pwm-rockchip.c
> +++ b/drivers/pwm/pwm-rockchip.c
> @@ -330,16 +330,12 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
>
> if (IS_ERR(pc->pclk)) {
> ret = PTR_ERR(pc->pclk);
> - if (ret != -EPROBE_DEFER)
> - dev_err(&pdev->dev, "Can't get APB clk: %d\n", ret);
> - return ret;
> + return dev_err_probe(&pdev->dev, ret, "Can't get APB clk\n");
> }
This could be further simplified (as pointed out in the (implicit) v1)
to:
if (IS_ERR(pc->pclk))
return dev_err_probe(&pdev->dev, PTR_ERR(pc->pclk), "Can't get APB clk\n");
but I wouldn't insist on that one as it's somewhat subjective if you
like it better on two lines.
>
> ret = clk_prepare_enable(pc->clk);
> - if (ret) {
> - dev_err(&pdev->dev, "Can't prepare enable PWM clk: %d\n", ret);
> - return ret;
> - }
> + if (ret)
> + dev_err_probe(&pdev->dev, ret, "Can't prepare enable PWM clk\n");
>
> ret = clk_prepare_enable(pc->pclk);
> if (ret) {
The context here continues with:
dev_err(&pdev->dev, "Can't prepare enable APB clk: %d\n", ret);
this could benefit from dev_err_probe(), too.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] pwm: rockchip: Convert to use dev_err_probe()
2022-08-18 7:55 ` zhaoxiao
(?)
@ 2022-08-18 20:14 ` Christophe JAILLET
-1 siblings, 0 replies; 9+ messages in thread
From: Christophe JAILLET @ 2022-08-18 20:14 UTC (permalink / raw)
To: zhaoxiao, thierry.reding, heiko
Cc: u.kleine-koenig, linux-pwm, linux-arm-kernel, linux-rockchip,
linux-kernel
Le 18/08/2022 à 09:55, zhaoxiao a écrit :
> It's fine to call dev_err_probe() in ->probe() when error code is known.
> Convert the driver to use dev_err_probe().
>
> Signed-off-by: zhaoxiao <zhaoxiao@uniontech.com>
> ---
> v2: remove the %d in the message.
Hi,
You did more than that.
>
> 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 f3647b317152..c6e088c1a6bf 100644
> --- a/drivers/pwm/pwm-rockchip.c
> +++ b/drivers/pwm/pwm-rockchip.c
> @@ -330,16 +330,12 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
>
> if (IS_ERR(pc->pclk)) {
> ret = PTR_ERR(pc->pclk);
> - if (ret != -EPROBE_DEFER)
> - dev_err(&pdev->dev, "Can't get APB clk: %d\n", ret);
> - return ret;
> + return dev_err_probe(&pdev->dev, ret, "Can't get APB clk\n");
> }
You could use PTR_ERR(pc->pclk) directly. There is no need to assign it
to 'ret'. This would simplify even further the code. ({} can be removed)
>
> ret = clk_prepare_enable(pc->clk);
> - if (ret) {
> - dev_err(&pdev->dev, "Can't prepare enable PWM clk: %d\n", ret);
> - return ret;
> - }
> + if (ret)
> + dev_err_probe(&pdev->dev, ret, "Can't prepare enable PWM clk\n");
Is a 'return' before dev_err_probe() missing?
Before we were returning the error code, now we ignore it and continue.
If done on purpose, you should explain why in the commit log.
>
> ret = clk_prepare_enable(pc->pclk);
> if (ret) {
Why just converting 2 dev_err() and leaving the other one in the probe
untouched?
CJ
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] pwm: rockchip: Convert to use dev_err_probe()
@ 2022-08-18 20:14 ` Christophe JAILLET
0 siblings, 0 replies; 9+ messages in thread
From: Christophe JAILLET @ 2022-08-18 20:14 UTC (permalink / raw)
To: zhaoxiao, thierry.reding, heiko
Cc: u.kleine-koenig, linux-pwm, linux-arm-kernel, linux-rockchip,
linux-kernel
Le 18/08/2022 à 09:55, zhaoxiao a écrit :
> It's fine to call dev_err_probe() in ->probe() when error code is known.
> Convert the driver to use dev_err_probe().
>
> Signed-off-by: zhaoxiao <zhaoxiao@uniontech.com>
> ---
> v2: remove the %d in the message.
Hi,
You did more than that.
>
> 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 f3647b317152..c6e088c1a6bf 100644
> --- a/drivers/pwm/pwm-rockchip.c
> +++ b/drivers/pwm/pwm-rockchip.c
> @@ -330,16 +330,12 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
>
> if (IS_ERR(pc->pclk)) {
> ret = PTR_ERR(pc->pclk);
> - if (ret != -EPROBE_DEFER)
> - dev_err(&pdev->dev, "Can't get APB clk: %d\n", ret);
> - return ret;
> + return dev_err_probe(&pdev->dev, ret, "Can't get APB clk\n");
> }
You could use PTR_ERR(pc->pclk) directly. There is no need to assign it
to 'ret'. This would simplify even further the code. ({} can be removed)
>
> ret = clk_prepare_enable(pc->clk);
> - if (ret) {
> - dev_err(&pdev->dev, "Can't prepare enable PWM clk: %d\n", ret);
> - return ret;
> - }
> + if (ret)
> + dev_err_probe(&pdev->dev, ret, "Can't prepare enable PWM clk\n");
Is a 'return' before dev_err_probe() missing?
Before we were returning the error code, now we ignore it and continue.
If done on purpose, you should explain why in the commit log.
>
> ret = clk_prepare_enable(pc->pclk);
> if (ret) {
Why just converting 2 dev_err() and leaving the other one in the probe
untouched?
CJ
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] pwm: rockchip: Convert to use dev_err_probe()
@ 2022-08-18 20:14 ` Christophe JAILLET
0 siblings, 0 replies; 9+ messages in thread
From: Christophe JAILLET @ 2022-08-18 20:14 UTC (permalink / raw)
To: zhaoxiao, thierry.reding, heiko
Cc: u.kleine-koenig, linux-pwm, linux-arm-kernel, linux-rockchip,
linux-kernel
Le 18/08/2022 à 09:55, zhaoxiao a écrit :
> It's fine to call dev_err_probe() in ->probe() when error code is known.
> Convert the driver to use dev_err_probe().
>
> Signed-off-by: zhaoxiao <zhaoxiao@uniontech.com>
> ---
> v2: remove the %d in the message.
Hi,
You did more than that.
>
> 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 f3647b317152..c6e088c1a6bf 100644
> --- a/drivers/pwm/pwm-rockchip.c
> +++ b/drivers/pwm/pwm-rockchip.c
> @@ -330,16 +330,12 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
>
> if (IS_ERR(pc->pclk)) {
> ret = PTR_ERR(pc->pclk);
> - if (ret != -EPROBE_DEFER)
> - dev_err(&pdev->dev, "Can't get APB clk: %d\n", ret);
> - return ret;
> + return dev_err_probe(&pdev->dev, ret, "Can't get APB clk\n");
> }
You could use PTR_ERR(pc->pclk) directly. There is no need to assign it
to 'ret'. This would simplify even further the code. ({} can be removed)
>
> ret = clk_prepare_enable(pc->clk);
> - if (ret) {
> - dev_err(&pdev->dev, "Can't prepare enable PWM clk: %d\n", ret);
> - return ret;
> - }
> + if (ret)
> + dev_err_probe(&pdev->dev, ret, "Can't prepare enable PWM clk\n");
Is a 'return' before dev_err_probe() missing?
Before we were returning the error code, now we ignore it and continue.
If done on purpose, you should explain why in the commit log.
>
> ret = clk_prepare_enable(pc->pclk);
> if (ret) {
Why just converting 2 dev_err() and leaving the other one in the probe
untouched?
CJ
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-08-18 20:16 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-18 7:55 [PATCH v2] pwm: rockchip: Convert to use dev_err_probe() zhaoxiao
2022-08-18 7:55 ` zhaoxiao
2022-08-18 7:55 ` zhaoxiao
2022-08-18 9:26 ` Uwe Kleine-König
2022-08-18 9:26 ` Uwe Kleine-König
2022-08-18 9:26 ` Uwe Kleine-König
2022-08-18 20:14 ` Christophe JAILLET
2022-08-18 20:14 ` Christophe JAILLET
2022-08-18 20:14 ` Christophe JAILLET
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.