spi: convert transfer delay to new spi_delay struct
Subsystems (2)
cover spi: convert transfer delay to new spi_delay struct
This resolves the TODO comment in spi_transfer_one_message().
Only one driver (mc13xxx) was using the delay_usecs field, making this a straightforward conversion with minimal impact.
Bo Sun (1):
spi: convert transfer delay to new spi_delay struct
drivers/mfd/mc13xxx.c | 5 ++++- drivers/spi/spi.c | 4 +--- include/spi/spi.h | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-)
PATCH 1/1 spi: convert transfer delay to new spi_delay struct
Replace the deprecated delay_usecs field with the new spi_delay struct in spi_transfer structure. Update spi_transfer_one_message to use spi_delay_exec and the mc13xxx driver to use the new structure.
--- drivers/mfd/mc13xxx.c | 5 ++++- drivers/spi/spi.c | 4 +--- include/spi/spi.h | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-)
drivers/mfd/mc13xxx.c +4 -1
@@ -84,7 +84,10 @@ static int spi_rw(struct spi_device *spi, void * buf, size_t len) .rx_buf = buf, .len = len, .cs_change = 0, - .delay_usecs = 0, + .delay = { + .value = 0, + .unit = SPI_DELAY_UNIT_USECS, + }, };struct spi_message m;
drivers/spi/spi.c +1 -3
@@ -463,9 +463,7 @@ static int spi_transfer_one_message(struct spi_device *spi, struct spi_message *if (msg->status != -EINPROGRESS ) goto out; -/* TODO: Convert to new spi_delay API */ -if (xfer->delay_usecs) -udelay (xfer->delay_usecs); +spi_delay_exec (&xfer->delay,NULL );if (xfer->cs_change) { if (list_is_last(&xfer->transfer_list,
include/spi/spi.h +4 -4
@@ -413,9 +413,9 @@ static inline size_t spi_max_transfer_size(struct spi_device *spi)* @bits_per_word: select a bits_per_word other then the device default * for this transfer. If 0 the default (from @spi_device) is used. * @cs_change: affects chipselect after this transfer completes -* @delay_usecs: microseconds to delay after this transfer before -* (optionally) changing the chipselect status, then starting -* the next transfer or completing this @spi_message. +* @delay: delay to be introduced after this transfer before +* (optionally) changing the chipselect status, then starting +* the next transfer or completing this @spi_message. * @transfer_list: transfers are sequenced through @spi_message.transfers * * SPI transfers always write the same number of bytes as they read.
@@ -476,7 +476,7 @@ struct spi_transfer { unsigned cs_change:1;u8 bits_per_word; -u16 delay_usecs; +struct spi_delay delay;u32 speed_hz;u32 effective_speed_hz;
Sascha Hauer
AppliedQuoted 5 lines · Bo Sun
Replace the deprecated
delay_usecsfield with the newspi_delaystruct inspi_transferstructure. Updatespi_transfer_one_messageto usespi_delay_execand the mc13xxx driver to use the new structure.
Applied, thanks!
[1/1] spi: convert transfer delay to new spi_delay struct
https://git.pengutronix.de/cgit/barebox/commit/?id=b66fab5c7425 (link may not be stable)
Best regards,
Signature · 1 line
Sascha Hauer <[email protected]>
Hi,
Quoted 16 lines · Bo Sun
Replace the deprecated
delay_usecsfield with the newspi_delaystruct inspi_transferstructure. Updatespi_transfer_one_messageto usespi_delay_execand the mc13xxx driver to use the new structure.Signed-off-by Bo Sun <[email protected]>--- drivers/mfd/mc13xxx.c | 5 ++++- drivers/spi/spi.c | 4 +--- include/spi/spi.h | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-)drivers/mfd/mc13xxx.c +0
-0
drivers/mfd/mc13xxx.c static int spi_rw(struct spi_device *spi, void * buf, size_t len) · line 87
Quoted 4 lines
drivers/mfd/mc13xxx.c +0
-1@@ -84,7 +84,10 @@ static int spi_rw(struct spi_device *spi, void * buf, size_t len) .rx_buf = buf, .len = len, .cs_change = 0, - .delay_usecs = 0,
It's initialized to 0, so
if (xfer->delay_usecs)
udelay(xfer->delay_usecs);will do just nothing.
drivers/mfd/mc13xxx.c static int spi_rw(struct spi_device *spi, void * buf, size_t len) · line 90
Quoted 4 lines
drivers/mfd/mc13xxx.c +4
-0+ .delay = { + .value = 0, + .unit = SPI_DELAY_UNIT_USECS, + },
I just dropped this and adjusted the commit message accordingly.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Quoted 30 lines · Sascha Hauer
Hi,
Quoted 16 lines · Bo Sun
Replace the deprecated
delay_usecsfield with the newspi_delaystruct inspi_transferstructure. Updatespi_transfer_one_messageto usespi_delay_execand the mc13xxx driver to use the new structure.Signed-off-by Bo Sun <[email protected]>--- drivers/mfd/mc13xxx.c | 5 ++++- drivers/spi/spi.c | 4 +--- include/spi/spi.h | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-)drivers/mfd/mc13xxx.c +0
-0drivers/mfd/mc13xxx.c static int spi_rw(struct spi_device *spi, void * · line 88
Quoted 5 lines
drivers/mfd/mc13xxx.c +0
-1@@ -84,7 +84,10 @@ static int spi_rw(struct spi_device *spi, void * buf, size_t len) .rx_buf = buf, .len = len, .cs_change = 0, - .delay_usecs = 0,It's initialized to 0, so
if (xfer->delay_usecs) udelay(xfer->delay_usecs);
Quoted 8 lines
will do just nothing.
drivers/mfd/mc13xxx.c static int spi_rw(struct spi_device *spi, void * buf, size_t len) · line 90
Quoted 4 lines
drivers/mfd/mc13xxx.c +4
-0+ .delay = { + .value = 0, + .unit = SPI_DELAY_UNIT_USECS, + },I just dropped this and adjusted the commit message accordingly.
Thanks, and sorry for the oversight.
Bo
Quoted 2 lines
Sascha