summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorOleksandr Suvorov <oleksandr.suvorov@toradex.com>2020-02-19 16:56:56 +0200
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2020-03-09 13:44:31 +0100
commit2a7e678d4750a7bd6f7665647e16642575c11b7c (patch)
tree6953f12a142aac5b1dfc78afb7a07c709bb1a49d /drivers
parentfd2bf9eda2a5931b8eb182e4dc2f9c765dfc3b97 (diff)
spi: fsl-lpspi: remove unneeded array
- replace the array with the shift operation - remove the extra comparing operation. Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/spi/spi-fsl-lpspi.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
index bf254287e138..8d2ebdda4fe0 100644
--- a/drivers/spi/spi-fsl-lpspi.c
+++ b/drivers/spi/spi-fsl-lpspi.c
@@ -96,8 +96,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;
@@ -335,15 +333,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),