mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/1] spi: convert transfer delay to new spi_delay struct
@ 2025-06-27 12:28 Bo Sun
  2025-06-27 12:28 ` [PATCH 1/1] " Bo Sun
  0 siblings, 1 reply; 2+ messages in thread
From: Bo Sun @ 2025-06-27 12:28 UTC (permalink / raw)
  To: barebox

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(-)




^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 1/1] spi: convert transfer delay to new spi_delay struct
  2025-06-27 12:28 [PATCH 0/1] spi: convert transfer delay to new spi_delay struct Bo Sun
@ 2025-06-27 12:28 ` Bo Sun
  0 siblings, 0 replies; 2+ messages in thread
From: Bo Sun @ 2025-06-27 12:28 UTC (permalink / raw)
  To: barebox

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.

Signed-off-by: Bo Sun <bo@mboxify.com>
---
 drivers/mfd/mc13xxx.c | 5 ++++-
 drivers/spi/spi.c     | 4 +---
 include/spi/spi.h     | 8 ++++----
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/mfd/mc13xxx.c b/drivers/mfd/mc13xxx.c
index 288bd407ff..393f163671 100644
--- a/drivers/mfd/mc13xxx.c
+++ b/drivers/mfd/mc13xxx.c
@@ -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;
 
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index f8a01dd083..b64e206649 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -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,
diff --git a/include/spi/spi.h b/include/spi/spi.h
index 5b2d345705..00337446e6 100644
--- a/include/spi/spi.h
+++ b/include/spi/spi.h
@@ -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;



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-06-27 13:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-27 12:28 [PATCH 0/1] spi: convert transfer delay to new spi_delay struct Bo Sun
2025-06-27 12:28 ` [PATCH 1/1] " Bo Sun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox