All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwmon: (lm90) Fix false alarm when writing convrate on max6658
@ 2021-03-04 15:38 Paul Menzel
  2021-03-11 22:15 ` Guenter Roeck
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Menzel @ 2021-03-04 15:38 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck
  Cc: linux-hwmon, Guohan Lu, Boyang Yu, Paul Menzel

From: Boyang Yu <byu@arista.com>

We found that the max6658 sometimes issues a false alarm when its
convrate is changed, with the current hwmon driver. This workaround
will fix it by stopping the conversion before setting the convrate.

Upstream the patch added added to the SONiC Linux kernel in merge/pull
request #82 [1][2].

[1]: https://github.com/Azure/sonic-linux-kernel/pull/82
[2]: https://github.com/Azure/sonic-linux-kernel/commit/d03f6167f64b2bfa1330ff7b33fe217f68ab7028

[pmenzel: Forward port patch from 4.19 to 5.12-rc1+]
Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
---
 drivers/hwmon/lm90.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index ebbfd5f352c0..0c1a91b715e8 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -639,7 +639,11 @@ static int lm90_set_convrate(struct i2c_client *client, struct lm90_data *data,
 		if (interval >= update_interval * 3 / 4)
 			break;
 
-	err = lm90_write_convrate(data, i);
+	if (data->kind == max6657)
+		err = max6657_write_convrate(client, i);
+	else
+		err = lm90_write_convrate(data, i);
+
 	data->update_interval = DIV_ROUND_CLOSEST(update_interval, 64);
 	return err;
 }
@@ -1649,7 +1653,11 @@ static void lm90_restore_conf(void *_data)
 	struct i2c_client *client = data->client;
 
 	/* Restore initial configuration */
-	lm90_write_convrate(data, data->convrate_orig);
+	if (data->kind == max6657)
+		max6657_write_convrate(client, data->convrate_orig);
+	else
+		lm90_write_convrate(data, data->convrate_orig);
+
 	i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
 				  data->config_orig);
 }
@@ -1672,7 +1680,8 @@ static int lm90_init_client(struct i2c_client *client, struct lm90_data *data)
 	data->config_orig = config;
 	data->config = config;
 
-	lm90_set_convrate(client, data, 500); /* 500ms; 2Hz conversion rate */
+	if (data->kind != max6657)
+		lm90_set_convrate(client, data, 500); /* 500ms; 2Hz conversion rate */
 
 	/* Check Temperature Range Select */
 	if (data->kind == adt7461 || data->kind == tmp451) {
-- 
2.30.1


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

* Re: [PATCH] hwmon: (lm90) Fix false alarm when writing convrate on max6658
  2021-03-04 15:38 [PATCH] hwmon: (lm90) Fix false alarm when writing convrate on max6658 Paul Menzel
@ 2021-03-11 22:15 ` Guenter Roeck
  2021-03-12  7:48   ` Paul Menzel
  0 siblings, 1 reply; 7+ messages in thread
From: Guenter Roeck @ 2021-03-11 22:15 UTC (permalink / raw)
  To: Paul Menzel; +Cc: Jean Delvare, linux-hwmon, Guohan Lu, Boyang Yu

On Thu, Mar 04, 2021 at 04:38:32PM +0100, Paul Menzel wrote:
> From: Boyang Yu <byu@arista.com>
> 
> We found that the max6658 sometimes issues a false alarm when its
> convrate is changed, with the current hwmon driver. This workaround
> will fix it by stopping the conversion before setting the convrate.
> 
> Upstream the patch added added to the SONiC Linux kernel in merge/pull
> request #82 [1][2].
> 
> [1]: https://github.com/Azure/sonic-linux-kernel/pull/82
> [2]: https://github.com/Azure/sonic-linux-kernel/commit/d03f6167f64b2bfa1330ff7b33fe217f68ab7028
> 
> [pmenzel: Forward port patch from 4.19 to 5.12-rc1+]
> Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
> ---
>  drivers/hwmon/lm90.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
> index ebbfd5f352c0..0c1a91b715e8 100644
> --- a/drivers/hwmon/lm90.c
> +++ b/drivers/hwmon/lm90.c
> @@ -639,7 +639,11 @@ static int lm90_set_convrate(struct i2c_client *client, struct lm90_data *data,
>  		if (interval >= update_interval * 3 / 4)
>  			break;
>  
> -	err = lm90_write_convrate(data, i);
> +	if (data->kind == max6657)
> +		err = max6657_write_convrate(client, i);

There is no such function in the upstream kernel.
Anyway, this problem has already been already fixed
in the upstream kernel with commit 62456189f3292 ("hwmon:
(lm90) Fix max6658 sporadic wrong temperature reading").

Guenter

> +	else
> +		err = lm90_write_convrate(data, i);
> +
>  	data->update_interval = DIV_ROUND_CLOSEST(update_interval, 64);
>  	return err;
>  }
> @@ -1649,7 +1653,11 @@ static void lm90_restore_conf(void *_data)
>  	struct i2c_client *client = data->client;
>  
>  	/* Restore initial configuration */
> -	lm90_write_convrate(data, data->convrate_orig);
> +	if (data->kind == max6657)
> +		max6657_write_convrate(client, data->convrate_orig);
> +	else
> +		lm90_write_convrate(data, data->convrate_orig);
> +
>  	i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
>  				  data->config_orig);
>  }
> @@ -1672,7 +1680,8 @@ static int lm90_init_client(struct i2c_client *client, struct lm90_data *data)
>  	data->config_orig = config;
>  	data->config = config;
>  
> -	lm90_set_convrate(client, data, 500); /* 500ms; 2Hz conversion rate */
> +	if (data->kind != max6657)
> +		lm90_set_convrate(client, data, 500); /* 500ms; 2Hz conversion rate */
>  
>  	/* Check Temperature Range Select */
>  	if (data->kind == adt7461 || data->kind == tmp451) {

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

* Re: [PATCH] hwmon: (lm90) Fix false alarm when writing convrate on max6658
  2021-03-11 22:15 ` Guenter Roeck
@ 2021-03-12  7:48   ` Paul Menzel
  2021-03-12 14:48     ` Guenter Roeck
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Menzel @ 2021-03-12  7:48 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: Jean Delvare, linux-hwmon, Guohan Lu, Boyang Yu

Dear Guenter,


Thank you for your reply.

Am 11.03.21 um 23:15 schrieb Guenter Roeck:
> On Thu, Mar 04, 2021 at 04:38:32PM +0100, Paul Menzel wrote:
>> From: Boyang Yu <byu@arista.com>
>>
>> We found that the max6658 sometimes issues a false alarm when its
>> convrate is changed, with the current hwmon driver. This workaround
>> will fix it by stopping the conversion before setting the convrate.
>>
>> Upstream the patch added added to the SONiC Linux kernel in merge/pull
>> request #82 [1][2].
>>
>> [1]: https://github.com/Azure/sonic-linux-kernel/pull/82
>> [2]: https://github.com/Azure/sonic-linux-kernel/commit/d03f6167f64b2bfa1330ff7b33fe217f68ab7028
>>
>> [pmenzel: Forward port patch from 4.19 to 5.12-rc1+]
>> Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
>> ---
>>   drivers/hwmon/lm90.c | 15 ++++++++++++---
>>   1 file changed, 12 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
>> index ebbfd5f352c0..0c1a91b715e8 100644
>> --- a/drivers/hwmon/lm90.c
>> +++ b/drivers/hwmon/lm90.c
>> @@ -639,7 +639,11 @@ static int lm90_set_convrate(struct i2c_client *client, struct lm90_data *data,
>>   		if (interval >= update_interval * 3 / 4)
>>   			break;
>>   
>> -	err = lm90_write_convrate(data, i);
>> +	if (data->kind == max6657)
>> +		err = max6657_write_convrate(client, i);
> 
> There is no such function in the upstream kernel.

Hmm, why did that hunk get lost when preparing the patch? I am sorry for 
this oversight.

> Anyway, this problem has already been already fixed
> in the upstream kernel with commit 62456189f3292 ("hwmon:
> (lm90) Fix max6658 sporadic wrong temperature reading").

Ah, indeed. Thank you for pointing that out. It’d be great to have that 
included in the 4.19 LTS series. Would it be alright, if I contacted the 
stable series maintainers?


Kind regards,

Paul


>> +	else
>> +		err = lm90_write_convrate(data, i);
>> +
>>   	data->update_interval = DIV_ROUND_CLOSEST(update_interval, 64);
>>   	return err;
>>   }
>> @@ -1649,7 +1653,11 @@ static void lm90_restore_conf(void *_data)
>>   	struct i2c_client *client = data->client;
>>   
>>   	/* Restore initial configuration */
>> -	lm90_write_convrate(data, data->convrate_orig);
>> +	if (data->kind == max6657)
>> +		max6657_write_convrate(client, data->convrate_orig);
>> +	else
>> +		lm90_write_convrate(data, data->convrate_orig);
>> +
>>   	i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
>>   				  data->config_orig);
>>   }
>> @@ -1672,7 +1680,8 @@ static int lm90_init_client(struct i2c_client *client, struct lm90_data *data)
>>   	data->config_orig = config;
>>   	data->config = config;
>>   
>> -	lm90_set_convrate(client, data, 500); /* 500ms; 2Hz conversion rate */
>> +	if (data->kind != max6657)
>> +		lm90_set_convrate(client, data, 500); /* 500ms; 2Hz conversion rate */
>>   
>>   	/* Check Temperature Range Select */
>>   	if (data->kind == adt7461 || data->kind == tmp451) {

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

* Re: [PATCH] hwmon: (lm90) Fix false alarm when writing convrate on max6658
  2021-03-12  7:48   ` Paul Menzel
@ 2021-03-12 14:48     ` Guenter Roeck
  2021-03-12 16:53       ` hwmon: (lm90) Fix max6658 sporadic wrong temperature reading Paul Menzel
  0 siblings, 1 reply; 7+ messages in thread
From: Guenter Roeck @ 2021-03-12 14:48 UTC (permalink / raw)
  To: Paul Menzel; +Cc: Jean Delvare, linux-hwmon, Guohan Lu, Boyang Yu

On 3/11/21 11:48 PM, Paul Menzel wrote:
> Dear Guenter,
> 
> 
> Thank you for your reply.
> 
> Am 11.03.21 um 23:15 schrieb Guenter Roeck:
>> On Thu, Mar 04, 2021 at 04:38:32PM +0100, Paul Menzel wrote:
>>> From: Boyang Yu <byu@arista.com>
>>>
>>> We found that the max6658 sometimes issues a false alarm when its
>>> convrate is changed, with the current hwmon driver. This workaround
>>> will fix it by stopping the conversion before setting the convrate.
>>>
>>> Upstream the patch added added to the SONiC Linux kernel in merge/pull
>>> request #82 [1][2].
>>>
>>> [1]: https://github.com/Azure/sonic-linux-kernel/pull/82
>>> [2]: https://github.com/Azure/sonic-linux-kernel/commit/d03f6167f64b2bfa1330ff7b33fe217f68ab7028
>>>
>>> [pmenzel: Forward port patch from 4.19 to 5.12-rc1+]
>>> Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
>>> ---
>>>   drivers/hwmon/lm90.c | 15 ++++++++++++---
>>>   1 file changed, 12 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
>>> index ebbfd5f352c0..0c1a91b715e8 100644
>>> --- a/drivers/hwmon/lm90.c
>>> +++ b/drivers/hwmon/lm90.c
>>> @@ -639,7 +639,11 @@ static int lm90_set_convrate(struct i2c_client *client, struct lm90_data *data,
>>>           if (interval >= update_interval * 3 / 4)
>>>               break;
>>>   -    err = lm90_write_convrate(data, i);
>>> +    if (data->kind == max6657)
>>> +        err = max6657_write_convrate(client, i);
>>
>> There is no such function in the upstream kernel.
> 
> Hmm, why did that hunk get lost when preparing the patch? I am sorry for this oversight.
> 
No worries.

>> Anyway, this problem has already been already fixed
>> in the upstream kernel with commit 62456189f3292 ("hwmon:
>> (lm90) Fix max6658 sporadic wrong temperature reading").
> 
> Ah, indeed. Thank you for pointing that out. It’d be great to have that included in the 4.19 LTS series. Would it be alright, if I contacted the stable series maintainers?
> 

Sure.

Guenter

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

* hwmon: (lm90) Fix max6658 sporadic wrong temperature reading
  2021-03-12 14:48     ` Guenter Roeck
@ 2021-03-12 16:53       ` Paul Menzel
  2021-03-12 19:24         ` Guenter Roeck
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Menzel @ 2021-03-12 16:53 UTC (permalink / raw)
  To: stable; +Cc: Jean Delvare, linux-hwmon, Guohan Lu, Boyang Yu, Guenter Roeck

Dear Linux folks,


Could you please apply commit 62456189f3292c62f87aef363f204886dc1d4b48 
to the Linux 4.19 stable series?


Kind regards,

Paul

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

* Re: hwmon: (lm90) Fix max6658 sporadic wrong temperature reading
  2021-03-12 16:53       ` hwmon: (lm90) Fix max6658 sporadic wrong temperature reading Paul Menzel
@ 2021-03-12 19:24         ` Guenter Roeck
  2021-03-15  9:30           ` Greg KH
  0 siblings, 1 reply; 7+ messages in thread
From: Guenter Roeck @ 2021-03-12 19:24 UTC (permalink / raw)
  To: Paul Menzel; +Cc: stable, Jean Delvare, linux-hwmon, Guohan Lu, Boyang Yu

On Fri, Mar 12, 2021 at 05:53:49PM +0100, Paul Menzel wrote:
> Dear Linux folks,
> 
> 
> Could you please apply commit 62456189f3292c62f87aef363f204886dc1d4b48 to
> the Linux 4.19 stable series?
> 

v4.9.y..v1.19.y, actually, please.

Thanks,
Guenter

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

* Re: hwmon: (lm90) Fix max6658 sporadic wrong temperature reading
  2021-03-12 19:24         ` Guenter Roeck
@ 2021-03-15  9:30           ` Greg KH
  0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2021-03-15  9:30 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Paul Menzel, stable, Jean Delvare, linux-hwmon, Guohan Lu, Boyang Yu

On Fri, Mar 12, 2021 at 11:24:57AM -0800, Guenter Roeck wrote:
> On Fri, Mar 12, 2021 at 05:53:49PM +0100, Paul Menzel wrote:
> > Dear Linux folks,
> > 
> > 
> > Could you please apply commit 62456189f3292c62f87aef363f204886dc1d4b48 to
> > the Linux 4.19 stable series?
> > 
> 
> v4.9.y..v1.19.y, actually, please.

Now done, thanks.

greg k-h

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

end of thread, other threads:[~2021-03-15  9:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-04 15:38 [PATCH] hwmon: (lm90) Fix false alarm when writing convrate on max6658 Paul Menzel
2021-03-11 22:15 ` Guenter Roeck
2021-03-12  7:48   ` Paul Menzel
2021-03-12 14:48     ` Guenter Roeck
2021-03-12 16:53       ` hwmon: (lm90) Fix max6658 sporadic wrong temperature reading Paul Menzel
2021-03-12 19:24         ` Guenter Roeck
2021-03-15  9:30           ` Greg KH

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.