mirror of
https://github.com/torvalds/linux.git
synced 2024-11-28 07:01:32 +00:00
spi: lpspi: run transfer speed_hz sanity check
Avoid config.speed_hz is 0 when it is a divisor. Signed-off-by: Han Xu <han.xu@nxp.com Signed-off-by: Clark Wang <xiaoning.wang@nxp.com Link: https://lore.kernel.org/r/20230505064159.3964473-1-xiaoning.wang@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org
This commit is contained in:
parent
47e0255989
commit
f571d9132e
@ -303,6 +303,12 @@ static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi)
|
||||
|
||||
perclk_rate = clk_get_rate(fsl_lpspi->clk_per);
|
||||
|
||||
if (!config.speed_hz) {
|
||||
dev_err(fsl_lpspi->dev,
|
||||
"error: the transmission speed provided is 0!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (config.speed_hz > perclk_rate / 2) {
|
||||
dev_err(fsl_lpspi->dev,
|
||||
"per-clk should be at least two times of transfer speed");
|
||||
|
Loading…
Reference in New Issue
Block a user