]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
spi: rzv2h-rspi: Fix silent failure in clock setup error path
authorJohn Madieu <john.madieu.xa@bp.renesas.com>
Sat, 25 Apr 2026 02:47:25 +0000 (02:47 +0000)
committerMark Brown <broonie@kernel.org>
Sun, 26 Apr 2026 21:45:08 +0000 (06:45 +0900)
rzv2h_rspi_setup_clock() is declared to return u32 but returns -EINVAL
when no valid clock parameters are found. Cast to u32, -EINVAL becomes
0xffffffea, which is a non-zero value. The caller in
rzv2h_rspi_prepare_message() guards against failure with:

rspi->freq = rzv2h_rspi_setup_clock(rspi, speed_hz);
if (!rspi->freq)
return -EINVAL;

Because 0xffffffea is non-zero, the check is bypassed and the controller
proceeds to program SPBR/SPCMD with stale values, leading to an unknown
bit rate.

Return 0 on the failed-search path, consistent with the existing
clk_set_rate() failure path which already returns 0.

Fixes: 77d931584dd3 ("spi: rzv2h-rspi: make transfer clock rate finding chip-specific")
Signed-off-by: John Madieu <john.madieu.xa@bp.renesas.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com>
Link: https://patch.msgid.link/20260425024725.2393632-1-john.madieu.xa@bp.renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-rzv2h-rspi.c

index f45af588463851e73e749e8e7262d66d244ebd88..1655efda7d20900d6a0d333ebd1a79c2999778c8 100644 (file)
@@ -579,7 +579,7 @@ static u32 rzv2h_rspi_setup_clock(struct rzv2h_rspi_priv *rspi, u32 hz)
                rspi->info->find_pclk_rate(rspi->pclk, hz, &best_clock);
 
        if (!best_clock.clk_rate)
-               return -EINVAL;
+               return 0;
 
        ret = clk_set_rate(best_clock.clk, best_clock.clk_rate);
        if (ret)