Skip to contentSkip to conversation

iio: si7020: Remove reset in probe

PATCH In review Eddie James 2 participants 3 messages May 25, 2022 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: si7020: Remove reset in probe

I2C commands issued after the SI7020 is starting up or after reset can potentially upset the startup sequence. Therefore, the host needs to wait for the startup sequence to finish before issuing further i2c commands. This is impractical in cases where the SI7020 is on a shared bus or behind a mux, which may switch channels at any time (generating I2C traffic). Therefore, remove the device reset in the probe function.

---
 drivers/iio/humidity/si7020.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/iio/humidity/si7020.c +0 -7
index ab6537f136ba..3c55b81ce984 100644
@@ -115,13 +115,6 @@ static int si7020_probe(struct i2c_client *client,
 				     I2C_FUNC_SMBUS_READ_WORD_DATA))
 		return -EOPNOTSUPP;
 
-	/* Reset device, loads default settings. */
-	ret = i2c_smbus_write_byte(client, SI7020CMD_RESET);
-	if (ret < 0)
-		return ret;
-	/* Wait the maximum power-up time after software reset. */
-	msleep(15);
-
 	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
 	if (!indio_dev)
 		return -ENOMEM;
Signature · 1 line
2.27.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Eddie James

I2C commands issued after the SI7020 is starting up or after reset can potentially upset the startup sequence. Therefore, the host needs to wait for the startup sequence to finish before issuing further i2c commands. This is impractical in cases where the SI7020 is on a shared bus or behind a mux, which may switch channels at any time (generating I2C traffic). Therefore, remove the device reset in the probe function.

Following the upstream discussion, I think this is the way forward. Send this out to the upstream list when you have time.

https://lore.kernel.org/all/[email protected]/

Quoted 27 lines
---
 drivers/iio/humidity/si7020.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/iio/humidity/si7020.c +0 -8
index ab6537f136ba..3c55b81ce984 100644
@@ -115,13 +115,6 @@ static int si7020_probe(struct i2c_client *client,
                                     I2C_FUNC_SMBUS_READ_WORD_DATA))
                return -EOPNOTSUPP;
 
-       /* Reset device, loads default settings. */
-       ret = i2c_smbus_write_byte(client, SI7020CMD_RESET);
-       if (ret < 0)
-               return ret;
-       /* Wait the maximum power-up time after software reset. */
-       msleep(15);
-
        indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
        if (!indio_dev)
                return -ENOMEM;
--

2.27.0

#2 lore raw
In reply to Eddie James
Quoted 19 lines · Eddie James

I2C commands issued after the SI7020 is starting up or after reset can potentially upset the startup sequence. Therefore, the host needs to wait for the startup sequence to finish before issuing further i2c commands. This is impractical in cases where the SI7020 is on a shared bus or behind a mux, which may switch channels at any time (generating I2C traffic). Therefore, remove the device reset in the probe function.

---
 drivers/iio/humidity/si7020.c | 7 -------
 1 file changed, 7 deletions(-)
drivers/iio/humidity/si7020.c +0 -0
index ab6537f136ba..3c55b81ce984 100644

drivers/iio/humidity/si7020.c static int si7020_probe(struct i2c_client *client, · line 123

Quoted 9 lines
drivers/iio/humidity/si7020.c +0 -6
@@ -115,13 +115,6 @@ static int si7020_probe(struct i2c_client *client,
                                     I2C_FUNC_SMBUS_READ_WORD_DATA))
                return -EOPNOTSUPP;
 
-       /* Reset device, loads default settings. */
-       ret = i2c_smbus_write_byte(client, SI7020CMD_RESET);
-       if (ret < 0)
-               return ret;
-       /* Wait the maximum power-up time after software reset. */
-       msleep(15);

../drivers/iio/humidity/si7020.c:111:13: warning: unused variable ‘ret’ [-Wunused-variable]
111 | int ret;
| ^~~

I have fixed it up when applying, but keep that in mind for when you send upstream.

Quoted 7 lines
drivers/iio/humidity/si7020.c +0 -2
-
        indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
        if (!indio_dev)
                return -ENOMEM;
--

2.27.0