netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: dsa: realtek: make use of dev_err_cast_probe()
@ 2024-08-28 12:18 Hongbo Li
  2024-08-28 15:51 ` Andrew Lunn
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Hongbo Li @ 2024-08-28 12:18 UTC (permalink / raw)
  To: linus.walleij, alsi, andrew, f.fainelli, olteanv, davem, edumazet,
	kuba, pabeni
  Cc: netdev, lihongbo22

Using dev_err_cast_probe() to simplify the code.

Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
 drivers/net/dsa/realtek/rtl83xx.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c
index 35709a1756ae..3c5018d5e1f9 100644
--- a/drivers/net/dsa/realtek/rtl83xx.c
+++ b/drivers/net/dsa/realtek/rtl83xx.c
@@ -185,11 +185,9 @@ rtl83xx_probe(struct device *dev,
 
 	/* TODO: if power is software controlled, set up any regulators here */
 	priv->reset_ctl = devm_reset_control_get_optional(dev, NULL);
-	if (IS_ERR(priv->reset_ctl)) {
-		ret = PTR_ERR(priv->reset_ctl);
-		dev_err_probe(dev, ret, "failed to get reset control\n");
-		return ERR_CAST(priv->reset_ctl);
-	}
+	if (IS_ERR(priv->reset_ctl))
+		return dev_err_cast_probe(dev, priv->reset_ctl,
+					  "failed to get reset control\n");
 
 	priv->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
 	if (IS_ERR(priv->reset)) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] net: dsa: realtek: make use of dev_err_cast_probe()
  2024-08-28 12:18 [PATCH net-next] net: dsa: realtek: make use of dev_err_cast_probe() Hongbo Li
@ 2024-08-28 15:51 ` Andrew Lunn
  2024-08-28 16:14 ` Alvin Šipraga
  2024-08-29 19:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2024-08-28 15:51 UTC (permalink / raw)
  To: Hongbo Li
  Cc: linus.walleij, alsi, f.fainelli, olteanv, davem, edumazet, kuba,
	pabeni, netdev

On Wed, Aug 28, 2024 at 08:18:05PM +0800, Hongbo Li wrote:
> Using dev_err_cast_probe() to simplify the code.
> 
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] net: dsa: realtek: make use of dev_err_cast_probe()
  2024-08-28 12:18 [PATCH net-next] net: dsa: realtek: make use of dev_err_cast_probe() Hongbo Li
  2024-08-28 15:51 ` Andrew Lunn
@ 2024-08-28 16:14 ` Alvin Šipraga
  2024-08-29  1:34   ` Hongbo Li
  2024-08-29 19:00 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 5+ messages in thread
From: Alvin Šipraga @ 2024-08-28 16:14 UTC (permalink / raw)
  To: Hongbo Li
  Cc: linus.walleij@linaro.org, andrew@lunn.ch, f.fainelli@gmail.com,
	olteanv@gmail.com, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org

On Wed, Aug 28, 2024 at 08:18:05PM GMT, Hongbo Li wrote:
> Using dev_err_cast_probe() to simplify the code.
> 
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> ---
>  drivers/net/dsa/realtek/rtl83xx.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c
> index 35709a1756ae..3c5018d5e1f9 100644
> --- a/drivers/net/dsa/realtek/rtl83xx.c
> +++ b/drivers/net/dsa/realtek/rtl83xx.c
> @@ -185,11 +185,9 @@ rtl83xx_probe(struct device *dev,
> 
>         /* TODO: if power is software controlled, set up any regulators here */
>         priv->reset_ctl = devm_reset_control_get_optional(dev, NULL);
> -       if (IS_ERR(priv->reset_ctl)) {
> -               ret = PTR_ERR(priv->reset_ctl);
> -               dev_err_probe(dev, ret, "failed to get reset control\n");
> -               return ERR_CAST(priv->reset_ctl);
> -       }
> +       if (IS_ERR(priv->reset_ctl))
> +               return dev_err_cast_probe(dev, priv->reset_ctl,
> +                                         "failed to get reset control\n");

The change is fine, but maybe it would be nice to fix up the other two
similar cases as well? The errors would be stringified but that's OK.

   159          rc.lock_arg = priv;
   160          priv->map = devm_regmap_init(dev, NULL, priv, &rc);
   161          if (IS_ERR(priv->map)) {
   162                  ret = PTR_ERR(priv->map);
   163                  dev_err(dev, "regmap init failed: %d\n", ret);
   164                  return ERR_PTR(ret);
   165          }
   166  
   167          rc.disable_locking = true;
   168          priv->map_nolock = devm_regmap_init(dev, NULL, priv, &rc);
   169          if (IS_ERR(priv->map_nolock)) {
   170                  ret = PTR_ERR(priv->map_nolock);
   171                  dev_err(dev, "regmap init failed: %d\n", ret);
   172                  return ERR_PTR(ret);
   173          }

Then you can remove the ret variable altogether.

Either way,

Reviewed-by: Alvin Šipraga <alsi@bang-olufsen.dk>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] net: dsa: realtek: make use of dev_err_cast_probe()
  2024-08-28 16:14 ` Alvin Šipraga
@ 2024-08-29  1:34   ` Hongbo Li
  0 siblings, 0 replies; 5+ messages in thread
From: Hongbo Li @ 2024-08-29  1:34 UTC (permalink / raw)
  To: Alvin Šipraga
  Cc: linus.walleij@linaro.org, andrew@lunn.ch, f.fainelli@gmail.com,
	olteanv@gmail.com, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org



On 2024/8/29 0:14, Alvin Šipraga wrote:
> On Wed, Aug 28, 2024 at 08:18:05PM GMT, Hongbo Li wrote:
>> Using dev_err_cast_probe() to simplify the code.
>>
>> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
>> ---
>>   drivers/net/dsa/realtek/rtl83xx.c | 8 +++-----
>>   1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c
>> index 35709a1756ae..3c5018d5e1f9 100644
>> --- a/drivers/net/dsa/realtek/rtl83xx.c
>> +++ b/drivers/net/dsa/realtek/rtl83xx.c
>> @@ -185,11 +185,9 @@ rtl83xx_probe(struct device *dev,
>>
>>          /* TODO: if power is software controlled, set up any regulators here */
>>          priv->reset_ctl = devm_reset_control_get_optional(dev, NULL);
>> -       if (IS_ERR(priv->reset_ctl)) {
>> -               ret = PTR_ERR(priv->reset_ctl);
>> -               dev_err_probe(dev, ret, "failed to get reset control\n");
>> -               return ERR_CAST(priv->reset_ctl);
>> -       }
>> +       if (IS_ERR(priv->reset_ctl))
>> +               return dev_err_cast_probe(dev, priv->reset_ctl,
>> +                                         "failed to get reset control\n");
> 
> The change is fine, but maybe it would be nice to fix up the other two
> similar cases as well? The errors would be stringified but that's OK.
> 
>     159          rc.lock_arg = priv;
>     160          priv->map = devm_regmap_init(dev, NULL, priv, &rc);
>     161          if (IS_ERR(priv->map)) {
>     162                  ret = PTR_ERR(priv->map);
>     163                  dev_err(dev, "regmap init failed: %d\n", ret);
>     164                  return ERR_PTR(ret);
It's similar, but not the same. Now we just have the dev_err_cast_probe 
which wraps the dev_err_probe. The dev_err_probe is not completely 
equivalent to dev_err.

Thanks,
Hongbo

>     165          }
>     166
>     167          rc.disable_locking = true;
>     168          priv->map_nolock = devm_regmap_init(dev, NULL, priv, &rc);
>     169          if (IS_ERR(priv->map_nolock)) {
>     170                  ret = PTR_ERR(priv->map_nolock);
>     171                  dev_err(dev, "regmap init failed: %d\n", ret);
>     172                  return ERR_PTR(ret);
>     173          }
> 
> Then you can remove the ret variable altogether.
> 
> Either way,
> 
> Reviewed-by: Alvin Šipraga <alsi@bang-olufsen.dk>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] net: dsa: realtek: make use of dev_err_cast_probe()
  2024-08-28 12:18 [PATCH net-next] net: dsa: realtek: make use of dev_err_cast_probe() Hongbo Li
  2024-08-28 15:51 ` Andrew Lunn
  2024-08-28 16:14 ` Alvin Šipraga
@ 2024-08-29 19:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-08-29 19:00 UTC (permalink / raw)
  To: Hongbo Li
  Cc: linus.walleij, alsi, andrew, f.fainelli, olteanv, davem, edumazet,
	kuba, pabeni, netdev

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 28 Aug 2024 20:18:05 +0800 you wrote:
> Using dev_err_cast_probe() to simplify the code.
> 
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> ---
>  drivers/net/dsa/realtek/rtl83xx.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)

Here is the summary with links:
  - [net-next] net: dsa: realtek: make use of dev_err_cast_probe()
    https://git.kernel.org/netdev/net-next/c/9023fda2f186

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-08-29 19:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-28 12:18 [PATCH net-next] net: dsa: realtek: make use of dev_err_cast_probe() Hongbo Li
2024-08-28 15:51 ` Andrew Lunn
2024-08-28 16:14 ` Alvin Šipraga
2024-08-29  1:34   ` Hongbo Li
2024-08-29 19:00 ` patchwork-bot+netdevbpf

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).