linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Dinh Nguyen <dinh.nguyen@linux.intel.com>
Cc: Guenter Roeck <linux@roeck-us.net>,
	linux-hwmon@vger.kernel.org, dinguyen@kernel.org,
	devicetree@vger.kernel.org, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, linux-kernel@vger.kernel.org,
	jdelvare@suse.com
Subject: Re: [PATCH 3/5] hwmon: (socfpga) Add hardware monitoring support on SoCFPGA platforms
Date: Wed, 19 Apr 2023 14:46:58 +0300	[thread overview]
Message-ID: <ZD/UsuzhZmK3AFJn@smile.fi.intel.com> (raw)
In-Reply-To: <a1a34c32-dbd4-7a77-ab7e-5e34af85900f@linux.intel.com>

On Tue, Apr 18, 2023 at 12:29:40PM -0500, Dinh Nguyen wrote:
> On 4/17/2023 4:51 PM, Guenter Roeck wrote:
> > On 4/17/23 13:55, Dinh Nguyen wrote:

...

> > ... and this contradict each other. If bit 31 indicates an error,
> > this can not be a signed 32-bit value.
> > 
> You're right! I've re-read the spec and should have the the code look for
> the specific error values:
> 
> 0x80000000 - inactive
> 0x80000001 - old value
> 0x80000002 - invalid channel
> 0x80000003 -  corrupted.

No, they are not hex. Probably you need to define an error space with it, but
at least just use signed _decimal_ values.

Instead of BIT(31) this should go as

#define ..._ERR_BASE   INT_MIN // or equivalent if the type is not int
#define ..._ERR_MAX ... // or whatever name is better

Then in your code

	if (value >= _ERR_MAX)
		return 0;

	err = _ERR_MAX - value;
	switch (err) {
		...
	}

P.S. I asked during internal review if the values are bit fielded when errors.
AFAIU that time they are, now it seems different.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2023-04-19 11:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-10 15:33 [PATCH 1/5] units: add a macro for MILLIVOLT_PER_VOLT dinh.nguyen
2023-04-10 15:33 ` [PATCH 2/5] dt-bindings: hwmon: intel: add hardware monitor bindings for SoCFPGA dinh.nguyen
2023-04-10 23:48   ` Rob Herring
2023-04-11  6:53   ` Krzysztof Kozlowski
2023-04-10 15:33 ` [PATCH 3/5] hwmon: (socfpga) Add hardware monitoring support on SoCFPGA platforms dinh.nguyen
2023-04-11  2:44   ` Guenter Roeck
2023-04-17 20:55     ` Dinh Nguyen
2023-04-17 21:51       ` Guenter Roeck
2023-04-18 17:29         ` Dinh Nguyen
2023-04-19 11:46           ` Andy Shevchenko [this message]
2023-04-20 14:46             ` Dinh Nguyen
2023-04-21  9:36               ` Andy Shevchenko
2023-04-10 15:33 ` [PATCH 4/5] MAINTAINERS: add Dinh Nguyen for socfpga-hwmon driver dinh.nguyen
2023-04-10 15:33 ` [PATCH 5/5] arm64: dts: socfpga: add hwmon properties dinh.nguyen

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=ZD/UsuzhZmK3AFJn@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dinguyen@kernel.org \
    --cc=dinh.nguyen@linux.intel.com \
    --cc=jdelvare@suse.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=robh+dt@kernel.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;
as well as URLs for NNTP newsgroup(s).