[PATCH] net: macb: simplify clk_init with dev_err_probe

Nicolas Ferre nicolas.ferre at microchip.com
Wed Mar 17 18:38:45 GMT 2021


On 17/03/2021 at 17:16, Michael Tretter wrote:
> On some platforms, e.g., the ZynqMP, devm_clk_get can return
> -EPROBE_DEFER if the clock controller, which is implemented in firmware,
> has not been probed yet.
> 
> As clk_init is only called during probe, use dev_err_probe to simplify
> the error message and hide it for -EPROBE_DEFER.
> 
> Signed-off-by: Michael Tretter <m.tretter at pengutronix.de>

Looks good to me:
Acked-by: Nicolas Ferre <nicolas.ferre at microchip.com>

Thanks Michael, regards,
   Nicolas

> ---
>   drivers/net/ethernet/cadence/macb_main.c | 20 +++++++++-----------
>   1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index e7c123aadf56..f56f3dbbc015 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -3758,17 +3758,15 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
>                  *hclk = devm_clk_get(&pdev->dev, "hclk");
>          }
> 
> -       if (IS_ERR_OR_NULL(*pclk)) {
> -               err = IS_ERR(*pclk) ? PTR_ERR(*pclk) : -ENODEV;
> -               dev_err(&pdev->dev, "failed to get macb_clk (%d)\n", err);
> -               return err;
> -       }
> -
> -       if (IS_ERR_OR_NULL(*hclk)) {
> -               err = IS_ERR(*hclk) ? PTR_ERR(*hclk) : -ENODEV;
> -               dev_err(&pdev->dev, "failed to get hclk (%d)\n", err);
> -               return err;
> -       }
> +       if (IS_ERR_OR_NULL(*pclk))
> +               return dev_err_probe(&pdev->dev,
> +                                    IS_ERR(*pclk) ? PTR_ERR(*pclk) : -ENODEV,
> +                                    "failed to get pclk\n");
> +
> +       if (IS_ERR_OR_NULL(*hclk))
> +               return dev_err_probe(&pdev->dev,
> +                                    IS_ERR(*hclk) ? PTR_ERR(*hclk) : -ENODEV,
> +                                    "failed to get hclk\n");
> 
>          *tx_clk = devm_clk_get_optional(&pdev->dev, "tx_clk");
>          if (IS_ERR(*tx_clk))
> --
> 2.29.2
> 


-- 
Nicolas Ferre



More information about the linux-arm-kernel mailing list