From: Devyn Liu <liudingyuan@huawei.com>
To: <f.fangjian@huawei.com>, <broonie@kernel.org>
Cc: <linux-spi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<jonathan.cameron@huawei.com>, <salil.mehta@huawei.com>,
<shameerali.kolothum.thodi@huawei.com>, <shiju.jose@huawei.com>,
<liuyonglong@huawei.com>, <yangyicong@huawei.com>,
<yisen.zhuang@huawei.com>, <kong.kongxinwei@hisilicon.com>,
<liudingyuan@huawei.com>
Subject: [PATCH 1/2] spi: hisi-kunpeng: Add validation for the minimum value of speed_hz
Date: Tue, 30 Jul 2024 11:20:39 +0800 [thread overview]
Message-ID: <20240730032040.3156393-2-liudingyuan@huawei.com> (raw)
In-Reply-To: <20240730032040.3156393-1-liudingyuan@huawei.com>
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>
---
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
next prev parent reply other threads:[~2024-07-30 3:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-30 3:20 [PATCH 0/2] spi: hisi-kunpeng: Set verification for speed_hz and max_frequency Devyn Liu
2024-07-30 3:20 ` Devyn Liu [this message]
2024-07-30 3:20 ` [PATCH 2/2] spi: hisi-kunpeng: Add verification for the max_frequency provided by the firmware Devyn Liu
2024-07-30 16:03 ` [PATCH 0/2] spi: hisi-kunpeng: Set verification for speed_hz and max_frequency Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240730032040.3156393-2-liudingyuan@huawei.com \
--to=liudingyuan@huawei.com \
--cc=broonie@kernel.org \
--cc=f.fangjian@huawei.com \
--cc=jonathan.cameron@huawei.com \
--cc=kong.kongxinwei@hisilicon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=liuyonglong@huawei.com \
--cc=salil.mehta@huawei.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=shiju.jose@huawei.com \
--cc=yangyicong@huawei.com \
--cc=yisen.zhuang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®