History

spi: spi-fsl-espi: convert transfer delay to `spi_delay` format

The way the max delay is computed for this controller, it looks like it is searching for the max delay from an SPI message a using that. No idea if this is valid. But this change should support both `delay_usecs` and the new `delay` data which is of `spi_delay` type.

Alexandru Ardelean committed 7 years ago

Commit 3984d391 parent 25093bd3 files · +19 −7Browse files

Unified · Split

3 files
  1. drivers/spi/spi-fsl-espi.c +13 −3
  2. drivers/spi/spi.c +5 −4
  3. include/linux/spi/spi.h +1 −0
drivers/spi/spi-fsl-espi.c+13−3
@@ -437,6 +437,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, · 436 unmodified lines
437437 struct spi_message *m)
438438 {
439439 unsigned int delay_usecs = 0, rx_nbits = 0;
440+ unsigned int delay_nsecs = 0, delay_nsecs1 = 0;
440441 struct spi_transfer *t, trans = {};
441442 int ret;
442443
@@ -445,8 +446,16 @@ static int fsl_espi_do_one_msg(struct spi_master *master, · 2 unmodified lines
445446 goto out;
446447
447448 list_for_each_entry(t, &m->transfers, transfer_list) {
448− if (t->delay_usecs > delay_usecs)
449− delay_usecs = t->delay_usecs;
449+ if (t->delay_usecs) {
450+ if (t->delay_usecs > delay_usecs) {
451+ delay_usecs = t->delay_usecs;
452+ delay_nsecs = delay_usecs * 1000;
453+ }
454+ } else {
455+ delay_nsecs1 = spi_delay_to_ns(&t->delay, t);
456+ if (delay_nsecs1 > delay_nsecs)
457+ delay_nsecs = delay_nsecs1;
458+ }
450459 if (t->rx_nbits > rx_nbits)
451460 rx_nbits = t->rx_nbits;
452461 }
@@ -457,7 +466,8 @@ static int fsl_espi_do_one_msg(struct spi_master *master, · 4 unmodified lines
457466 trans.len = m->frame_length;
458467 trans.speed_hz = t->speed_hz;
459468 trans.bits_per_word = t->bits_per_word;
460− trans.delay_usecs = delay_usecs;
469+ trans.delay.value = delay_nsecs;
470+ trans.delay.unit = SPI_DELAY_UNIT_NSECS;
461471 trans.rx_nbits = rx_nbits;
462472
463473 if (trans.len)
drivers/spi/spi.c+5−4
@@ -1120,7 +1120,7 @@ static void _spi_transfer_delay_ns(u32 ns) · 1119 unmodified lines
11201120 }
11211121 }
11221122
1123−static int _spi_delay_to_ns(struct spi_delay *_delay, struct spi_transfer *xfer)
1123+int spi_delay_to_ns(struct spi_delay *_delay, struct spi_transfer *xfer)
11241124 {
11251125 u32 delay = _delay->value;
11261126 u32 unit = _delay->unit;
@@ -1153,6 +1153,7 @@ static int _spi_delay_to_ns(struct spi_delay *_delay, struct spi_transfer *xfer) · 26 unmodified lines
11531153
11541154 return delay;
11551155 }
1156+EXPORT_SYMBOL_GPL(spi_delay_to_ns);
11561157
11571158 int spi_delay_exec(struct spi_delay *_delay, struct spi_transfer *xfer)
11581159 {
@@ -1161,7 +1162,7 @@ int spi_delay_exec(struct spi_delay *_delay, struct spi_transfer *xfer) · 2 unmodified lines
11611162 if (!_delay)
11621163 return -EINVAL;
11631164
1164− delay = _spi_delay_to_ns(_delay, xfer);
1165+ delay = spi_delay_to_ns(_delay, xfer);
11651166 if (delay < 0)
11661167 return delay;
11671168
@@ -3333,11 +3334,11 @@ static int _spi_xfer_word_delay_update(struct spi_transfer *xfer, · 2165 unmodified lines
33333334 {
33343335 int delay1, delay2;
33353336
3336− delay1 = _spi_delay_to_ns(&xfer->word_delay, xfer);
3337+ delay1 = spi_delay_to_ns(&xfer->word_delay, xfer);
33373338 if (delay1 < 0)
33383339 return delay1;
33393340
3340− delay2 = _spi_delay_to_ns(&spi->word_delay, xfer);
3341+ delay2 = spi_delay_to_ns(&spi->word_delay, xfer);
33413342 if (delay2 < 0)
33423343 return delay2;
33433344
include/linux/spi/spi.h+1−0
@@ -103,6 +103,7 @@ struct spi_delay { · 102 unmodified lines
103103 u8 unit;
104104 };
105105
106+extern int spi_delay_to_ns(struct spi_delay *_delay, struct spi_transfer *xfer);
106107 extern int spi_delay_exec(struct spi_delay *_delay, struct spi_transfer *xfer);
107108
108109 /**

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t