diff options
author | Axel Lin <axel.lin@ingics.com> | 2014-03-02 09:48:41 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-03-03 22:19:14 -0500 |
commit | af348519e4a41eac8eae82cf3dcaeb6c1b008113 (patch) | |
tree | 6504aa74755a5791a596676c5bb0caec01c7fb46 /drivers/spi | |
parent | 38dbfb59d1175ef458d006556061adeaa8751b72 (diff) |
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>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi-xcomm.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/spi/spi-xcomm.c b/drivers/spi/spi-xcomm.c index 24c40b13dab1..2505b7e1232a 100644 --- a/drivers/spi/spi-xcomm.c +++ b/drivers/spi/spi-xcomm.c | |||
@@ -74,15 +74,13 @@ static void spi_xcomm_chipselect(struct spi_xcomm *spi_xcomm, | |||
74 | static int spi_xcomm_setup_transfer(struct spi_xcomm *spi_xcomm, | 74 | static int spi_xcomm_setup_transfer(struct spi_xcomm *spi_xcomm, |
75 | struct spi_device *spi, struct spi_transfer *t, unsigned int *settings) | 75 | struct spi_device *spi, struct spi_transfer *t, unsigned int *settings) |
76 | { | 76 | { |
77 | unsigned int speed; | ||
78 | |||
79 | if (t->len > 62) | 77 | if (t->len > 62) |
80 | return -EINVAL; | 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) { | 83 | divider = DIV_ROUND_UP(SPI_XCOMM_CLOCK, t->speed_hz); |
85 | unsigned int divider = DIV_ROUND_UP(SPI_XCOMM_CLOCK, speed); | ||
86 | if (divider >= 64) | 84 | if (divider >= 64) |
87 | *settings |= SPI_XCOMM_SETTINGS_CLOCK_DIV_64; | 85 | *settings |= SPI_XCOMM_SETTINGS_CLOCK_DIV_64; |
88 | else if (divider >= 16) | 86 | else if (divider >= 16) |
@@ -90,7 +88,7 @@ static int spi_xcomm_setup_transfer(struct spi_xcomm *spi_xcomm, | |||
90 | else | 88 | else |
91 | *settings |= SPI_XCOMM_SETTINGS_CLOCK_DIV_4; | 89 | *settings |= SPI_XCOMM_SETTINGS_CLOCK_DIV_4; |
92 | 90 | ||
93 | spi_xcomm->current_speed = speed; | 91 | spi_xcomm->current_speed = t->speed_hz; |
94 | } | 92 | } |
95 | 93 | ||
96 | if (spi->mode & SPI_CPOL) | 94 | if (spi->mode & SPI_CPOL) |
@@ -148,8 +146,6 @@ static int spi_xcomm_transfer_one(struct spi_master *master, | |||
148 | int status = 0; | 146 | int status = 0; |
149 | bool is_last; | 147 | bool is_last; |
150 | 148 | ||
151 | is_first = true; | ||
152 | |||
153 | spi_xcomm_chipselect(spi_xcomm, spi, true); | 149 | spi_xcomm_chipselect(spi_xcomm, spi, true); |
154 | 150 | ||
155 | list_for_each_entry(t, &msg->transfers, transfer_list) { | 151 | list_for_each_entry(t, &msg->transfers, transfer_list) { |