Re: [PATCH v2 3/5] spi: bcmbca-hsspi: fix division by zero for devices without a max speed

From: shao.mingyin

Date: Wed Nov 11 2026 - 04:49:06 EST


--------------------------------------------------------------------------------
On Tue, Nov 10, 2026 at 12:30:05PM -0800, William Zhang wrote:
> The bs->speed_hz is typcially 200MHz, reg(Frequency Control Word)
> will be zero when hz clamp to 1. It is not a valid reg setting. FCW
> must be 1 or larger.
> The same applies to bcm63xx-hsspi driver.

You're right -- with speed_hz ~200 MHz the clamp yields FCW = 0, and
2/5 (bcm63xx) has the same expression.

> IMHO the upper layer should fail ... rather than having the controller
> driver to override with a risky 1Hz clock.

Agreed; the fix belongs upstream of the driver, not in ->set_clk().
Mark, which do you prefer: reject max_speed_hz == 0 in spi core, or
have these two drivers clamp FCW >= 1? I'll wait for your call and
won't spin a v3 meanwhile.

Thanks,
Shao
--------------------------------------------------------------------------------