summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lechner <dlechner@baylibre.com>2023-12-04 20:33:31 +0300
committerMark Brown <broonie@kernel.org>2023-12-06 17:19:33 +0300
commite006c181dd9ab006d7b0982d35ef7951fbffe825 (patch)
tree9673c0c7890bfddff2e4657e65f341aaef65cbdd
parentbe9070bcf67057b7b03c5acc1980d3897448ad20 (diff)
downloadlinux-e006c181dd9ab006d7b0982d35ef7951fbffe825.tar.xz
spi: axi-spi-engine: remove xfer arg from spi_engine_gen_sleep()
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> Acked-by: Michael Hennerich <michael.hennerich@analog.com> Acked-by: Nuno Sa <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20231204-axi-spi-engine-series-2-v1-5-063672323fce@baylibre.com Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/spi/spi-axi-spi-engine.c10
1 files changed, 5 insertions, 5 deletions
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)) {