Skip to contentSkip to conversation

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

PATCH Superseded Hungyu Lin 2 participants 2 messages May 10

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Hungyu Lin

author
#0 lore raw

PATCH 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.

---
 drivers/staging/iio/addac/adt7316-spi.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/staging/iio/addac/adt7316-spi.c +9 -1
index f91325d11394..6d710e1d4aaa 100644
@@ -106,7 +106,15 @@ 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.
+	 *
+	 * 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.
+	 */
 	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
#1 lore raw
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.

...

drivers/staging/iio/addac/adt7316-spi.c static int adt7316_spi_probe(struct spi_device *spi_dev) · line 112

Quoted 5 lines
drivers/staging/iio/addac/adt7316-spi.c +4 -1
-	/* 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.

Add a reference (Section number and title, and/or table / chart number and its title).

drivers/staging/iio/addac/adt7316-spi.c static int adt7316_spi_probe(struct spi_device *spi_dev) · line 117

Quoted 4 lines
drivers/staging/iio/addac/adt7316-spi.c +4 -0
+	 * 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.
+	 */

Otherwise it is indeed what we want to be here.

Perhaps also add a line closer to the code (that will be visible in the patch in case someone ignores to read the comment)

	 *
	 * TL;DR: Do not change this!
	 */
Signature · 2 lines
With Best Regards,
Andy Shevchenko