Linux kernel staging patches
 help / color / mirror / Atom feed
* [PATCH v3] staging: iio: addac: adt7316: document SPI interface switching sequence
@ 2026-05-11  2:31 Hungyu Lin
  2026-05-11  3:00 ` Maxwell Doose
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Hungyu Lin @ 2026-05-11  2:31 UTC (permalink / raw)
  To: jic23, lars, Michael.Hennerich, gregkh
  Cc: dlechner, nuno.sa, andy, m32285159, linux-iio, linux-staging,
	linux-kernel, Hungyu Lin

The device powers up in I2C mode. Switching to SPI mode
requires sending a sequence of SPI writes as described in
the datasheet.

During this sequence, the device may still be in I2C mode,
so SPI transactions may not be recognized and can fail.
Such errors are expected and are ignored.

Add a comment to clarify this behavior.

Datasheet: https://www.analog.com/en/products/adt7316.html
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
Changes in v3:
- Add Datasheet tag
- Use datasheet name in code comment

Changes in v2:
- Add datasheet reference
- Add TL;DR note

 drivers/staging/iio/addac/adt7316-spi.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c
index f91325d11394..bd92dcddfd91 100644
--- a/drivers/staging/iio/addac/adt7316-spi.c
+++ b/drivers/staging/iio/addac/adt7316-spi.c
@@ -106,7 +106,17 @@ static int adt7316_spi_probe(struct spi_device *spi_dev)
 		return -EINVAL;
 	}
 
-	/* switch from default I2C protocol to SPI protocol */
+	/*
+	 * The device powers up in I2C mode. Switching to SPI mode
+	 * requires sending a sequence of SPI writes as described in
+	 * the datasheet "ADT7316/ADT7317/ADT7318", Rev. B.
+	 *
+	 * During this sequence, the device may still be in I2C mode,
+	 * so SPI transactions may not be recognized and can fail.
+	 * Such errors are expected and are ignored.
+	 *
+	 * TL;DR: Do not change this!
+	 */
 	adt7316_spi_write(spi_dev, 0, 0);
 	adt7316_spi_write(spi_dev, 0, 0);
 	adt7316_spi_write(spi_dev, 0, 0);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] staging: iio: addac: adt7316: document SPI interface switching sequence
  2026-05-11  2:31 [PATCH v3] staging: iio: addac: adt7316: document SPI interface switching sequence Hungyu Lin
@ 2026-05-11  3:00 ` Maxwell Doose
  2026-05-11 10:19 ` Andy Shevchenko
  2026-05-11 13:48 ` Jonathan Cameron
  2 siblings, 0 replies; 5+ messages in thread
From: Maxwell Doose @ 2026-05-11  3:00 UTC (permalink / raw)
  To: Hungyu Lin
  Cc: jic23, lars, Michael.Hennerich, gregkh, dlechner, nuno.sa, andy,
	linux-iio, linux-staging, linux-kernel

On Sun, May 10, 2026 at 9:31 PM Hungyu Lin <dennylin0707@gmail.com> wrote:
>
> The device powers up in I2C mode. Switching to SPI mode
> requires sending a sequence of SPI writes as described in
> the datasheet.
>
> During this sequence, the device may still be in I2C mode,
> so SPI transactions may not be recognized and can fail.
> Such errors are expected and are ignored.
>
> Add a comment to clarify this behavior.
>
> Datasheet: https://www.analog.com/en/products/adt7316.html
> Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
> ---
> Changes in v3:
> - Add Datasheet tag
> - Use datasheet name in code comment
>
> Changes in v2:
> - Add datasheet reference
> - Add TL;DR note
>
>  drivers/staging/iio/addac/adt7316-spi.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>
[snip]

Reviewed-by: Maxwell Doose <m32285159@gmail.com>

best regards,
max

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] staging: iio: addac: adt7316: document SPI interface switching sequence
  2026-05-11  2:31 [PATCH v3] staging: iio: addac: adt7316: document SPI interface switching sequence Hungyu Lin
  2026-05-11  3:00 ` Maxwell Doose
@ 2026-05-11 10:19 ` Andy Shevchenko
  2026-05-11 13:46   ` Jonathan Cameron
  2026-05-11 13:48 ` Jonathan Cameron
  2 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2026-05-11 10:19 UTC (permalink / raw)
  To: Hungyu Lin
  Cc: jic23, lars, Michael.Hennerich, gregkh, dlechner, nuno.sa, andy,
	m32285159, linux-iio, linux-staging, linux-kernel

On Mon, May 11, 2026 at 02:31:27AM +0000, Hungyu Lin wrote:
> The device powers up in I2C mode. Switching to SPI mode
> requires sending a sequence of SPI writes as described in
> the datasheet.
> 
> During this sequence, the device may still be in I2C mode,
> so SPI transactions may not be recognized and can fail.
> Such errors are expected and are ignored.
> 
> Add a comment to clarify this behavior.
> 
> Datasheet: https://www.analog.com/en/products/adt7316.html
> Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>

Thanks, almost there!
Please, address the below and feel free to add
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
to your v4 of this patch.

Also I think we don't need "staging" in the Subject, as we can deduce that,
in any case it's up to Jonathan (and yes, I see the common use of the pattern
in the Git history).

...

> Changes in v3:
> - Add Datasheet tag
> - Use datasheet name in code comment

...

> +	/*
> +	 * The device powers up in I2C mode. Switching to SPI mode
> +	 * requires sending a sequence of SPI writes as described in
> +	 * the datasheet "ADT7316/ADT7317/ADT7318", Rev. B.

Yeah, but you dropped the section title...

	 * the datasheet "ADT7316/ADT7317/ADT7318", Rev. B in
	 * the section "...".

> +	 * During this sequence, the device may still be in I2C mode,
> +	 * so SPI transactions may not be recognized and can fail.
> +	 * Such errors are expected and are ignored.
> +	 *
> +	 * TL;DR: Do not change this!
> +	 */

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] staging: iio: addac: adt7316: document SPI interface switching sequence
  2026-05-11 10:19 ` Andy Shevchenko
@ 2026-05-11 13:46   ` Jonathan Cameron
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2026-05-11 13:46 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Hungyu Lin, lars, Michael.Hennerich, gregkh, dlechner, nuno.sa,
	andy, m32285159, linux-iio, linux-staging, linux-kernel

On Mon, 11 May 2026 13:19:21 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Mon, May 11, 2026 at 02:31:27AM +0000, Hungyu Lin wrote:
> > The device powers up in I2C mode. Switching to SPI mode
> > requires sending a sequence of SPI writes as described in
> > the datasheet.
> > 
> > During this sequence, the device may still be in I2C mode,
> > so SPI transactions may not be recognized and can fail.
> > Such errors are expected and are ignored.
> > 
> > Add a comment to clarify this behavior.
> > 
> > Datasheet: https://www.analog.com/en/products/adt7316.html
> > Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>  
> 
> Thanks, almost there!
> Please, address the below and feel free to add
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> to your v4 of this patch.
> 
> Also I think we don't need "staging" in the Subject, as we can deduce that,
> in any case it's up to Jonathan (and yes, I see the common use of the pattern
> in the Git history).

I think keeping staging is appropriate for a couple of reasons.

1) Affects who looks at it.  
2) Aligns with the more general pattern for most of staging that goes
   directly through Greg rather than via another tree like IIO.

> 
> ...
> 
> > Changes in v3:
> > - Add Datasheet tag
> > - Use datasheet name in code comment  
> 
> ...
> 
> > +	/*
> > +	 * The device powers up in I2C mode. Switching to SPI mode
> > +	 * requires sending a sequence of SPI writes as described in
> > +	 * the datasheet "ADT7316/ADT7317/ADT7318", Rev. B.  
> 
> Yeah, but you dropped the section title...
> 
> 	 * the datasheet "ADT7316/ADT7317/ADT7318", Rev. B in
> 	 * the section "...".

Absolutely agree on this! Can be hard to find this stuff in the bigger
datasheets :(
> 
> > +	 * During this sequence, the device may still be in I2C mode,
> > +	 * so SPI transactions may not be recognized and can fail.
> > +	 * Such errors are expected and are ignored.
> > +	 *
> > +	 * TL;DR: Do not change this!
> > +	 */  
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3] staging: iio: addac: adt7316: document SPI interface switching sequence
  2026-05-11  2:31 [PATCH v3] staging: iio: addac: adt7316: document SPI interface switching sequence Hungyu Lin
  2026-05-11  3:00 ` Maxwell Doose
  2026-05-11 10:19 ` Andy Shevchenko
@ 2026-05-11 13:48 ` Jonathan Cameron
  2 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2026-05-11 13:48 UTC (permalink / raw)
  To: Hungyu Lin
  Cc: lars, Michael.Hennerich, gregkh, dlechner, nuno.sa, andy,
	m32285159, linux-iio, linux-staging, linux-kernel

On Mon, 11 May 2026 02:31:27 +0000
Hungyu Lin <dennylin0707@gmail.com> wrote:

> The device powers up in I2C mode. Switching to SPI mode
> requires sending a sequence of SPI writes as described in
> the datasheet.
> 
> During this sequence, the device may still be in I2C mode,
> so SPI transactions may not be recognized and can fail.
> Such errors are expected and are ignored.

I'd not say they are 'expected' as such.  That's because SPI
is a rather simple protocol so it is challenging to detect when
anything is wrong on writes.   It might happen, it might not.

Perhaps

Such errors are therefore ignored.

Same below - otherwise we might get someone trying to verify
they get an error on this sequence ;)

> 
> Add a comment to clarify this behavior.
> 
> Datasheet: https://www.analog.com/en/products/adt7316.html
> Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
> ---
> Changes in v3:
> - Add Datasheet tag
> - Use datasheet name in code comment
> 
> Changes in v2:
> - Add datasheet reference
> - Add TL;DR note
> 
>  drivers/staging/iio/addac/adt7316-spi.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c
> index f91325d11394..bd92dcddfd91 100644
> --- a/drivers/staging/iio/addac/adt7316-spi.c
> +++ b/drivers/staging/iio/addac/adt7316-spi.c
> @@ -106,7 +106,17 @@ static int adt7316_spi_probe(struct spi_device *spi_dev)
>  		return -EINVAL;
>  	}
>  
> -	/* switch from default I2C protocol to SPI protocol */
> +	/*
> +	 * The device powers up in I2C mode. Switching to SPI mode
> +	 * requires sending a sequence of SPI writes as described in
> +	 * the datasheet "ADT7316/ADT7317/ADT7318", Rev. B.
> +	 *
> +	 * During this sequence, the device may still be in I2C mode,
> +	 * so SPI transactions may not be recognized and can fail.
> +	 * Such errors are expected and are ignored.
> +	 *
> +	 * TL;DR: Do not change this!
> +	 */
>  	adt7316_spi_write(spi_dev, 0, 0);
>  	adt7316_spi_write(spi_dev, 0, 0);
>  	adt7316_spi_write(spi_dev, 0, 0);


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-05-11 13:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-11  2:31 [PATCH v3] staging: iio: addac: adt7316: document SPI interface switching sequence Hungyu Lin
2026-05-11  3:00 ` Maxwell Doose
2026-05-11 10:19 ` Andy Shevchenko
2026-05-11 13:46   ` Jonathan Cameron
2026-05-11 13:48 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox