Skip to contentSkip to conversation

iio: humidity: hdc100x: Add margin to the conversion time

PATCH Superseded Chris Lesiak 4 participants 5 messages Jun 9, 2021 – Jun 11, 2021 IIO

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: humidity: hdc100x: Add margin to the conversion time

The datasheets have the following note for the conversion time
specification: "This parameter is specified by design and/or characterization and it is not tested in production."

Parts have been seen that require more time to do 14-bit conversions for the relative humidity channel. The result is ENXIO due to the address phase of a transfer not getting an ACK.

Delay an additional 1 ms per conversion to allow for additional margin.

---
 drivers/iio/humidity/hdc100x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/humidity/hdc100x.c +2 -2
index 2a957f19048e..91790aa8beeb 100644
@@ -166,7 +166,7 @@ static int hdc100x_get_measurement(struct hdc100x_data *data,
 				   struct iio_chan_spec const *chan)
 {
 	struct i2c_client *client = data->client;
-	int delay = data->adc_int_us[chan->address];
+	int delay = data->adc_int_us[chan->address] + 1000;
 	int ret;
 	__be16 val;
 
@@ -316,7 +316,7 @@ static irqreturn_t hdc100x_trigger_handler(int irq, void *p)
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct hdc100x_data *data = iio_priv(indio_dev);
 	struct i2c_client *client = data->client;
-	int delay = data->adc_int_us[0] + data->adc_int_us[1];
+	int delay = data->adc_int_us[0] + data->adc_int_us[1] + 2000;
 	int ret;
 
 	/* dual read starts at temp register */
Signature · 1 line
2.26.2
#1 lore raw
Quoted 11 lines · On Wed, 9 Jun 2021 14:37:48 -0500 Chris Lesiak <[email protected]> wrote:

The datasheets have the following note for the conversion time
specification: "This parameter is specified by design and/or characterization and it is not tested in production."

Parts have been seen that require more time to do 14-bit conversions for the relative humidity channel. The result is ENXIO due to the address phase of a transfer not getting an ACK.

Delay an additional 1 ms per conversion to allow for additional margin.

Hi Chris

Could you figure out a fixes tag for this one so we can get it backported into stable?

If not I can probably guess when I catch up with applying patches.

Thanks,

Jonathan

Quoted 26 lines
---
 drivers/iio/humidity/hdc100x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/humidity/hdc100x.c +2 -2
index 2a957f19048e..91790aa8beeb 100644
@@ -166,7 +166,7 @@ static int hdc100x_get_measurement(struct hdc100x_data *data,
 				   struct iio_chan_spec const *chan)
 {
 	struct i2c_client *client = data->client;
-	int delay = data->adc_int_us[chan->address];
+	int delay = data->adc_int_us[chan->address] + 1000;
 	int ret;
 	__be16 val;
 
@@ -316,7 +316,7 @@ static irqreturn_t hdc100x_trigger_handler(int irq, void *p)
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct hdc100x_data *data = iio_priv(indio_dev);
 	struct i2c_client *client = data->client;
-	int delay = data->adc_int_us[0] + data->adc_int_us[1];
+	int delay = data->adc_int_us[0] + data->adc_int_us[1] + 2000;
 	int ret;
 
 	/* dual read starts at temp register */
#2 lore raw

PATCH v2 1/1 iio: humidity: hdc100x: Add margin to the conversion time

The datasheets have the following note for the conversion time
specification: "This parameter is specified by design and/or characterization and it is not tested in production."

Parts have been seen that require more time to do 14-bit conversions for the relative humidity channel. The result is ENXIO due to the address phase of a transfer not getting an ACK.

Delay an additional 1 ms per conversion to allow for additional margin.

Fixes 4839367d99e3 ("iio: humidity: add HDC100x support")
---
 drivers/iio/humidity/hdc100x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/humidity/hdc100x.c +2 -2
index 2a957f19048e..91790aa8beeb 100644
@@ -166,7 +166,7 @@ static int hdc100x_get_measurement(struct hdc100x_data *data,
 				   struct iio_chan_spec const *chan)
 {
 	struct i2c_client *client = data->client;
-	int delay = data->adc_int_us[chan->address];
+	int delay = data->adc_int_us[chan->address] + 1000;
 	int ret;
 	__be16 val;
 
@@ -316,7 +316,7 @@ static irqreturn_t hdc100x_trigger_handler(int irq, void *p)
 	struct iio_dev *indio_dev = pf->indio_dev;
 	struct hdc100x_data *data = iio_priv(indio_dev);
 	struct i2c_client *client = data->client;
-	int delay = data->adc_int_us[0] + data->adc_int_us[1];
+	int delay = data->adc_int_us[0] + data->adc_int_us[1] + 2000;
 	int ret;
 
 	/* dual read starts at temp register */
Signature · 1 line
2.26.2
#3 lore raw
Quoted 10 lines · Chris Lesiak

The datasheets have the following note for the conversion time
specification: "This parameter is specified by design and/or characterization and it is not tested in production."

Parts have been seen that require more time to do 14-bit conversions for the relative humidity channel. The result is ENXIO due to the address phase of a transfer not getting an ACK.

Delay an additional 1 ms per conversion to allow for additional margin.

This is crucial and not so visible in the code, see below.

Quoted 11 lines
Fixes 4839367d99e3 ("iio: humidity: add HDC100x support")
---
 drivers/iio/humidity/hdc100x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/humidity/hdc100x.c +0 -0
index 2a957f19048e..91790aa8beeb 100644

drivers/iio/humidity/hdc100x.c static int hdc100x_get_measurement(struct hdc100x_data *data, · line 169

Quoted 5 lines
drivers/iio/humidity/hdc100x.c +1 -1
@@ -166,7 +166,7 @@ static int hdc100x_get_measurement(struct hdc100x_data *data,
                                   struct iio_chan_spec const *chan)
 {
        struct i2c_client *client = data->client;
-       int delay = data->adc_int_us[chan->address];
+       int delay = data->adc_int_us[chan->address] + 1000;

+ 1 * USEC_PER_MSEC;

drivers/iio/humidity/hdc100x.c static irqreturn_t hdc100x_trigger_handler(int irq, void *p) · line 319

Quoted 9 lines
drivers/iio/humidity/hdc100x.c +1 -1
        int ret;
        __be16 val;
 
@@ -316,7 +316,7 @@ static irqreturn_t hdc100x_trigger_handler(int irq, void *p)
        struct iio_dev *indio_dev = pf->indio_dev;
        struct hdc100x_data *data = iio_priv(indio_dev);
        struct i2c_client *client = data->client;
-       int delay = data->adc_int_us[0] + data->adc_int_us[1];
+       int delay = data->adc_int_us[0] + data->adc_int_us[1] + 2000;

+ 2 * USEC_PER_MSEC

drivers/iio/humidity/hdc100x.c static irqreturn_t hdc100x_trigger_handler(int irq, void *p) · line 322

Quoted 3 lines
drivers/iio/humidity/hdc100x.c +0 -0
        int ret;
 
        /* dual read starts at temp register */

Above might require to add #include <vdso/time64.h>.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#4 lore raw
Quoted 6 lines · On Thu, 10 Jun 2021 16:55:20 +0300 Andy Shevchenko <[email protected]>…
Quoted 5 lines · Chris Lesiak

The datasheets have the following note for the conversion time
specification: "This parameter is specified by design and/or characterization and it is not tested in production."

Quoted 10 lines
Quoted 5 lines

Parts have been seen that require more time to do 14-bit conversions for the relative humidity channel. The result is ENXIO due to the address phase of a transfer not getting an ACK.

Delay an additional 1 ms per conversion to allow for additional margin.

This is crucial and not so visible in the code, see below.

Quoted 2 lines
Fixes 4839367d99e3 ("iio: humidity: add HDC100x support")

Small process note.

For IIO at least, please don't send new versions of patches as replies to earlier series. Whilst it doesn't matter that much here, for large series it can get very confusing and runs the risk of be picking up the wrong patch versions.

A new thread is much easier to deal with.

Jonathan

Quoted 35 lines
Quoted 9 lines
---
 drivers/iio/humidity/hdc100x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/humidity/hdc100x.c +0 -0
index 2a957f19048e..91790aa8beeb 100644

drivers/iio/humidity/hdc100x.c static int hdc100x_get_measurement(struct hdc100x_data *data, · line 169

Quoted 5 lines
drivers/iio/humidity/hdc100x.c +1 -1
@@ -166,7 +166,7 @@ static int hdc100x_get_measurement(struct hdc100x_data *data,
                                   struct iio_chan_spec const *chan)
 {
        struct i2c_client *client = data->client;
-       int delay = data->adc_int_us[chan->address];
+       int delay = data->adc_int_us[chan->address] + 1000;  

+ 1 * USEC_PER_MSEC;

drivers/iio/humidity/hdc100x.c static irqreturn_t hdc100x_trigger_handler(int irq, void *p) · line 319

Quoted 9 lines
drivers/iio/humidity/hdc100x.c +1 -1
        int ret;
        __be16 val;
 
@@ -316,7 +316,7 @@ static irqreturn_t hdc100x_trigger_handler(int irq, void *p)
        struct iio_dev *indio_dev = pf->indio_dev;
        struct hdc100x_data *data = iio_priv(indio_dev);
        struct i2c_client *client = data->client;
-       int delay = data->adc_int_us[0] + data->adc_int_us[1];
+       int delay = data->adc_int_us[0] + data->adc_int_us[1] + 2000;  

+ 2 * USEC_PER_MSEC

drivers/iio/humidity/hdc100x.c static irqreturn_t hdc100x_trigger_handler(int irq, void *p) · line 322

Quoted 3 lines
drivers/iio/humidity/hdc100x.c +0 -0
        int ret;
 
        /* dual read starts at temp register */  

Above might require to add #include <vdso/time64.h>.