mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Nicolin Chen <nicoleotsuka@gmail.com>
Cc: jdelvare@suse.com, linux-hwmon@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/5] hwmon: (ina3221) Return -ENODATA for two alarms attributes
Date: Wed, 17 Oct 2018 12:46:05 -0700	[thread overview]
Message-ID: <20181017194605.GB6812@roeck-us.net> (raw)
In-Reply-To: <20181017012426.26958-3-nicoleotsuka@gmail.com>

On Tue, Oct 16, 2018 at 06:24:23PM -0700, Nicolin Chen wrote:
> There is nothing critically wrong to read these two attributes
> without having a is_enabled() check at this point. But reading
> the MASK_ENABLE register would clear the CVRF bit according to
> the datasheet. So it'd be safer to fence for disabled channels
> in order to add pm runtime feature.
> 
> Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
> ---
>  drivers/hwmon/ina3221.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c
> index d61688f04594..3e98b59108ee 100644
> --- a/drivers/hwmon/ina3221.c
> +++ b/drivers/hwmon/ina3221.c
> @@ -200,6 +200,8 @@ static int ina3221_read_curr(struct device *dev, u32 attr,
>  		return 0;
>  	case hwmon_curr_crit_alarm:
>  	case hwmon_curr_max_alarm:
> +		if (!ina3221_is_enabled(ina, channel))
> +			return -ENODATA;

Makes sense, but can you check what the sensors command does with this ?
If it bails out I'd rather have the code return 0 and no error (after all,
the sensor is disabled, so any alarm would be bogus).

Thanks,
Guenter

>  		ret = regmap_field_read(ina->fields[reg], &regval);
>  		if (ret)
>  			return ret;
> -- 
> 2.17.1
> 

  reply	other threads:[~2018-10-17 19:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-17  1:24 [PATCH 0/5] hwmon: (ina3221) Implement PM runtime to save power Nicolin Chen
2018-10-17  1:24 ` [PATCH 1/5] hwmon: (core) Inherit power properties to hdev Nicolin Chen
2018-10-17 19:44   ` Guenter Roeck
2018-10-17 20:15     ` Nicolin Chen
2018-10-18 11:37   ` Dan Carpenter
2018-10-17  1:24 ` [PATCH 2/5] hwmon: (ina3221) Return -ENODATA for two alarms attributes Nicolin Chen
2018-10-17 19:46   ` Guenter Roeck [this message]
2018-10-17 20:39     ` Nicolin Chen
2018-10-17 21:14       ` Guenter Roeck
2018-10-18  1:03         ` Nicolin Chen
2018-10-17  1:24 ` [PATCH 3/5] hwmon: (ina3221) Serialize sysfs ABI accesses Nicolin Chen
2018-10-17  1:24 ` [PATCH 4/5] hwmon: (ina3221) Make sure data is ready after channel enabling Nicolin Chen
2018-10-17 16:55   ` Guenter Roeck
2018-10-17 20:53     ` Nicolin Chen
2018-10-17 21:17       ` Guenter Roeck
2018-10-18  1:04         ` Nicolin Chen
2018-10-17  1:24 ` [PATCH 5/5] hwmon: (ina3221) Add PM runtime support Nicolin Chen

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=20181017194605.GB6812@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicoleotsuka@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

all inboxes | Powered by JetHome®