From: Claudiu Beznea If the provider of can_clk is not yet probed, devm_clk_get() returns -EPROBE_DEFER. The driver treats any error as can_clk being absent and falls back to the other clocking options, so the wrong clock may be selected instead of deferring the probe. Request can_clk with devm_clk_get_optional() and propagate its errors. While at it, add a comment mentioning that the canfd or fck clocks are used as a fallbacks when the external clock is not available or it is described in device tree with a rate of 0. Signed-off-by: Claudiu Beznea Link: https://patch.msgid.link/20261019121356.2421761-2-claudiu.beznea@kernel.org Signed-off-by: Marc Kleine-Budde --- drivers/net/can/rcar/rcar_canfd.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index 74c3c3f20991..bb2d03b75142 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -2220,11 +2220,14 @@ static int rcar_canfd_probe(struct platform_device *pdev) return dev_err_probe(dev, PTR_ERR(gpriv->clkp), "cannot get peripheral clock\n"); - /* fCAN clock: Pick External clock. If not available fallback to - * CANFD clock + /* fCAN clock: Pick External clock. If not available or its rate is + * zero fallback to CANFD clock or fck (when info->fcan_pclk = 1). */ - gpriv->can_clk = devm_clk_get(dev, "can_clk"); - if (IS_ERR(gpriv->can_clk) || (clk_get_rate(gpriv->can_clk) == 0)) { + gpriv->can_clk = devm_clk_get_optional(dev, "can_clk"); + if (IS_ERR(gpriv->can_clk)) + return dev_err_probe(dev, PTR_ERR(gpriv->can_clk), "cannot get can_clk"); + + if (!gpriv->can_clk || (clk_get_rate(gpriv->can_clk) == 0)) { if (info->fcan_pclk) { fcan_freq = clk_get_rate(gpriv->clkp); gpriv->can_clk = NULL; -- 2.53.0