Skip to contentSkip to conversation

staging: iio: addac: adt7316: document SPI interface switching sequence

PATCH Superseded Hungyu Lin 3 participants 7 messages May 10

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Hungyu Lin

author
#0 lore raw

PATCH v2 1/1 staging: iio: addac: adt7316: document SPI interface switching sequence

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.

---
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(-)
drivers/staging/iio/addac/adt7316-spi.c +11 -1
index f91325d11394..980532b7fa1e 100644
@@ -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 ("Serial Interface Selection" 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!
+	 */
 	adt7316_spi_write(spi_dev, 0, 0);
 	adt7316_spi_write(spi_dev, 0, 0);
 	adt7316_spi_write(spi_dev, 0, 0);
Signature · 1 line
2.34.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 44 lines · 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.

---
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(-)
drivers/staging/iio/addac/adt7316-spi.c +11 -2
index f91325d11394..980532b7fa1e 100644
@@ -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 ("Serial Interface Selection" 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!
+        */
        adt7316_spi_write(spi_dev, 0, 0);
        adt7316_spi_write(spi_dev, 0, 0);
        adt7316_spi_write(spi_dev, 0, 0);
--
Quoted 3 lines

2.34.1

but please, wait at least 24hrs before submitting a new version...

best regards,
max

Reviewed-by on v2 1/1
#2 lore raw
In reply to Hungyu Lin
Quoted 9 lines · 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.

...

Quoted 2 lines

Changes in v2:
- Add datasheet reference

This is still odd. Please, put in a format

	$SNUM "$STITLE"

where $SNUM is the section number (like 2.1.4) and "$STITLE" as currently done in this version, Ideally the datasheet also needs a versioning.

...

With that being addressed,

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#3 lore raw
Quoted 6 lines

This is still odd. Please, put in a format

$SNUM "$STITLE"

where $SNUM is the section number (like 2.1.4) and "$STITLE" as currently done in this version, Ideally the datasheet also needs a versioning.

The ADT7316 datasheet does not seem to provide explicit section numbering for the "Serial Interface Selection" section, only the section title.

Would it be acceptable to reference it using just the section title, or would you prefer using the page number instead?

Thanks,
Hungyu

#4 lore raw
Quoted 7 lines · Denny Lin
Quoted 6 lines

This is still odd. Please, put in a format

$SNUM "$STITLE"

where $SNUM is the section number (like 2.1.4) and "$STITLE" as currently done in this version, Ideally the datasheet also needs a versioning.

Quoted 6 lines

The ADT7316 datasheet does not seem to provide explicit section numbering for the "Serial Interface Selection" section, only the section title.

Would it be acceptable to reference it using just the section title, or would you prefer using the page number instead?

Do you have the Datasheet version? Maybe URL?

(Yeah, that's unfortunate they do not provide numbering, in such a case
it's acceptable to have reduced reference.)

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw
Quoted 6 lines · Denny Lin
Quoted 1 line

Do you have the Datasheet version? Maybe URL?

The datasheet I am referring to is:
https://www.analog.com/en/products/adt7316.html

(ADT7316/ADT7317/ADT7318, Rev. B)

OK! Put the URL in the commit message as Datasheet tag and use the name in the comment in the code

Datasheet: $URL
Signed-off-by: ...

...

/*
*...datasheet "ADT7316/ADT7317/ADT7318", Rev. B... */

Signature · 2 lines
With Best Regards,
Andy Shevchenko