[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <873edfae-a174-4f3d-a9cb-bb9126fa461a@huawei.com>
Date: Thu, 29 Aug 2024 09:34:49 +0800
From: Hongbo Li <lihongbo22@...wei.com>
To: Alvin Šipraga <ALSI@...g-olufsen.dk>
CC: "linus.walleij@...aro.org" <linus.walleij@...aro.org>, "andrew@...n.ch"
<andrew@...n.ch>, "f.fainelli@...il.com" <f.fainelli@...il.com>,
"olteanv@...il.com" <olteanv@...il.com>, "davem@...emloft.net"
<davem@...emloft.net>, "edumazet@...gle.com" <edumazet@...gle.com>,
"kuba@...nel.org" <kuba@...nel.org>, "pabeni@...hat.com" <pabeni@...hat.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: [PATCH net-next] net: dsa: realtek: make use of
dev_err_cast_probe()
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@...wei.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@...g-olufsen.dk>
Powered by blists - more mailing lists