Skip to content

Commit c3c4f22

Browse files
Devyn Liubroonie
authored andcommitted
spi: hisi-kunpeng: Add validation for the minimum value of speed_hz
The speed specified by the user is used to calculate the clk_div based on the max_speed_hz in hisi_calc_effective_speed. A very low speed value can lead to a clk_div larger than the variable range. Avoid this by setting the min_speed_hz so that such a small speed value is rejected. __spi_validate() in spi.c will return -EINVAL for the specified speed_hz lower than min_speed_hz. Signed-off-by: Devyn Liu <liudingyuan@huawei.com> Reviewed-by: Jay Fang <f.fangjian@huawei.com> Link: https://patch.msgid.link/20240730032040.3156393-2-liudingyuan@huawei.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 8400291 commit c3c4f22

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/spi/spi-hisi-kunpeng.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ static int hisi_spi_probe(struct platform_device *pdev)
495495
host->transfer_one = hisi_spi_transfer_one;
496496
host->handle_err = hisi_spi_handle_err;
497497
host->dev.fwnode = dev->fwnode;
498+
host->min_speed_hz = DIV_ROUND_UP(host->max_speed_hz, CLK_DIV_MAX);
498499

499500
hisi_spi_hw_init(hs);
500501

0 commit comments

Comments
 (0)