Commit 2fa98705 authored by Oleksandr Suvorov's avatar Oleksandr Suvorov Committed by Mark Brown

spi: fsl-lpspi: remove unneeded array

- replace the array with the shift operation
- remove the extra comparing operation.
Signed-off-by: default avatarOleksandr Suvorov <oleksandr.suvorov@toradex.com>
Link: https://lore.kernel.org/r/20200220141143.3902922-2-oleksandr.suvorov@toradex.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 788bfc6e
...@@ -86,8 +86,6 @@ ...@@ -86,8 +86,6 @@
#define TCR_RXMSK BIT(19) #define TCR_RXMSK BIT(19)
#define TCR_TXMSK BIT(18) #define TCR_TXMSK BIT(18)
static int clkdivs[] = {1, 2, 4, 8, 16, 32, 64, 128};
struct lpspi_config { struct lpspi_config {
u8 bpw; u8 bpw;
u8 chip_select; u8 chip_select;
...@@ -331,15 +329,14 @@ static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi) ...@@ -331,15 +329,14 @@ static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi)
} }
for (prescale = 0; prescale < 8; prescale++) { for (prescale = 0; prescale < 8; prescale++) {
scldiv = perclk_rate / scldiv = perclk_rate / config.speed_hz / (1 << prescale) - 2;
(clkdivs[prescale] * config.speed_hz) - 2;
if (scldiv < 256) { if (scldiv < 256) {
fsl_lpspi->config.prescale = prescale; fsl_lpspi->config.prescale = prescale;
break; break;
} }
} }
if (prescale == 8 && scldiv >= 256) if (scldiv >= 256)
return -EINVAL; return -EINVAL;
writel(scldiv | (scldiv << 8) | ((scldiv >> 1) << 16), writel(scldiv | (scldiv << 8) | ((scldiv >> 1) << 16),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment