Unverified Commit 9342fc96 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!7141 spi: hisi-kunpeng: Add validation for the minimum value of speed_hz

Merge Pull Request from: @lujunhuaHW 
 
We get the configuration of max_frequency from the firmware, which is
used to calculate the clk_div together with the set speed. If the
speed set by the user is too small, it may cause the clk_div to be too
large to exceed the variable range. Therefore, we limit the minimum
value of the speed configuration to the value obtained by
(master->max_speed_hz/CLK_DIV_MAX).

issue:https://gitee.com/openeuler/kernel/issues/I9O7EH 
 
Link:https://gitee.com/openeuler/kernel/pulls/7141

 

Signed-off-by: default avatarZhang Peng <zhangpeng362@huawei.com>
parents 57348257 51291a22
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -481,6 +481,12 @@ static int hisi_spi_probe(struct platform_device *pdev)
		return -EINVAL;
	}

	if (host->max_speed_hz == 0) {
		dev_err(dev, "invalid max SPI clocking speed, max-freq=%u\n",
				host->max_speed_hz);
		return -EINVAL;
	}

	ret = device_property_read_u16(dev, "num-cs",
					&host->num_chipselect);
	if (ret)
@@ -495,6 +501,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);