[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALHNRZ928KN6ZBDzdGWyabSQw4Hny6F5RdqZ4hBUZosPZtni1A@mail.gmail.com>
Date: Tue, 6 May 2025 04:50:37 -0500
From: Aaron Kling <webgeek1234@...il.com>
To: Jon Hunter <jonathanh@...dia.com>
Cc: Laxman Dewangan <ldewangan@...dia.com>, Mark Brown <broonie@...nel.org>,
Thierry Reding <thierry.reding@...il.com>, Mason Zhang <Mason.Zhang@...iatek.com>,
linux-spi@...r.kernel.org, linux-tegra@...r.kernel.org,
linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH] spi: tegra114: Don't fail set_cs_timing when delays are zero
On Tue, May 6, 2025 at 4:27 AM Jon Hunter <jonathanh@...dia.com> wrote:
>
>
> On 24/04/2025 03:03, Aaron Kling via B4 Relay wrote:
> > From: Aaron Kling <webgeek1234@...il.com>
> >
> > The original code would skip null delay pointers, but when the pointers
> > were converted to point within the spi_device struct, the check was not
> > updated to skip delays of zero. Hence all spi devices that didn't set
> > delays would fail to probe.
> >
> > Fixes: 04e6bb0d6bb1 ("spi: modify set_cs_timing parameter")
> > Cc: stable@...r.kernel.org
> > Signed-off-by: Aaron Kling <webgeek1234@...il.com>
> > ---
> > drivers/spi/spi-tegra114.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c
> > index 3822d7c8d8edb9730e937df50d1c75e095dd18ec..2a8bb798e95b954fe573f1c50445ed2e7fcbfd78 100644
> > --- a/drivers/spi/spi-tegra114.c
> > +++ b/drivers/spi/spi-tegra114.c
> > @@ -728,9 +728,9 @@ static int tegra_spi_set_hw_cs_timing(struct spi_device *spi)
> > u32 inactive_cycles;
> > u8 cs_state;
> >
> > - if (setup->unit != SPI_DELAY_UNIT_SCK ||
> > - hold->unit != SPI_DELAY_UNIT_SCK ||
> > - inactive->unit != SPI_DELAY_UNIT_SCK) {
> > + if ((setup->unit && setup->unit != SPI_DELAY_UNIT_SCK) ||
> > + (hold->unit && hold->unit != SPI_DELAY_UNIT_SCK) ||
> > + (inactive->unit && inactive->unit != SPI_DELAY_UNIT_SCK)) {
>
> The above does not look correct to me. For example, if 'setup->unit' is
> 0, this means that the unit is 'SPI_DELAY_UNIT_USECS' and does not
> indicate that the delay is 0.
>
> Shouldn't the above be ...
>
> if ((setup && setup->unit != SPI_DELAY_UNIT_SCK) ||
> (hold && hold->unit != SPI_DELAY_UNIT_SCK) ||
> (inactive && inactive->unit != SPI_DELAY_UNIT_SCK)) {
This is what the code looked like before 373c36b [0], which dropped
that check because the pointers can never be NULL. Should this check
if ->value is not 0 instead?
Sincerely,
Aaron Kling
[0] https://github.com/torvalds/linux/commit/373c36bf7914e3198ac2654dede499f340c52950
Powered by blists - more mailing lists