diff mbox series

spi: spi-fsl-lpspi: Fix off-by-one in prescale max

Message ID 20240905111537.90389-1-wahrenst@gmx.net (mailing list archive)
State New
Headers show
Series spi: spi-fsl-lpspi: Fix off-by-one in prescale max | expand

Commit Message

Stefan Wahren Sept. 5, 2024, 11:15 a.m. UTC
The commit 783bf5d09f86 ("spi: spi-fsl-lpspi: limit PRESCALE bit in
TCR register") doesn't implement the prescaler maximum as intended.
The maximum allowed value for i.MX93 should be 1 and for i.MX7ULP
it should be 7. So this needs also a adjustment of the comparison
in the scldiv calculation.

Fixes: 783bf5d09f86 ("spi: spi-fsl-lpspi: limit PRESCALE bit in TCR register")
Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 drivers/spi/spi-fsl-lpspi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--
2.34.1

Comments

Mark Brown Sept. 5, 2024, 2:20 p.m. UTC | #1
On Thu, 05 Sep 2024 13:15:37 +0200, Stefan Wahren wrote:
> The commit 783bf5d09f86 ("spi: spi-fsl-lpspi: limit PRESCALE bit in
> TCR register") doesn't implement the prescaler maximum as intended.
> The maximum allowed value for i.MX93 should be 1 and for i.MX7ULP
> it should be 7. So this needs also a adjustment of the comparison
> in the scldiv calculation.
> 
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: spi-fsl-lpspi: Fix off-by-one in prescale max
      commit: ff949d981c775332be94be70397ee1df20bc68e5

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
diff mbox series

Patch

diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
index 350c5d91d869..8ecb426be45c 100644
--- a/drivers/spi/spi-fsl-lpspi.c
+++ b/drivers/spi/spi-fsl-lpspi.c
@@ -136,7 +136,7 @@  static struct fsl_lpspi_devtype_data imx93_lpspi_devtype_data = {
 };

 static struct fsl_lpspi_devtype_data imx7ulp_lpspi_devtype_data = {
-	.prescale_max = 8,
+	.prescale_max = 7,
 };

 static const struct of_device_id fsl_lpspi_dt_ids[] = {
@@ -336,7 +336,7 @@  static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi)

 	div = DIV_ROUND_UP(perclk_rate, config.speed_hz);

-	for (prescale = 0; prescale < prescale_max; prescale++) {
+	for (prescale = 0; prescale <= prescale_max; prescale++) {
 		scldiv = div / (1 << prescale) - 2;
 		if (scldiv < 256) {
 			fsl_lpspi->config.prescale = prescale;