[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240730032040.3156393-2-liudingyuan@huawei.com>
Date: Tue, 30 Jul 2024 11:20:39 +0800
From: Devyn Liu <liudingyuan@...wei.com>
To: <f.fangjian@...wei.com>, <broonie@...nel.org>
CC: <linux-spi@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<jonathan.cameron@...wei.com>, <salil.mehta@...wei.com>,
<shameerali.kolothum.thodi@...wei.com>, <shiju.jose@...wei.com>,
<liuyonglong@...wei.com>, <yangyicong@...wei.com>, <yisen.zhuang@...wei.com>,
<kong.kongxinwei@...ilicon.com>, <liudingyuan@...wei.com>
Subject: [PATCH 1/2] 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@...wei.com>
Reviewed-by: Jay Fang <f.fangjian@...wei.com>
---
drivers/spi/spi-hisi-kunpeng.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/spi/spi-hisi-kunpeng.c b/drivers/spi/spi-hisi-kunpeng.c
index 77e9738e42f6..6910b4d4c427 100644
--- a/drivers/spi/spi-hisi-kunpeng.c
+++ b/drivers/spi/spi-hisi-kunpeng.c
@@ -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);
--
2.33.0
Powered by blists - more mailing lists