diff mbox series

[5/9] spi: axi-spi-engine: remove xfer arg from spi_engine_gen_sleep()

Message ID 20231204-axi-spi-engine-series-2-v1-5-063672323fce@baylibre.com (mailing list archive)
State Accepted
Commit e006c181dd9ab006d7b0982d35ef7951fbffe825
Headers show
Series spi: axi-spi-engine: improvements round 2 | expand

Commit Message

David Lechner Dec. 4, 2023, 5:33 p.m. UTC
This replaces the xfer parameter of spi_engine_gen_sleep() in the AXI
SPI Engine driver with parameters for the delay in nanoseconds and the
SPI SCLK rate. This will allow this function to be used by callers in
the future that do not have a spi_transfer struct.

Signed-off-by: David Lechner <dlechner@baylibre.com>
---
 drivers/spi/spi-axi-spi-engine.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c
index b3e72308fcc5..84ec37732d8b 100644
--- a/drivers/spi/spi-axi-spi-engine.c
+++ b/drivers/spi/spi-axi-spi-engine.c
@@ -168,17 +168,16 @@  static void spi_engine_gen_xfer(struct spi_engine_program *p, bool dry,
 }
 
 static void spi_engine_gen_sleep(struct spi_engine_program *p, bool dry,
-	struct spi_transfer *xfer)
+				 int delay_ns, u32 sclk_hz)
 {
 	unsigned int t;
-	int delay_ns;
 
-	delay_ns = spi_delay_to_ns(&xfer->delay, xfer);
+	/* negative delay indicates error, e.g. from spi_delay_to_ns() */
 	if (delay_ns <= 0)
 		return;
 
 	/* rounding down since executing the instruction adds a couple of ticks delay */
-	t = DIV_ROUND_DOWN_ULL((u64)delay_ns * xfer->effective_speed_hz, NSEC_PER_SEC);
+	t = DIV_ROUND_DOWN_ULL((u64)delay_ns * sclk_hz, NSEC_PER_SEC);
 	while (t) {
 		unsigned int n = min(t, 256U);
 
@@ -256,7 +255,8 @@  static void spi_engine_compile_message(struct spi_message *msg, bool dry,
 		}
 
 		spi_engine_gen_xfer(p, dry, xfer);
-		spi_engine_gen_sleep(p, dry, xfer);
+		spi_engine_gen_sleep(p, dry, spi_delay_to_ns(&xfer->delay, xfer),
+				     xfer->effective_speed_hz);
 
 		if (xfer->cs_change) {
 			if (list_is_last(&xfer->transfer_list, &msg->transfers)) {