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; 5+ 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] 5+ 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
  2025-06-30  8:06   ` Sascha Hauer
  2025-06-30  8:08   ` Sascha Hauer
  0 siblings, 2 replies; 5+ 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] 5+ messages in thread

* Re: [PATCH 1/1] spi: convert transfer delay to new spi_delay struct
  2025-06-27 12:28 ` [PATCH 1/1] " Bo Sun
@ 2025-06-30  8:06   ` Sascha Hauer
  2025-06-30  8:08   ` Sascha Hauer
  1 sibling, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2025-06-30  8:06 UTC (permalink / raw)
  To: barebox, Bo Sun


On Fri, 27 Jun 2025 20:28:11 +0800, Bo Sun wrote:
> 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.
> 
> 

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,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

* Re: [PATCH 1/1] spi: convert transfer delay to new spi_delay struct
  2025-06-27 12:28 ` [PATCH 1/1] " Bo Sun
  2025-06-30  8:06   ` Sascha Hauer
@ 2025-06-30  8:08   ` Sascha Hauer
  2025-06-30  8:38     ` bo
  1 sibling, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2025-06-30  8:08 UTC (permalink / raw)
  To: Bo Sun; +Cc: barebox

Hi,

On Fri, Jun 27, 2025 at 08:28:11PM +0800, Bo Sun wrote:
> 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,

It's initialized to 0, so

             if (xfer->delay_usecs)
                     udelay(xfer->delay_usecs);

will do just nothing.

> +		.delay = {
> +			.value = 0,
> +			.unit = SPI_DELAY_UNIT_USECS,
> +		},

I just dropped this and adjusted the commit message accordingly.

Sascha

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



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

* Re: [PATCH 1/1] spi: convert transfer delay to new spi_delay struct
  2025-06-30  8:08   ` Sascha Hauer
@ 2025-06-30  8:38     ` bo
  0 siblings, 0 replies; 5+ messages in thread
From: bo @ 2025-06-30  8:38 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 2025-06-30 16:08, Sascha Hauer wrote:
> Hi,
> 
> On Fri, Jun 27, 2025 at 08:28:11PM +0800, Bo Sun wrote:
>> 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,
> 
> It's initialized to 0, so
> 
>              if (xfer->delay_usecs)
>                      udelay(xfer->delay_usecs);
> 
> will do just nothing.
> 
>> +		.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

> 
> Sascha



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

end of thread, other threads:[~2025-06-30  8:46 UTC | newest]

Thread overview: 5+ 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
2025-06-30  8:06   ` Sascha Hauer
2025-06-30  8:08   ` Sascha Hauer
2025-06-30  8:38     ` bo

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