Commit ddbbed25 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Marc Kleine-Budde

can: rcar_canfd: Use dev_err_probe() to simplify code and better handle -EPROBE_DEFER

devm_clk_get() can return -EPROBE_DEFER, so use dev_err_probe() instead of
dev_err() in order to be less verbose in the log.

This also saves a few LoC.

While at it, turn a "goto fail_dev;" at the beginning of the function into
a direct return in order to avoid mixing goto and return, which looks
spurious.
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/all/f5bf0b8f757bd3bc9b391094ece3548cc2f96456.1659858686.git.christophe.jaillet@wanadoo.frSigned-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent d945346d
...@@ -1880,10 +1880,9 @@ static int rcar_canfd_probe(struct platform_device *pdev) ...@@ -1880,10 +1880,9 @@ static int rcar_canfd_probe(struct platform_device *pdev)
/* Global controller context */ /* Global controller context */
gpriv = devm_kzalloc(&pdev->dev, sizeof(*gpriv), GFP_KERNEL); gpriv = devm_kzalloc(&pdev->dev, sizeof(*gpriv), GFP_KERNEL);
if (!gpriv) { if (!gpriv)
err = -ENOMEM; return -ENOMEM;
goto fail_dev;
}
gpriv->pdev = pdev; gpriv->pdev = pdev;
gpriv->channels_mask = channels_mask; gpriv->channels_mask = channels_mask;
gpriv->fdmode = fdmode; gpriv->fdmode = fdmode;
...@@ -1904,12 +1903,9 @@ static int rcar_canfd_probe(struct platform_device *pdev) ...@@ -1904,12 +1903,9 @@ static int rcar_canfd_probe(struct platform_device *pdev)
/* Peripheral clock */ /* Peripheral clock */
gpriv->clkp = devm_clk_get(&pdev->dev, "fck"); gpriv->clkp = devm_clk_get(&pdev->dev, "fck");
if (IS_ERR(gpriv->clkp)) { if (IS_ERR(gpriv->clkp))
err = PTR_ERR(gpriv->clkp); return dev_err_probe(&pdev->dev, PTR_ERR(gpriv->clkp),
dev_err(&pdev->dev, "cannot get peripheral clock, error %d\n", "cannot get peripheral clock\n");
err);
goto fail_dev;
}
/* fCAN clock: Pick External clock. If not available fallback to /* fCAN clock: Pick External clock. If not available fallback to
* CANFD clock * CANFD clock
...@@ -1917,12 +1913,10 @@ static int rcar_canfd_probe(struct platform_device *pdev) ...@@ -1917,12 +1913,10 @@ static int rcar_canfd_probe(struct platform_device *pdev)
gpriv->can_clk = devm_clk_get(&pdev->dev, "can_clk"); gpriv->can_clk = devm_clk_get(&pdev->dev, "can_clk");
if (IS_ERR(gpriv->can_clk) || (clk_get_rate(gpriv->can_clk) == 0)) { if (IS_ERR(gpriv->can_clk) || (clk_get_rate(gpriv->can_clk) == 0)) {
gpriv->can_clk = devm_clk_get(&pdev->dev, "canfd"); gpriv->can_clk = devm_clk_get(&pdev->dev, "canfd");
if (IS_ERR(gpriv->can_clk)) { if (IS_ERR(gpriv->can_clk))
err = PTR_ERR(gpriv->can_clk); return dev_err_probe(&pdev->dev, PTR_ERR(gpriv->can_clk),
dev_err(&pdev->dev, "cannot get canfd clock\n");
"cannot get canfd clock, error %d\n", err);
goto fail_dev;
}
gpriv->fcan = RCANFD_CANFDCLK; gpriv->fcan = RCANFD_CANFDCLK;
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment