2020-02-27 14:48:02

by Sergiu Cuciurean

[permalink] [raw]
Subject: [PATCH] staging: kpc2000: kpc2000_spi: Use new structure for SPI transfer delays

In a recent change to the SPI subsystem [1], a new `delay` struct was added
to replace the `delay_usecs`. This change replaces the current
`delay_usecs` with `delay` for this driver.

The `spi_transfer_delay_exec()` function [in the SPI framework] makes sure
that both `delay_usecs` & `delay` are used (in this order to preserve
backwards compatibility).

[1] commit bebcfd272df6 ("spi: introduce `delay` field for
`spi_transfer` + spi_transfer_delay_exec()")

Signed-off-by: Sergiu Cuciurean <[email protected]>
---
drivers/staging/kpc2000/kpc2000_spi.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c
index 1c360daa703d..cc9b147fd437 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -386,8 +386,9 @@ kp_spi_transfer_one_message(struct spi_master *master, struct spi_message *m)
}
}

- if (transfer->delay_usecs)
- udelay(transfer->delay_usecs);
+ if (transfer->delay.value &&
+ (transfer->delay.unit == SPI_DELAY_UNIT_USECS))
+ udelay(transfer->delay.value);
}

/* de-assert chip select to end the sequence */
--
2.17.1


2020-03-02 07:46:43

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH] staging: kpc2000: kpc2000_spi: Use new structure for SPI transfer delays

On Thu, Feb 27, 2020 at 04:46:43PM +0200, Sergiu Cuciurean wrote:
> In a recent change to the SPI subsystem [1], a new `delay` struct was added

Don't do [1] footnote, just say "SPI subsystem in commit bebcfd272df6
("spi: introduce `delay` field for `spi_transfer` + spi_transfer_delay_exec()")
You can use footnotes for URLs if you want (not required).

> to replace the `delay_usecs`. This change replaces the current
> `delay_usecs` with `delay` for this driver.
>
> The `spi_transfer_delay_exec()` function [in the SPI framework] makes sure
> that both `delay_usecs` & `delay` are used (in this order to preserve
> backwards compatibility).
>
> [1] commit bebcfd272df6 ("spi: introduce `delay` field for
> `spi_transfer` + spi_transfer_delay_exec()")
>
> Signed-off-by: Sergiu Cuciurean <[email protected]>
> ---
> drivers/staging/kpc2000/kpc2000_spi.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c
> index 1c360daa703d..cc9b147fd437 100644
> --- a/drivers/staging/kpc2000/kpc2000_spi.c
> +++ b/drivers/staging/kpc2000/kpc2000_spi.c
> @@ -386,8 +386,9 @@ kp_spi_transfer_one_message(struct spi_master *master, struct spi_message *m)
> }
> }
>
> - if (transfer->delay_usecs)
> - udelay(transfer->delay_usecs);
> + if (transfer->delay.value &&
> + (transfer->delay.unit == SPI_DELAY_UNIT_USECS))
> + udelay(transfer->delay.value);

What if the units are in USEC now? We should probably not just ignore
it right?

regards,
dan carpenter

2020-03-04 07:39:05

by Sergiu Cuciurean

[permalink] [raw]
Subject: [PATCH v2] staging: kpc2000: kpc2000_spi: Use new structure for SPI transfer delays

In a recent change to the SPI subsystem in commit <bebcfd272df6>
("spi: introduce `delay` field for `spi_transfer` +
spi_transfer_delay_exec()"), a new `delay` struct was added
to replace the `delay_usecs`. This change replaces the current
`delay_usecs` with `delay` for this driver.

The `spi_transfer_delay_exec()` function [in the SPI framework] makes sure
that both `delay_usecs` & `delay` are used (in this order to preserve
backwards compatibility).

Signed-off-by: Sergiu Cuciurean <[email protected]>
---

Changelog v1->v2:
*Removed footnote from the commit description
*Convert the delay in nano seconds. In this way, the delay is executed no
matter what unit it is described by.

drivers/staging/kpc2000/kpc2000_spi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c
index 1c360daa703d..44017d523da5 100644
--- a/drivers/staging/kpc2000/kpc2000_spi.c
+++ b/drivers/staging/kpc2000/kpc2000_spi.c
@@ -386,8 +386,8 @@ kp_spi_transfer_one_message(struct spi_master *master, struct spi_message *m)
}
}

- if (transfer->delay_usecs)
- udelay(transfer->delay_usecs);
+ if (transfer->delay.value)
+ ndelay(spi_delay_to_ns(&transfer->delay, transfer));
}

/* de-assert chip select to end the sequence */
--
2.17.1