aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-omap-100k.c
diff options
context:
space:
mode:
authorJarkko Nikula <jarkko.nikula@linux.intel.com>2015-09-15 09:26:21 -0400
committerMark Brown <broonie@kernel.org>2015-09-17 07:34:20 -0400
commit76f67ea9bf27b045eacf8f1e148fd13149f51823 (patch)
tree8beaf78c07e1db3899c2c7ac6fff468c38b4e48d /drivers/spi/spi-omap-100k.c
parent6ff33f3902c3b1c5d0db6b1e2c70b6d76fba357f (diff)
spi: omap-100k: Rely on validations done by spi core
SPI core validates both bits_per_word and speed_hz transfer parameters and defaults to spi->bits_per_word and spi->max_speed_hz in case these per transfer parameters are not set. This allows to remove a few if statements around per transfer bits_per_word and speed_hz tests as they evaluate always to true. Also defaulting word_len to 8 is needless since spi_setup() has already made sure spi->bits_per_word is 8 in case it is not set. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-omap-100k.c')
-rw-r--r--drivers/spi/spi-omap-100k.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/drivers/spi/spi-omap-100k.c b/drivers/spi/spi-omap-100k.c
index 35b332dacb13..76a8425be227 100644
--- a/drivers/spi/spi-omap-100k.c
+++ b/drivers/spi/spi-omap-100k.c
@@ -244,12 +244,12 @@ static int omap1_spi100k_setup_transfer(struct spi_device *spi,
244{ 244{
245 struct omap1_spi100k *spi100k = spi_master_get_devdata(spi->master); 245 struct omap1_spi100k *spi100k = spi_master_get_devdata(spi->master);
246 struct omap1_spi100k_cs *cs = spi->controller_state; 246 struct omap1_spi100k_cs *cs = spi->controller_state;
247 u8 word_len = spi->bits_per_word; 247 u8 word_len;
248 248
249 if (t != NULL && t->bits_per_word) 249 if (t != NULL)
250 word_len = t->bits_per_word; 250 word_len = t->bits_per_word;
251 if (!word_len) 251 else
252 word_len = 8; 252 word_len = spi->bits_per_word;
253 253
254 if (spi->bits_per_word > 32) 254 if (spi->bits_per_word > 32)
255 return -EINVAL; 255 return -EINVAL;
@@ -302,7 +302,6 @@ static int omap1_spi100k_transfer_one_message(struct spi_master *master,
302 struct spi_device *spi = m->spi; 302 struct spi_device *spi = m->spi;
303 struct spi_transfer *t = NULL; 303 struct spi_transfer *t = NULL;
304 int cs_active = 0; 304 int cs_active = 0;
305 int par_override = 0;
306 int status = 0; 305 int status = 0;
307 306
308 list_for_each_entry(t, &m->transfers, transfer_list) { 307 list_for_each_entry(t, &m->transfers, transfer_list) {
@@ -310,14 +309,9 @@ static int omap1_spi100k_transfer_one_message(struct spi_master *master,
310 status = -EINVAL; 309 status = -EINVAL;
311 break; 310 break;
312 } 311 }
313 if (par_override || t->speed_hz || t->bits_per_word) { 312 status = omap1_spi100k_setup_transfer(spi, t);
314 par_override = 1; 313 if (status < 0)
315 status = omap1_spi100k_setup_transfer(spi, t); 314 break;
316 if (status < 0)
317 break;
318 if (!t->speed_hz && !t->bits_per_word)
319 par_override = 0;
320 }
321 315
322 if (!cs_active) { 316 if (!cs_active) {
323 omap1_spi100k_force_cs(spi100k, 1); 317 omap1_spi100k_force_cs(spi100k, 1);
@@ -347,11 +341,7 @@ static int omap1_spi100k_transfer_one_message(struct spi_master *master,
347 } 341 }
348 } 342 }
349 343
350 /* Restore defaults if they were overriden */ 344 status = omap1_spi100k_setup_transfer(spi, NULL);
351 if (par_override) {
352 par_override = 0;
353 status = omap1_spi100k_setup_transfer(spi, NULL);
354 }
355 345
356 if (cs_active) 346 if (cs_active)
357 omap1_spi100k_force_cs(spi100k, 0); 347 omap1_spi100k_force_cs(spi100k, 0);