Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: xcomm: Remove duplicate code to set default bits_per_word and max speed

In the implementation of __spi_validate(), spi core will set transfer
bits_per_word and max speed as spi device default if it is not set for
this transfer. So we can remove the same logic in spi_xcomm_setup_transfer().
Also remove a redundant code to initialize is_first variable.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>

authored by

Axel Lin and committed by
Mark Brown
af348519 38dbfb59

+4 -8
+4 -8
drivers/spi/spi-xcomm.c
··· 74 74 static int spi_xcomm_setup_transfer(struct spi_xcomm *spi_xcomm, 75 75 struct spi_device *spi, struct spi_transfer *t, unsigned int *settings) 76 76 { 77 - unsigned int speed; 78 - 79 77 if (t->len > 62) 80 78 return -EINVAL; 81 79 82 - speed = t->speed_hz ? t->speed_hz : spi->max_speed_hz; 80 + if (t->speed_hz != spi_xcomm->current_speed) { 81 + unsigned int divider; 83 82 84 - if (speed != spi_xcomm->current_speed) { 85 - unsigned int divider = DIV_ROUND_UP(SPI_XCOMM_CLOCK, speed); 83 + divider = DIV_ROUND_UP(SPI_XCOMM_CLOCK, t->speed_hz); 86 84 if (divider >= 64) 87 85 *settings |= SPI_XCOMM_SETTINGS_CLOCK_DIV_64; 88 86 else if (divider >= 16) ··· 88 90 else 89 91 *settings |= SPI_XCOMM_SETTINGS_CLOCK_DIV_4; 90 92 91 - spi_xcomm->current_speed = speed; 93 + spi_xcomm->current_speed = t->speed_hz; 92 94 } 93 95 94 96 if (spi->mode & SPI_CPOL) ··· 145 147 bool is_first = true; 146 148 int status = 0; 147 149 bool is_last; 148 - 149 - is_first = true; 150 150 151 151 spi_xcomm_chipselect(spi_xcomm, spi, true); 152 152