From: Greg KH <gregkh@linuxfoundation.org>
To: Alexandru Ardelean <aardelean@deviqon.com>
Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
greybus-dev@lists.linaro.org, devel@driverdev.osuosl.org,
linux-tegra@vger.kernel.org,
bcm-kernel-feedback-list@broadcom.com, thierry.reding@gmail.com,
elder@kernel.org, johan@kernel.org, jonathanh@nvidia.com,
broonie@kernel.org, ldewangan@nvidia.com, vireshk@kernel.org,
f.fainelli@gmail.com, linux@deviqon.com
Subject: Re: [PATCH 06/10] staging: greybus: spilib: use 'spi_delay_to_ns' for getting xfer delay
Date: Tue, 9 Mar 2021 14:05:10 +0100 [thread overview]
Message-ID: <YEdyhjayjbztoWI+@kroah.com> (raw)
In-Reply-To: <20210308145502.1075689-7-aardelean@deviqon.com>
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>
next prev parent reply other threads:[~2021-03-09 13:06 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-08 14:54 [PATCH 00/10] spi: finalize 'delay_usecs' removal/transition Alexandru Ardelean
2021-03-08 14:54 ` [PATCH 01/10] spi: spi-axi-spi-engine: remove usage of delay_usecs Alexandru Ardelean
2021-03-08 16:42 ` Lars-Peter Clausen
2021-03-10 7:16 ` Alexandru Ardelean
2021-03-10 7:21 ` Lars-Peter Clausen
2021-03-08 14:54 ` [PATCH 02/10] spi: bcm63xx-spi: don't check 'delay_usecs' field Alexandru Ardelean
2021-03-08 14:54 ` [PATCH 03/10] spi: spi-bcm-qspi: replace 'delay_usecs' with 'delay.value' check Alexandru Ardelean
2021-03-08 14:54 ` [PATCH 04/10] spi: spi-sh: replace 'delay_usecs' with 'delay.value' in pr_debug Alexandru Ardelean
2021-03-08 14:54 ` [PATCH 05/10] spi: spi-tegra20-flash: don't check 'delay_usecs' field for spi transfer Alexandru Ardelean
2021-03-08 14:54 ` [PATCH 06/10] staging: greybus: spilib: use 'spi_delay_to_ns' for getting xfer delay Alexandru Ardelean
2021-03-09 4:28 ` Viresh Kumar
2021-03-09 9:29 ` Rui Miguel Silva
2021-03-09 13:05 ` Greg KH [this message]
2021-03-08 14:54 ` [PATCH 07/10] spi: spi-falcon: remove check for 'delay_usecs' Alexandru Ardelean
2021-03-08 14:55 ` [PATCH 08/10] spi: fsl-espi: remove usage of 'delay_usecs' field Alexandru Ardelean
2021-03-08 14:55 ` [PATCH 09/10] spi: core: remove 'delay_usecs' field from spi_transfer Alexandru Ardelean
2021-03-08 14:55 ` [PATCH 10/10] spi: docs: update info about 'delay_usecs' Alexandru Ardelean
2021-03-12 20:25 ` [PATCH 00/10] spi: finalize 'delay_usecs' removal/transition Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YEdyhjayjbztoWI+@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=aardelean@deviqon.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=broonie@kernel.org \
--cc=devel@driverdev.osuosl.org \
--cc=elder@kernel.org \
--cc=f.fainelli@gmail.com \
--cc=greybus-dev@lists.linaro.org \
--cc=johan@kernel.org \
--cc=jonathanh@nvidia.com \
--cc=ldewangan@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=linux@deviqon.com \
--cc=thierry.reding@gmail.com \
--cc=vireshk@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).