summaryrefslogtreecommitdiff
path: root/drivers/spi/spi-dw.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2015-02-24 14:32:12 +0300
committerMark Brown <broonie@kernel.org>2015-02-24 17:43:34 +0300
commit341c7dc7c074e80d7344e0d75e2b8918ffc982fb (patch)
tree0ecbe7107f54a5dd6efcfe6dd93bfb6e9f107d09 /drivers/spi/spi-dw.c
parentea11370fffdfedbd0cca0fce17907d2c993246bc (diff)
downloadlinux-341c7dc7c074e80d7344e0d75e2b8918ffc982fb.tar.xz
spi: dw: refactor code that handles clk_div
This patch does the following changes: a) the calculation of clk_div is simplified to oneliner; b) chip->clk_div is updated if clk_div is not zero, therefore the condition is simplified by using chip->clk_div in both cases; c) while here, the redundant parentheses are removed. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-dw.c')
-rw-r--r--drivers/spi/spi-dw.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index 0febb97ae32f..0e0c48b37b83 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -416,12 +416,11 @@ static void pump_transfers(unsigned long data)
if (transfer->speed_hz) {
speed = chip->speed_hz;
- if ((transfer->speed_hz != speed) || (!chip->clk_div)) {
+ if ((transfer->speed_hz != speed) || !chip->clk_div) {
speed = transfer->speed_hz;
/* clk_div doesn't support odd number */
- clk_div = dws->max_freq / speed;
- clk_div = (clk_div + 1) & 0xfffe;
+ clk_div = (dws->max_freq / speed + 1) & 0xfffe;
chip->speed_hz = speed;
chip->clk_div = clk_div;
@@ -480,7 +479,7 @@ static void pump_transfers(unsigned long data)
if (dw_readw(dws, DW_SPI_CTRL0) != cr0)
dw_writew(dws, DW_SPI_CTRL0, cr0);
- spi_set_clk(dws, clk_div ? clk_div : chip->clk_div);
+ spi_set_clk(dws, chip->clk_div);
spi_chip_sel(dws, spi, 1);
/* Set the interrupt mask, for poll mode just disable all int */