linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] iio: humidity: hdc100x: Add margin to the conversion time
@ 2021-06-14 14:18 Chris Lesiak
  2021-06-16 12:43 ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Lesiak @ 2021-06-14 14:18 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, linux-kernel, 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.

Fixes: 4839367d99e3 ("iio: humidity: add HDC100x support")
Signed-off-by: Chris Lesiak <chris.lesiak@licor.com>
---
 drivers/iio/humidity/hdc100x.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/humidity/hdc100x.c b/drivers/iio/humidity/hdc100x.c
index 2a957f19048e..9e0fce917ce4 100644
--- a/drivers/iio/humidity/hdc100x.c
+++ b/drivers/iio/humidity/hdc100x.c
@@ -25,6 +25,8 @@
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
 
+#include <linux/time.h>
+
 #define HDC100X_REG_TEMP			0x00
 #define HDC100X_REG_HUMIDITY			0x01
 
@@ -166,7 +168,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] + 1*USEC_PER_MSEC;
 	int ret;
 	__be16 val;
 
@@ -316,7 +318,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] + 2*USEC_PER_MSEC;
 	int ret;
 
 	/* dual read starts at temp register */
-- 
2.26.2


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

* Re: [PATCH v3] iio: humidity: hdc100x: Add margin to the conversion time
  2021-06-14 14:18 [PATCH v3] iio: humidity: hdc100x: Add margin to the conversion time Chris Lesiak
@ 2021-06-16 12:43 ` Jonathan Cameron
  2021-07-18 14:51   ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2021-06-16 12:43 UTC (permalink / raw)
  To: Chris Lesiak; +Cc: linux-iio, linux-kernel, Matt Ranostay

On Mon, 14 Jun 2021 09:18:20 -0500
Chris Lesiak <chris.lesiak@licor.com> 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.
> 
> Fixes: 4839367d99e3 ("iio: humidity: add HDC100x support")
> Signed-off-by: Chris Lesiak <chris.lesiak@licor.com>

+CC Matt as this is one of his drivers.

Looks good to me.

> ---
>  drivers/iio/humidity/hdc100x.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/humidity/hdc100x.c b/drivers/iio/humidity/hdc100x.c
> index 2a957f19048e..9e0fce917ce4 100644
> --- a/drivers/iio/humidity/hdc100x.c
> +++ b/drivers/iio/humidity/hdc100x.c
> @@ -25,6 +25,8 @@
>  #include <linux/iio/trigger_consumer.h>
>  #include <linux/iio/triggered_buffer.h>
>  
> +#include <linux/time.h>
> +
>  #define HDC100X_REG_TEMP			0x00
>  #define HDC100X_REG_HUMIDITY			0x01
>  
> @@ -166,7 +168,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] + 1*USEC_PER_MSEC;
>  	int ret;
>  	__be16 val;
>  
> @@ -316,7 +318,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] + 2*USEC_PER_MSEC;
>  	int ret;
>  
>  	/* dual read starts at temp register */


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

* Re: [PATCH v3] iio: humidity: hdc100x: Add margin to the conversion time
  2021-06-16 12:43 ` Jonathan Cameron
@ 2021-07-18 14:51   ` Jonathan Cameron
  2021-07-18 21:31     ` Matt Ranostay
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2021-07-18 14:51 UTC (permalink / raw)
  To: Chris Lesiak; +Cc: linux-iio, linux-kernel, Matt Ranostay

On Wed, 16 Jun 2021 13:43:35 +0100
Jonathan Cameron <jic23@kernel.org> wrote:

> On Mon, 14 Jun 2021 09:18:20 -0500
> Chris Lesiak <chris.lesiak@licor.com> 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.
> > 
> > Fixes: 4839367d99e3 ("iio: humidity: add HDC100x support")
> > Signed-off-by: Chris Lesiak <chris.lesiak@licor.com>  
> 
> +CC Matt as this is one of his drivers.

@Matt. Ping.

> 
> Looks good to me.
> 
> > ---
> >  drivers/iio/humidity/hdc100x.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/iio/humidity/hdc100x.c b/drivers/iio/humidity/hdc100x.c
> > index 2a957f19048e..9e0fce917ce4 100644
> > --- a/drivers/iio/humidity/hdc100x.c
> > +++ b/drivers/iio/humidity/hdc100x.c
> > @@ -25,6 +25,8 @@
> >  #include <linux/iio/trigger_consumer.h>
> >  #include <linux/iio/triggered_buffer.h>
> >  
> > +#include <linux/time.h>
> > +
> >  #define HDC100X_REG_TEMP			0x00
> >  #define HDC100X_REG_HUMIDITY			0x01
> >  
> > @@ -166,7 +168,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] + 1*USEC_PER_MSEC;
> >  	int ret;
> >  	__be16 val;
> >  
> > @@ -316,7 +318,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] + 2*USEC_PER_MSEC;
> >  	int ret;
> >  
> >  	/* dual read starts at temp register */  
> 


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

* Re: [PATCH v3] iio: humidity: hdc100x: Add margin to the conversion time
  2021-07-18 14:51   ` Jonathan Cameron
@ 2021-07-18 21:31     ` Matt Ranostay
  2021-07-24 17:13       ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: Matt Ranostay @ 2021-07-18 21:31 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Chris Lesiak, open list:IIO SUBSYSTEM AND DRIVERS, open list

On Sun, Jul 18, 2021 at 7:49 AM Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Wed, 16 Jun 2021 13:43:35 +0100
> Jonathan Cameron <jic23@kernel.org> wrote:
>
> > On Mon, 14 Jun 2021 09:18:20 -0500
> > Chris Lesiak <chris.lesiak@licor.com> 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.
> > >
> > > Fixes: 4839367d99e3 ("iio: humidity: add HDC100x support")
> > > Signed-off-by: Chris Lesiak <chris.lesiak@licor.com>
> >
> > +CC Matt as this is one of his drivers.
>
> @Matt. Ping.
>
> >
> > Looks good to me.

Looks good to me as well.

Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>

> >
> > > ---
> > >  drivers/iio/humidity/hdc100x.c | 6 ++++--
> > >  1 file changed, 4 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/iio/humidity/hdc100x.c b/drivers/iio/humidity/hdc100x.c
> > > index 2a957f19048e..9e0fce917ce4 100644
> > > --- a/drivers/iio/humidity/hdc100x.c
> > > +++ b/drivers/iio/humidity/hdc100x.c
> > > @@ -25,6 +25,8 @@
> > >  #include <linux/iio/trigger_consumer.h>
> > >  #include <linux/iio/triggered_buffer.h>
> > >
> > > +#include <linux/time.h>
> > > +
> > >  #define HDC100X_REG_TEMP                   0x00
> > >  #define HDC100X_REG_HUMIDITY                       0x01
> > >
> > > @@ -166,7 +168,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] + 1*USEC_PER_MSEC;
> > >     int ret;
> > >     __be16 val;
> > >
> > > @@ -316,7 +318,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] + 2*USEC_PER_MSEC;
> > >     int ret;
> > >
> > >     /* dual read starts at temp register */
> >
>

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

* Re: [PATCH v3] iio: humidity: hdc100x: Add margin to the conversion time
  2021-07-18 21:31     ` Matt Ranostay
@ 2021-07-24 17:13       ` Jonathan Cameron
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2021-07-24 17:13 UTC (permalink / raw)
  To: Matt Ranostay
  Cc: Chris Lesiak, open list:IIO SUBSYSTEM AND DRIVERS, open list

On Sun, 18 Jul 2021 14:31:28 -0700
Matt Ranostay <matt.ranostay@konsulko.com> wrote:

> On Sun, Jul 18, 2021 at 7:49 AM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > On Wed, 16 Jun 2021 13:43:35 +0100
> > Jonathan Cameron <jic23@kernel.org> wrote:
> >  
> > > On Mon, 14 Jun 2021 09:18:20 -0500
> > > Chris Lesiak <chris.lesiak@licor.com> 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.
> > > >
> > > > Fixes: 4839367d99e3 ("iio: humidity: add HDC100x support")
> > > > Signed-off-by: Chris Lesiak <chris.lesiak@licor.com>  
> > >
> > > +CC Matt as this is one of his drivers.  
> >
> > @Matt. Ping.
> >  
> > >
> > > Looks good to me.  
> 
> Looks good to me as well.
> 
> Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>

Thanks.

Applied to the fixes-togreg branch of iio.git and marked for stable.

Jonathan

> 
> > >  
> > > > ---
> > > >  drivers/iio/humidity/hdc100x.c | 6 ++++--
> > > >  1 file changed, 4 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/drivers/iio/humidity/hdc100x.c b/drivers/iio/humidity/hdc100x.c
> > > > index 2a957f19048e..9e0fce917ce4 100644
> > > > --- a/drivers/iio/humidity/hdc100x.c
> > > > +++ b/drivers/iio/humidity/hdc100x.c
> > > > @@ -25,6 +25,8 @@
> > > >  #include <linux/iio/trigger_consumer.h>
> > > >  #include <linux/iio/triggered_buffer.h>
> > > >
> > > > +#include <linux/time.h>
> > > > +
> > > >  #define HDC100X_REG_TEMP                   0x00
> > > >  #define HDC100X_REG_HUMIDITY                       0x01
> > > >
> > > > @@ -166,7 +168,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] + 1*USEC_PER_MSEC;
> > > >     int ret;
> > > >     __be16 val;
> > > >
> > > > @@ -316,7 +318,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] + 2*USEC_PER_MSEC;
> > > >     int ret;
> > > >
> > > >     /* dual read starts at temp register */  
> > >  
> >  


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

end of thread, other threads:[~2021-07-24 17:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-14 14:18 [PATCH v3] iio: humidity: hdc100x: Add margin to the conversion time Chris Lesiak
2021-06-16 12:43 ` Jonathan Cameron
2021-07-18 14:51   ` Jonathan Cameron
2021-07-18 21:31     ` Matt Ranostay
2021-07-24 17:13       ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).