Skip to content

Commit

Permalink
spi: hisi-kunpeng: Add validation for the minimum value of speed_hz
Browse files Browse the repository at this point in the history
[ Upstream commit c3c4f22 ]

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 <[email protected]>
Reviewed-by: Jay Fang <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Mark Brown <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
Devyn Liu authored and gregkh committed Sep 8, 2024
1 parent 533e175 commit 8b28f8c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/spi/spi-hisi-kunpeng.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ static int hisi_spi_probe(struct platform_device *pdev)
host->transfer_one = hisi_spi_transfer_one;
host->handle_err = hisi_spi_handle_err;
host->dev.fwnode = dev->fwnode;
host->min_speed_hz = DIV_ROUND_UP(host->max_speed_hz, CLK_DIV_MAX);

hisi_spi_hw_init(hs);

Expand Down

0 comments on commit 8b28f8c

Please sign in to comment.