mirror of https://lore.kernel.org/lkml/
 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: Fri, 21 Apr 2023 12:36:19 +0300	[thread overview]
Message-ID: <ZEJZE5bxyXsrAZPJ@smile.fi.intel.com> (raw)
In-Reply-To: <f6e4a78d-0199-3135-f85d-800457a731b0@linux.intel.com>

On Thu, Apr 20, 2023 at 09:46:20AM -0500, Dinh Nguyen wrote:
> On 4/19/2023 6:46 AM, Andy Shevchenko wrote:
> > 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.
> 
> Can I ask what's wrong with this simple implementation?

Technically, nothing, but from understanding point of view it would be better
to have explicit ranges of error number space vs. actual value space.

The idea in the firmware of that device seems to me similar to what we have in
the Linux kernel. Note, it may be not _so_ explicitly, but the error number
space is limited by a PAGE_SIZE. All the same may be applied here.

> static int socfpga_hwmon_err_to_errno(struct socfpga_hwmon_priv *priv)
> {
>         int value = priv->temperature.value;
> 
>         switch (value) {
>         case ETEMP_NOT_PRESENT:
>                 return -ENOENT;
>         case ETEMP_CORRUPT:
>         case ETEMP_NOT_INITIALIZED:
>                 return -ENODATA;
>         case ETEMP_BUSY:
>                 return -EBUSY;
>         case ETEMP_INACTIVE:
>         case ETEMP_TIMEOUT:
>         case ETEMP_TOO_OLD:
>                 return -EAGAIN;
>         default:
>                 /* No error */
>                 return 0;
>         }
> }

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2023-04-21  9:36 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
2023-04-20 14:46             ` Dinh Nguyen
2023-04-21  9:36               ` Andy Shevchenko [this message]
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=ZEJZE5bxyXsrAZPJ@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

all inboxes | Powered by JetHome®