All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: palmas: shut up warning about calibration mismatch (due to noise)
@ 2022-03-08 12:53 H. Nikolaus Schaller
  2022-03-20 15:52 ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: H. Nikolaus Schaller @ 2022-03-08 12:53 UTC (permalink / raw)
  To: Jonathan Cameron, Colin Ian King, Sergiu Cuciurean, Julia Lawall,
	H. Nikolaus Schaller
  Cc: Lars-Peter Clausen, linux-iio, linux-kernel, letux-kernel,
	kernel, linux-omap

Although technically checking for ADC values below 0 is correct,
because they are outside of the calibration values, there is usually
noise which spuriously fills the console log with error messages if
calculated input voltage gets close to 0V.

Ignore small negative calculated values, but clamp them to 0.

Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
---
 drivers/iio/adc/palmas_gpadc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c
index f9c8385c72d3..bcfa6a7f6cb2 100644
--- a/drivers/iio/adc/palmas_gpadc.c
+++ b/drivers/iio/adc/palmas_gpadc.c
@@ -376,7 +376,8 @@ static int palmas_gpadc_get_calibrated_code(struct palmas_gpadc *adc,
 					adc->adc_info[adc_chan].gain_error;
 
 	if (val < 0) {
-		dev_err(adc->dev, "Mismatch with calibration\n");
+		if (val < -10)
+			dev_err(adc->dev, "Mismatch with calibration var = %d\n", val);
 		return 0;
 	}
 
-- 
2.33.0


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

* Re: [PATCH] iio: palmas: shut up warning about calibration mismatch (due to noise)
  2022-03-08 12:53 [PATCH] iio: palmas: shut up warning about calibration mismatch (due to noise) H. Nikolaus Schaller
@ 2022-03-20 15:52 ` Jonathan Cameron
  2022-03-20 16:28   ` H. Nikolaus Schaller
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2022-03-20 15:52 UTC (permalink / raw)
  To: H. Nikolaus Schaller
  Cc: Colin Ian King, Sergiu Cuciurean, Julia Lawall,
	Lars-Peter Clausen, linux-iio, linux-kernel, letux-kernel,
	kernel, linux-omap

On Tue,  8 Mar 2022 13:53:03 +0100
"H. Nikolaus Schaller" <hns@goldelico.com> wrote:

> Although technically checking for ADC values below 0 is correct,
> because they are outside of the calibration values, there is usually
> noise which spuriously fills the console log with error messages if
> calculated input voltage gets close to 0V.
> 
> Ignore small negative calculated values, but clamp them to 0.
> 
> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Hi.

Should we treat this as a fix or a cleanup?

I don't mind either way.

Jonathan


> ---
>  drivers/iio/adc/palmas_gpadc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c
> index f9c8385c72d3..bcfa6a7f6cb2 100644
> --- a/drivers/iio/adc/palmas_gpadc.c
> +++ b/drivers/iio/adc/palmas_gpadc.c
> @@ -376,7 +376,8 @@ static int palmas_gpadc_get_calibrated_code(struct palmas_gpadc *adc,
>  					adc->adc_info[adc_chan].gain_error;
>  
>  	if (val < 0) {
> -		dev_err(adc->dev, "Mismatch with calibration\n");
> +		if (val < -10)
> +			dev_err(adc->dev, "Mismatch with calibration var = %d\n", val);
>  		return 0;
>  	}
>  


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

* Re: [PATCH] iio: palmas: shut up warning about calibration mismatch (due to noise)
  2022-03-20 15:52 ` Jonathan Cameron
@ 2022-03-20 16:28   ` H. Nikolaus Schaller
  2022-03-27 16:13     ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: H. Nikolaus Schaller @ 2022-03-20 16:28 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Colin Ian King, Sergiu Cuciurean, Julia Lawall,
	Lars-Peter Clausen, linux-iio, linux-kernel, letux-kernel,
	kernel, linux-omap

Hi Jonathan,

> Am 20.03.2022 um 16:52 schrieb Jonathan Cameron <jic23@kernel.org>:
> 
> On Tue,  8 Mar 2022 13:53:03 +0100
> "H. Nikolaus Schaller" <hns@goldelico.com> wrote:
> 
>> Although technically checking for ADC values below 0 is correct,
>> because they are outside of the calibration values, there is usually
>> noise which spuriously fills the console log with error messages if
>> calculated input voltage gets close to 0V.
>> 
>> Ignore small negative calculated values, but clamp them to 0.
>> 
>> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
> Hi.
> 
> Should we treat this as a fix or a cleanup?
> 
> I don't mind either way.

I don't mind either since we have it for long time in our distribution kernel.

BR and thanks,
Nikolaus

> 
> Jonathan
> 
> 
>> ---
>> drivers/iio/adc/palmas_gpadc.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>> 
>> diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c
>> index f9c8385c72d3..bcfa6a7f6cb2 100644
>> --- a/drivers/iio/adc/palmas_gpadc.c
>> +++ b/drivers/iio/adc/palmas_gpadc.c
>> @@ -376,7 +376,8 @@ static int palmas_gpadc_get_calibrated_code(struct palmas_gpadc *adc,
>> 					adc->adc_info[adc_chan].gain_error;
>> 
>> 	if (val < 0) {
>> -		dev_err(adc->dev, "Mismatch with calibration\n");
>> +		if (val < -10)
>> +			dev_err(adc->dev, "Mismatch with calibration var = %d\n", val);
>> 		return 0;
>> 	}
>> 
> 


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

* Re: [PATCH] iio: palmas: shut up warning about calibration mismatch (due to noise)
  2022-03-20 16:28   ` H. Nikolaus Schaller
@ 2022-03-27 16:13     ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2022-03-27 16:13 UTC (permalink / raw)
  To: H. Nikolaus Schaller
  Cc: Colin Ian King, Sergiu Cuciurean, Julia Lawall,
	Lars-Peter Clausen, linux-iio, linux-kernel, letux-kernel,
	kernel, linux-omap

On Sun, 20 Mar 2022 17:28:21 +0100
"H. Nikolaus Schaller" <hns@goldelico.com> wrote:

> Hi Jonathan,
> 
> > Am 20.03.2022 um 16:52 schrieb Jonathan Cameron <jic23@kernel.org>:
> > 
> > On Tue,  8 Mar 2022 13:53:03 +0100
> > "H. Nikolaus Schaller" <hns@goldelico.com> wrote:
> >   
> >> Although technically checking for ADC values below 0 is correct,
> >> because they are outside of the calibration values, there is usually
> >> noise which spuriously fills the console log with error messages if
> >> calculated input voltage gets close to 0V.
> >> 
> >> Ignore small negative calculated values, but clamp them to 0.
> >> 
> >> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>  
> > Hi.
> > 
> > Should we treat this as a fix or a cleanup?
> > 
> > I don't mind either way.  
> 
> I don't mind either since we have it for long time in our distribution kernel.
> 
> BR and thanks,
> Nikolaus

Treated as cleanup so applied to the togreg branch of iio.git, but for now
only pushed out as testing because I'll be rebasing on rc1 next week.

Thanks,

Jonathan

> 
> > 
> > Jonathan
> > 
> >   
> >> ---
> >> drivers/iio/adc/palmas_gpadc.c | 3 ++-
> >> 1 file changed, 2 insertions(+), 1 deletion(-)
> >> 
> >> diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c
> >> index f9c8385c72d3..bcfa6a7f6cb2 100644
> >> --- a/drivers/iio/adc/palmas_gpadc.c
> >> +++ b/drivers/iio/adc/palmas_gpadc.c
> >> @@ -376,7 +376,8 @@ static int palmas_gpadc_get_calibrated_code(struct palmas_gpadc *adc,
> >> 					adc->adc_info[adc_chan].gain_error;
> >> 
> >> 	if (val < 0) {
> >> -		dev_err(adc->dev, "Mismatch with calibration\n");
> >> +		if (val < -10)
> >> +			dev_err(adc->dev, "Mismatch with calibration var = %d\n", val);
> >> 		return 0;
> >> 	}
> >>   
> >   
> 


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

end of thread, other threads:[~2022-03-27 16:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-08 12:53 [PATCH] iio: palmas: shut up warning about calibration mismatch (due to noise) H. Nikolaus Schaller
2022-03-20 15:52 ` Jonathan Cameron
2022-03-20 16:28   ` H. Nikolaus Schaller
2022-03-27 16:13     ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.