All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Václav Kubernát" <kubernat@cesnet.cz>
To: Guenter Roeck <linux@roeck-us.net>
Cc: linux-hwmon@vger.kernel.org, "Jean Delvare" <jdelvare@suse.com>,
	"Jan Kundrát" <jan.kundrat@cesnet.cz>
Subject: Re: [PATCH 5/7] hwmon: (max31790) Clear fan fault after reporting it
Date: Tue, 1 Jun 2021 10:08:50 +0200	[thread overview]
Message-ID: <CABKa3npepB4CnEsPqEZffZm+9ALePTUH2hej9AGGYu9h0667MA@mail.gmail.com> (raw)
In-Reply-To: <20210526154022.3223012-6-linux@roeck-us.net>

Fan fault reading/clearing works fine.

Tested-by: Václav Kubernát <kubernat@cesnet.cz>

st 26. 5. 2021 v 17:41 odesílatel Guenter Roeck <linux@roeck-us.net> napsal:
>
> Fault bits in MAX31790 are sticky and have to be cleared explicitly.
> A write operation into either the 'Target Duty Cycle' register or the
> 'Target Count' register is necessary to clear a fault.
>
> At the same time, we can never clear cached fault status values before
> reading them because the companion fault status for any given fan is
> cleared as well when clearing a fault.
>
> Cc: Jan Kundrát <jan.kundrat@cesnet.cz>
> Cc: Václav Kubernát <kubernat@cesnet.cz>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  drivers/hwmon/max31790.c | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/max31790.c b/drivers/hwmon/max31790.c
> index 19651feb40fb..8e4fd9b7c889 100644
> --- a/drivers/hwmon/max31790.c
> +++ b/drivers/hwmon/max31790.c
> @@ -80,7 +80,7 @@ static struct max31790_data *max31790_update_device(struct device *dev)
>                                 MAX31790_REG_FAN_FAULT_STATUS1);
>                 if (rv < 0)
>                         goto abort;
> -               data->fault_status = rv & 0x3F;
> +               data->fault_status |= rv & 0x3F;
>
>                 rv = i2c_smbus_read_byte_data(client,
>                                 MAX31790_REG_FAN_FAULT_STATUS2);
> @@ -184,7 +184,21 @@ static int max31790_read_fan(struct device *dev, u32 attr, int channel,
>                 *val = rpm;
>                 return 0;
>         case hwmon_fan_fault:
> +               mutex_lock(&data->update_lock);
>                 *val = !!(data->fault_status & (1 << channel));
> +               data->fault_status &= ~(1 << channel);
> +               /*
> +                * If a fault bit is set, we need to write into one of the fan
> +                * configuration registers to clear it. Note that this also
> +                * clears the fault for the companion channel if enabled.
> +                */
> +               if (*val) {
> +                       int reg = MAX31790_REG_TARGET_COUNT(channel % NR_CHANNEL);
> +
> +                       i2c_smbus_write_byte_data(data->client, reg,
> +                                                 data->target_count[channel % NR_CHANNEL] >> 8);
> +               }
> +               mutex_unlock(&data->update_lock);
>                 return 0;
>         default:
>                 return -EOPNOTSUPP;
> --
> 2.25.1
>

  reply	other threads:[~2021-06-01  8:09 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26 15:40 [PATCH 0/7] hwmon: (max31790) Fixes and improvements Guenter Roeck
2021-05-26 15:40 ` [PATCH 1/7] hwmon: (max31790) Fix fan speed reporting for fan7..12 Guenter Roeck
2021-06-02 12:27   ` Jan Kundrát
2021-05-26 15:40 ` [PATCH 2/7] hwmon: (max31790) Report correct current pwm duty cycles Guenter Roeck
2021-06-01  7:51   ` Václav Kubernát
2021-06-02 12:36   ` Jan Kundrát
2021-05-26 15:40 ` [PATCH 3/7] hwmon: (max31790) Fix pwmX_enable attributes Guenter Roeck
2021-06-01  8:01   ` Václav Kubernát
2021-06-02 10:47     ` Guenter Roeck
2021-06-02 12:44   ` Jan Kundrát
2021-05-26 15:40 ` [PATCH 4/7] hwmon: (max31790) Add support for fanX_enable attributes Guenter Roeck
2021-06-01  8:02   ` Václav Kubernát
2021-06-02 13:04   ` Jan Kundrát
2021-06-02 16:43     ` Guenter Roeck
2021-05-26 15:40 ` [PATCH 5/7] hwmon: (max31790) Clear fan fault after reporting it Guenter Roeck
2021-06-01  8:08   ` Václav Kubernát [this message]
2021-05-26 15:40 ` [PATCH 6/7] hwmon: (max31790) Detect and report zero fan speed Guenter Roeck
2021-06-01  8:11   ` Václav Kubernát
2021-05-26 15:40 ` [PATCH 7/7] hwmon: (max31790) Add support for fanX_min attributes Guenter Roeck
2021-06-01  8:19   ` Václav Kubernát
2021-06-01  8:29 ` [PATCH 0/7] hwmon: (max31790) Fixes and improvements Václav Kubernát
2021-06-01 12:08   ` Guenter Roeck

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=CABKa3npepB4CnEsPqEZffZm+9ALePTUH2hej9AGGYu9h0667MA@mail.gmail.com \
    --to=kubernat@cesnet.cz \
    --cc=jan.kundrat@cesnet.cz \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /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 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.