Re: [PATCH 2/2] net: stmmac: dwmac-rk: Validate rockchip,grf and php-grf during probe
From: Jonas Karlman
Date: Thu Mar 06 2025 - 18:14:45 EST
On 2025-03-06 22:21, Russell King (Oracle) wrote:
> On Thu, Mar 06, 2025 at 09:09:46PM +0000, Jonas Karlman wrote:
>> @@ -1813,8 +1564,24 @@ static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,
>>
>> bsp_priv->grf = syscon_regmap_lookup_by_phandle(dev->of_node,
>> "rockchip,grf");
>> - bsp_priv->php_grf = syscon_regmap_lookup_by_phandle(dev->of_node,
>> - "rockchip,php-grf");
>> + if (IS_ERR(bsp_priv->grf)) {
>> + ret = PTR_ERR(bsp_priv->grf);
>> + dev_err_probe(dev, ret, "failed to lookup rockchip,grf\n");
>> + return ERR_PTR(ret);
>
> Did you consider using ERR_CAST() for these, which would look like this:
>
> dev_err_probe(dev, PTR_ERR(bsp_priv->grf),
> "failed to lookup rockchip,grf\n");
> return ERR_CAST(bsp_priv->grf);
>
> ?
>
No, I did not, I only duplicated the same handling that was done for
the "failed to get phy regulator" case a little bit earlier in the
rk_gmac_setup() function.
I can adjust this (and the regulator case) to use ERR_CAST in a v2.
Regards,
Jonas