From: Guenter Roeck <linux@roeck-us.net>
To: Amy.Shih@advantech.com.tw
Cc: she90122@gmail.com, oakley.ding@advantech.com.tw,
bichan.lu@advantech.com.tw, Jean Delvare <jdelvare@suse.com>,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [v1,1/1] hwmon: (nct7904) Add array fan_alarm and vsen_alarm to store the alarms in nct7904_data struct.
Date: Wed, 2 Oct 2019 06:43:27 -0700 [thread overview]
Message-ID: <20191002134327.GA9272@roeck-us.net> (raw)
In-Reply-To: <20190919030205.11440-1-Amy.Shih@advantech.com.tw>
On Thu, Sep 19, 2019 at 11:02:05AM +0800, Amy.Shih@advantech.com.tw wrote:
> From: "amy.shih" <amy.shih@advantech.com.tw>
>
> SMI# interrupt for fan and voltage is Two-Times Interrupt Mode.
> Fan or voltage exceeds high limit or going below low limit,
> it will causes an interrupt if the previous interrupt has been
> reset by reading all the interrupt Status Register. Thus, add the
> array fan_alarm and vsen_alarm to store the alarms for all of the
> fan and voltage sensors.
>
> Signed-off-by: amy.shih <amy.shih@advantech.com.tw>
Applied.
Thanks,
Guenter
> ---
> drivers/hwmon/nct7904.c | 22 ++++++++++++++++++++--
> 1 file changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwmon/nct7904.c b/drivers/hwmon/nct7904.c
> index f62dd1882451..b26419dbe840 100644
> --- a/drivers/hwmon/nct7904.c
> +++ b/drivers/hwmon/nct7904.c
> @@ -99,6 +99,8 @@ struct nct7904_data {
> u8 enable_dts;
> u8 has_dts;
> u8 temp_mode; /* 0: TR mode, 1: TD mode */
> + u8 fan_alarm[2];
> + u8 vsen_alarm[3];
> };
>
> /* Access functions */
> @@ -214,7 +216,15 @@ static int nct7904_read_fan(struct device *dev, u32 attr, int channel,
> SMI_STS5_REG + (channel >> 3));
> if (ret < 0)
> return ret;
> - *val = (ret >> (channel & 0x07)) & 1;
> + if (!data->fan_alarm[channel >> 3])
> + data->fan_alarm[channel >> 3] = ret & 0xff;
> + else
> + /* If there is new alarm showing up */
> + data->fan_alarm[channel >> 3] |= (ret & 0xff);
> + *val = (data->fan_alarm[channel >> 3] >> (channel & 0x07)) & 1;
> + /* Needs to clean the alarm if alarm existing */
> + if (*val)
> + data->fan_alarm[channel >> 3] ^= 1 << (channel & 0x07);
> return 0;
> default:
> return -EOPNOTSUPP;
> @@ -298,7 +308,15 @@ static int nct7904_read_in(struct device *dev, u32 attr, int channel,
> SMI_STS1_REG + (index >> 3));
> if (ret < 0)
> return ret;
> - *val = (ret >> (index & 0x07)) & 1;
> + if (!data->vsen_alarm[index >> 3])
> + data->vsen_alarm[index >> 3] = ret & 0xff;
> + else
> + /* If there is new alarm showing up */
> + data->vsen_alarm[index >> 3] |= (ret & 0xff);
> + *val = (data->vsen_alarm[index >> 3] >> (index & 0x07)) & 1;
> + /* Needs to clean the alarm if alarm existing */
> + if (*val)
> + data->vsen_alarm[index >> 3] ^= 1 << (index & 0x07);
> return 0;
> default:
> return -EOPNOTSUPP;
prev parent reply other threads:[~2019-10-02 13:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-19 3:02 [v1,1/1] hwmon: (nct7904) Add array fan_alarm and vsen_alarm to store the alarms in nct7904_data struct Amy.Shih
2019-10-02 13:43 ` Guenter Roeck [this message]
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=20191002134327.GA9272@roeck-us.net \
--to=linux@roeck-us.net \
--cc=Amy.Shih@advantech.com.tw \
--cc=bichan.lu@advantech.com.tw \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oakley.ding@advantech.com.tw \
--cc=she90122@gmail.com \
/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