Skip to content

Commit

Permalink
spi: fsl-lpspi: remove unneeded array
Browse files Browse the repository at this point in the history
- replace the array with the shift operation
- remove the extra comparing operation.

Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
Link: https://lore.kernel.org/r/20200220141143.3902922-2-oleksandr.suvorov@toradex.com
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Oleksandr Suvorov authored and Mark Brown committed Mar 3, 2020
1 parent 788bfc6 commit 2fa9870
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions drivers/spi/spi-fsl-lpspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@
#define TCR_RXMSK BIT(19)
#define TCR_TXMSK BIT(18)

static int clkdivs[] = {1, 2, 4, 8, 16, 32, 64, 128};

struct lpspi_config {
u8 bpw;
u8 chip_select;
Expand Down Expand Up @@ -331,15 +329,14 @@ static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi)
}

for (prescale = 0; prescale < 8; prescale++) {
scldiv = perclk_rate /
(clkdivs[prescale] * config.speed_hz) - 2;
scldiv = perclk_rate / config.speed_hz / (1 << prescale) - 2;
if (scldiv < 256) {
fsl_lpspi->config.prescale = prescale;
break;
}
}

if (prescale == 8 && scldiv >= 256)
if (scldiv >= 256)
return -EINVAL;

writel(scldiv | (scldiv << 8) | ((scldiv >> 1) << 16),
Expand Down

0 comments on commit 2fa9870

Please sign in to comment.