mbox series

[00/10] spi: finalize 'delay_usecs' removal/transition

Message ID 20210308145502.1075689-1-aardelean@deviqon.com
Headers show
Series spi: finalize 'delay_usecs' removal/transition | expand

Message

Alexandru Ardelean March 8, 2021, 2:54 p.m. UTC
A while back I started the introduction of the 'spi_delay' data type:
  https://lore.kernel.org/linux-spi/20190926105147.7839-1-alexandru.ardelean@analog.com/

Users of the 'delay_usecs' were removed from drivers.

Now it's time to remove the 'delay_usecs' from the SPI subsystem and use
only the 'delay' field.

This changeset adapts all SPI drivers to do without 'delay_usecs'.
Additionally, for greybus we need to adapt it to use the 'delay' in
nano-seconds and convert it to micro-seconds.

Alexandru Ardelean (10):
  spi: spi-axi-spi-engine: remove usage of delay_usecs
  spi: bcm63xx-spi: don't check 'delay_usecs' field
  spi: spi-bcm-qspi: replace 'delay_usecs' with 'delay.value' check
  spi: spi-sh: replace 'delay_usecs' with 'delay.value' in pr_debug
  spi: spi-tegra20-flash: don't check 'delay_usecs' field for spi
    transfer
  staging: greybus: spilib: use 'spi_delay_to_ns' for getting xfer delay
  spi: spi-falcon: remove check for 'delay_usecs'
  spi: fsl-espi: remove usage of 'delay_usecs' field
  spi: core: remove 'delay_usecs' field from spi_transfer
  spi: docs: update info about 'delay_usecs'

 Documentation/spi/spi-summary.rst |  7 +++++--
 drivers/spi/spi-axi-spi-engine.c  | 12 ++++--------
 drivers/spi/spi-bcm-qspi.c        |  2 +-
 drivers/spi/spi-bcm63xx.c         |  2 +-
 drivers/spi/spi-falcon.c          |  2 +-
 drivers/spi/spi-fsl-espi.c        | 17 +++++------------
 drivers/spi/spi-sh.c              |  4 ++--
 drivers/spi/spi-tegra20-sflash.c  |  3 +--
 drivers/spi/spi.c                 |  1 -
 drivers/staging/greybus/spilib.c  |  5 ++++-
 include/linux/spi/spi.h           | 12 ------------
 11 files changed, 24 insertions(+), 43 deletions(-)

Comments

Viresh Kumar March 9, 2021, 4:28 a.m. UTC | #1
On 08-03-21, 16:54, Alexandru Ardelean wrote:
> The intent is the removal of the 'delay_usecs' field from the

> spi_transfer struct, as there is a 'delay' field that does the same

> thing.

> 

> The spi_delay_to_ns() can be used to get the transfer delay. It works by

> using the 'delay_usecs' field first (if it is non-zero), and finally

> uses the 'delay' field.

> 

> Since the 'delay_usecs' field is going away, this change makes use of the

> spi_delay_to_ns() function. This also means dividing the return value of

> the function by 1000, to convert it to microseconds.

> To prevent any potential faults when converting to microseconds and since

> the result of spi_delay_to_ns() is int, the delay is being computed in 32

> bits and then clamped between 0 & U16_MAX.

> 

> Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>

> ---

>  drivers/staging/greybus/spilib.c | 5 ++++-

>  1 file changed, 4 insertions(+), 1 deletion(-)

> 

> diff --git a/drivers/staging/greybus/spilib.c b/drivers/staging/greybus/spilib.c

> index 672d540d3365..30655153df6a 100644

> --- a/drivers/staging/greybus/spilib.c

> +++ b/drivers/staging/greybus/spilib.c

> @@ -245,6 +245,7 @@ static struct gb_operation *gb_spi_operation_create(struct gb_spilib *spi,

>  	/* Fill in the transfers array */

>  	xfer = spi->first_xfer;

>  	while (msg->state != GB_SPI_STATE_OP_DONE) {

> +		int xfer_delay;

>  		if (xfer == spi->last_xfer)

>  			xfer_len = spi->last_xfer_size;

>  		else

> @@ -259,7 +260,9 @@ static struct gb_operation *gb_spi_operation_create(struct gb_spilib *spi,

>  

>  		gb_xfer->speed_hz = cpu_to_le32(xfer->speed_hz);

>  		gb_xfer->len = cpu_to_le32(xfer_len);

> -		gb_xfer->delay_usecs = cpu_to_le16(xfer->delay_usecs);

> +		xfer_delay = spi_delay_to_ns(&xfer->delay, xfer) / 1000;

> +		xfer_delay = clamp_t(u16, xfer_delay, 0, U16_MAX);

> +		gb_xfer->delay_usecs = cpu_to_le16(xfer_delay);

>  		gb_xfer->cs_change = xfer->cs_change;

>  		gb_xfer->bits_per_word = xfer->bits_per_word;


Acked-by: Viresh Kumar <viresh.kumar@linaro.org>


-- 
viresh
Rui Miguel Silva March 9, 2021, 9:29 a.m. UTC | #2
Hi,
On Tue, Mar 09, 2021 at 09:58:09AM +0530, Viresh Kumar wrote:
> On 08-03-21, 16:54, Alexandru Ardelean wrote:

> > The intent is the removal of the 'delay_usecs' field from the

> > spi_transfer struct, as there is a 'delay' field that does the same

> > thing.

> > 

> > The spi_delay_to_ns() can be used to get the transfer delay. It works by

> > using the 'delay_usecs' field first (if it is non-zero), and finally

> > uses the 'delay' field.

> > 

> > Since the 'delay_usecs' field is going away, this change makes use of the

> > spi_delay_to_ns() function. This also means dividing the return value of

> > the function by 1000, to convert it to microseconds.

> > To prevent any potential faults when converting to microseconds and since

> > the result of spi_delay_to_ns() is int, the delay is being computed in 32

> > bits and then clamped between 0 & U16_MAX.

> > 

> > Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>

> > ---

> >  drivers/staging/greybus/spilib.c | 5 ++++-

> >  1 file changed, 4 insertions(+), 1 deletion(-)

> > 

> > diff --git a/drivers/staging/greybus/spilib.c b/drivers/staging/greybus/spilib.c

> > index 672d540d3365..30655153df6a 100644

> > --- a/drivers/staging/greybus/spilib.c

> > +++ b/drivers/staging/greybus/spilib.c

> > @@ -245,6 +245,7 @@ static struct gb_operation *gb_spi_operation_create(struct gb_spilib *spi,

> >  	/* Fill in the transfers array */

> >  	xfer = spi->first_xfer;

> >  	while (msg->state != GB_SPI_STATE_OP_DONE) {

> > +		int xfer_delay;

> >  		if (xfer == spi->last_xfer)

> >  			xfer_len = spi->last_xfer_size;

> >  		else

> > @@ -259,7 +260,9 @@ static struct gb_operation *gb_spi_operation_create(struct gb_spilib *spi,

> >  

> >  		gb_xfer->speed_hz = cpu_to_le32(xfer->speed_hz);

> >  		gb_xfer->len = cpu_to_le32(xfer_len);

> > -		gb_xfer->delay_usecs = cpu_to_le16(xfer->delay_usecs);

> > +		xfer_delay = spi_delay_to_ns(&xfer->delay, xfer) / 1000;

> > +		xfer_delay = clamp_t(u16, xfer_delay, 0, U16_MAX);

> > +		gb_xfer->delay_usecs = cpu_to_le16(xfer_delay);

> >  		gb_xfer->cs_change = xfer->cs_change;

> >  		gb_xfer->bits_per_word = xfer->bits_per_word;

> 

> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>


Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>


------
Cheers,
     Rui
Greg Kroah-Hartman March 9, 2021, 1:05 p.m. UTC | #3
On Mon, Mar 08, 2021 at 04:54:58PM +0200, Alexandru Ardelean wrote:
> The intent is the removal of the 'delay_usecs' field from the

> spi_transfer struct, as there is a 'delay' field that does the same

> thing.

> 

> The spi_delay_to_ns() can be used to get the transfer delay. It works by

> using the 'delay_usecs' field first (if it is non-zero), and finally

> uses the 'delay' field.

> 

> Since the 'delay_usecs' field is going away, this change makes use of the

> spi_delay_to_ns() function. This also means dividing the return value of

> the function by 1000, to convert it to microseconds.

> To prevent any potential faults when converting to microseconds and since

> the result of spi_delay_to_ns() is int, the delay is being computed in 32

> bits and then clamped between 0 & U16_MAX.

> 

> Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>

> ---

>  drivers/staging/greybus/spilib.c | 5 ++++-

>  1 file changed, 4 insertions(+), 1 deletion(-)

> 

> diff --git a/drivers/staging/greybus/spilib.c b/drivers/staging/greybus/spilib.c

> index 672d540d3365..30655153df6a 100644

> --- a/drivers/staging/greybus/spilib.c

> +++ b/drivers/staging/greybus/spilib.c

> @@ -245,6 +245,7 @@ static struct gb_operation *gb_spi_operation_create(struct gb_spilib *spi,

>  	/* Fill in the transfers array */

>  	xfer = spi->first_xfer;

>  	while (msg->state != GB_SPI_STATE_OP_DONE) {

> +		int xfer_delay;

>  		if (xfer == spi->last_xfer)

>  			xfer_len = spi->last_xfer_size;

>  		else

> @@ -259,7 +260,9 @@ static struct gb_operation *gb_spi_operation_create(struct gb_spilib *spi,

>  

>  		gb_xfer->speed_hz = cpu_to_le32(xfer->speed_hz);

>  		gb_xfer->len = cpu_to_le32(xfer_len);

> -		gb_xfer->delay_usecs = cpu_to_le16(xfer->delay_usecs);

> +		xfer_delay = spi_delay_to_ns(&xfer->delay, xfer) / 1000;

> +		xfer_delay = clamp_t(u16, xfer_delay, 0, U16_MAX);

> +		gb_xfer->delay_usecs = cpu_to_le16(xfer_delay);

>  		gb_xfer->cs_change = xfer->cs_change;

>  		gb_xfer->bits_per_word = xfer->bits_per_word;

>  


Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Mark Brown March 12, 2021, 8:25 p.m. UTC | #4
On Mon, 8 Mar 2021 16:54:52 +0200, Alexandru Ardelean wrote:
> A while back I started the introduction of the 'spi_delay' data type:

>   https://lore.kernel.org/linux-spi/20190926105147.7839-1-alexandru.ardelean@analog.com/

> 

> Users of the 'delay_usecs' were removed from drivers.

> 

> Now it's time to remove the 'delay_usecs' from the SPI subsystem and use

> only the 'delay' field.

> 

> [...]


Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[01/10] spi: spi-axi-spi-engine: remove usage of delay_usecs
        commit: 93c941448994a728e691f7dce9ea6475e352b09c
[02/10] spi: bcm63xx-spi: don't check 'delay_usecs' field
        commit: e7f2d4c6aacd0a2cded363bb14ef9b6e752798fd
[03/10] spi: spi-bcm-qspi: replace 'delay_usecs' with 'delay.value' check
        commit: 66a3aadec42aa001c62ae9a637398d853880a02b
[04/10] spi: spi-sh: replace 'delay_usecs' with 'delay.value' in pr_debug
        commit: 506d1a1b441e058e318d8d81141295ff76927367
[05/10] spi: spi-tegra20-flash: don't check 'delay_usecs' field for spi transfer
        commit: 7ca660f8212b2fbeb0f3133c3a6fa8805777a877
[06/10] staging: greybus: spilib: use 'spi_delay_to_ns' for getting xfer delay
        commit: 33a23423ca0a08b488791fc9d4ca53f4bea4e45b
[07/10] spi: spi-falcon: remove check for 'delay_usecs'
        commit: a886010c69718988756fd7873522caa0f26af398
[08/10] spi: fsl-espi: remove usage of 'delay_usecs' field
        commit: 55a47532fa4c5dc3291d796dd21cc80034b5d067
[09/10] spi: core: remove 'delay_usecs' field from spi_transfer
        commit: 3ab1cce553378fc0df1b1d26d7e23d03bd4dd3b6
[10/10] spi: docs: update info about 'delay_usecs'
        commit: 05d8a019eb057d14cdf9483318a7ee8b35a69cda

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark