public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
From: Wei Ni <wni@nvidia.com>
To: Jean Delvare <khali@linux-fr.org>
Cc: "linux@roeck-us.net" <linux@roeck-us.net>,
	"lm-sensors@lm-sensors.org" <lm-sensors@lm-sensors.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>
Subject: Re: [PATCH v4 1/3] hwmon: (lm90) Define status bits
Date: Thu, 31 Oct 2013 10:47:32 +0800	[thread overview]
Message-ID: <5271C4C4.2040308@nvidia.com> (raw)
In-Reply-To: <20131030164113.1396964e@endymion.delvare>

On 10/30/2013 11:41 PM, Jean Delvare wrote:
> Hi Wei,
> 
> On Wed, 7 Aug 2013 14:18:24 +0800, Wei Ni wrote:
>> Add bit defines for the status register. And add a function
>> lm90_is_tripped() which will read status register and return
>> tripped or not, then lm90_alert can call it directly, and in the
>> future the IRQ thread also can use it.
>>
>> Signed-off-by: Wei Ni <wni@nvidia.com>
>> ---
>>  drivers/hwmon/lm90.c |   75 +++++++++++++++++++++++++++++++++-----------------
>>  1 file changed, 50 insertions(+), 25 deletions(-)
>>
>> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
>> index cdff742..1da2eff 100644
>> --- a/drivers/hwmon/lm90.c
>> +++ b/drivers/hwmon/lm90.c
>> @@ -179,6 +179,18 @@ enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680,
>>  #define LM90_HAVE_TEMP3		(1 << 6) /* 3rd temperature sensor	*/
>>  #define LM90_HAVE_BROKEN_ALERT	(1 << 7) /* Broken alert		*/
>>  
>> +/* LM90 status */
>> +#define LM90_STATUS_LTHRM	(1 << 0) /* local THERM limit tripped */
>> +#define LM90_STATUS_RTHRM	(1 << 1) /* remote THERM limit tripped */
>> +#define LM90_STATUS_OPEN	(1 << 2) /* remote is an open circuit */
>> +#define LM90_STATUS_RLOW	(1 << 3) /* remote low temp limit tripped */
>> +#define LM90_STATUS_RHIGH	(1 << 4) /* remote high temp limit tripped */
>> +#define LM90_STATUS_LLOW	(1 << 5) /* local low temp limit tripped */
>> +#define LM90_STATUS_LHIGH	(1 << 6) /* local high temp limit tripped */
>> +
>> +#define MAX6696_STATUS2_RLOW	(1 << 3) /* remote2 low temp limit tripped */
>> +#define MAX6696_STATUS2_RHIGH	(1 << 4) /* remote2 high temp limit tripped */
>> +
>>  /*
>>   * Driver data (common to all clients)
>>   */
>> @@ -1391,6 +1403,36 @@ static void lm90_init_client(struct i2c_client *client)
>>  		i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config);
>>  }
>>  
>> +static bool lm90_is_tripped(struct i2c_client *client)
>> +{
>> +	struct lm90_data *data = i2c_get_clientdata(client);
>> +	u8 status, status2 = 0;
>> +
>> +	lm90_read_reg(client, LM90_REG_R_STATUS, &status);
>> +
>> +	if (data->kind == max6696)
>> +		lm90_read_reg(client, MAX6696_REG_R_STATUS2, &status2);
>> +
>> +	if ((status & 0x7f) == 0 && (status2 & 0xfe) == 0)
>> +		return false;
>> +
>> +	if (status & (LM90_STATUS_LLOW | LM90_STATUS_LHIGH | LM90_STATUS_LTHRM))
>> +		dev_warn(&client->dev,
>> +			 "temp%d out of range, please check!\n", 1);
>> +	if (status & (LM90_STATUS_RLOW | LM90_STATUS_RHIGH | LM90_STATUS_RTHRM))
>> +		dev_warn(&client->dev,
>> +			 "temp%d out of range, please check!\n", 2);
>> +	if (status & LM90_STATUS_OPEN)
>> +		dev_warn(&client->dev,
>> +			 "temp%d diode open, please check!\n", 2);
>> +
>> +	if (status2 & (MAX6696_STATUS2_RLOW | MAX6696_STATUS2_RHIGH))
>> +		dev_warn(&client->dev,
>> +			 "temp%d out of range, please check!\n", 3);
>> +
>> +	return true;
>> +}
>> +
>>  static int lm90_probe(struct i2c_client *client,
>>  		      const struct i2c_device_id *id)
>>  {
>> @@ -1489,36 +1531,17 @@ static int lm90_remove(struct i2c_client *client)
>>  
>>  static void lm90_alert(struct i2c_client *client, unsigned int flag)
>>  {
>> -	struct lm90_data *data = i2c_get_clientdata(client);
>> -	u8 config, alarms, alarms2 = 0;
>> -
>> -	lm90_read_reg(client, LM90_REG_R_STATUS, &alarms);
>> -
>> -	if (data->kind == max6696)
>> -		lm90_read_reg(client, MAX6696_REG_R_STATUS2, &alarms2);
>> -
>> -	if ((alarms & 0x7f) == 0 && (alarms2 & 0xfe) == 0) {
>> -		dev_info(&client->dev, "Everything OK\n");
>> -	} else {
>> -		if (alarms & 0x61)
>> -			dev_warn(&client->dev,
>> -				 "temp%d out of range, please check!\n", 1);
>> -		if (alarms & 0x1a)
>> -			dev_warn(&client->dev,
>> -				 "temp%d out of range, please check!\n", 2);
>> -		if (alarms & 0x04)
>> -			dev_warn(&client->dev,
>> -				 "temp%d diode open, please check!\n", 2);
>> -
>> -		if (alarms2 & 0x18)
>> -			dev_warn(&client->dev,
>> -				 "temp%d out of range, please check!\n", 3);
>> -
>> +	if (lm90_is_tripped(client)) {
> 
> You are reading LM90_REG_R_STATUS here...
> 
>>  		/*
>>  		 * Disable ALERT# output, because these chips don't implement
>>  		 * SMBus alert correctly; they should only hold the alert line
>>  		 * low briefly.
>>  		 */
>> +		struct lm90_data *data = i2c_get_clientdata(client);
>> +		u8 config, alarms;
>> +
>> +		lm90_read_reg(client, LM90_REG_R_STATUS, &alarms);
> 
> ... and here again. I already complained about this in my previous
> review of this patch, and you were supposed to address it, but you did
> not. As a result I am still not happy with this patch and I can't apply
> it, sorry.

It's so sorry, I made a mistake, I sent a old patch for this. I will
sent the right one right now.
Sorry again.

Wei.

> 
>> +
>>  		if ((data->flags & LM90_HAVE_BROKEN_ALERT)
>>  		 && (alarms & data->alert_alarms)) {
>>  			dev_dbg(&client->dev, "Disabling ALERT#\n");
>> @@ -1526,6 +1549,8 @@ static void lm90_alert(struct i2c_client *client, unsigned int flag)
>>  			i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
>>  						  config | 0x80);
>>  		}
>> +	} else {
>> +		dev_info(&client->dev, "Everything OK\n");
>>  	}
>>  }
>>  
> 

  parent reply	other threads:[~2013-10-31  2:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-07  6:18 [PATCH v4 0/3] Lm90 Enhancements Wei Ni
2013-08-07  6:18 ` [PATCH v4 1/3] hwmon: (lm90) Define status bits Wei Ni
     [not found]   ` <1375856306-14415-2-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-10-30 15:41     ` Jean Delvare
2013-10-30 17:03       ` Guenter Roeck
2013-10-31  2:47       ` Wei Ni [this message]
     [not found]         ` <5271C4C4.2040308-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-10-31  3:09           ` Wei Ni
     [not found] ` <1375856306-14415-1-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-08-07  6:18   ` [PATCH v4 2/3] hwmon: (lm90) add support to handle IRQ Wei Ni
     [not found]     ` <1375856306-14415-3-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-10-30 15:53       ` Jean Delvare
2013-11-04  9:34       ` Jean Delvare
     [not found]         ` <20131104103434.5a085e27-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-11-04 10:05           ` Wei Ni
2013-09-09  6:16   ` [PATCH v4 0/3] Lm90 Enhancements Wei Ni
     [not found]     ` <522D67B2.4030406-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-09-09  7:42       ` Jean Delvare
2013-08-07  6:18 ` [PATCH v4 3/3] hwmon: (lm90) use enums for the indexes of temp8 and temp11 Wei Ni
     [not found]   ` <1375856306-14415-4-git-send-email-wni-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-10-30 16:21     ` Jean Delvare

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5271C4C4.2040308@nvidia.com \
    --to=wni@nvidia.com \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=lm-sensors@lm-sensors.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox