public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Salih Erim <salih.erim@amd.com>
Cc: jic23@kernel.org, robh@kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org, git@amd.com, nuno.sa@analog.com,
	andy@kernel.org, dlechner@baylibre.com, michal.simek@amd.com,
	conall.ogriofa@amd.com, erimsalih@gmail.com,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/5] iio: adc: add Versal SysMon driver
Date: Tue, 5 May 2026 10:12:44 +0300	[thread overview]
Message-ID: <afmYbF8sLXugL-EE@ashevche-desk.local> (raw)
In-Reply-To: <8d0ed33d-deab-4aa3-a7bf-3aaf84f4583f@amd.com>

On Mon, May 04, 2026 at 04:50:05PM +0100, Salih Erim wrote:

> On 5/4/2026 11:18 AM, Andy Shevchenko wrote:
> > On Sat, May 02, 2026 at 12:19:48PM +0100, Salih Erim wrote:

...

> > > +     if (format)
> > > +             mantissa = (int)(s16)mantissa;
> > 
> > Potential user of FIELD_GET_SIGNED(), but for now just use explicit call to
> > sign_extend32().
> 
> Accepted. Will use sign_extend32(mantissa, 15).
> 
> > > +     *val = (mantissa * SYSMON_MILLI) >> exponent;

The idea is to think about this (and other) user and try to come up with the
solution that will not decrease readability and at the same time give more
context. Perhaps you need an additional patch that introduces the multiplier
for millivolts (as it's done for degrees).

...

> > > +/* Signed milli scale (MILLI from linux/units.h is unsigned long) */
> > > +#define SYSMON_MILLI                 1000
> > 
> > I think you want a different approach. I already forgot how it's being used,
> > but there shouldn't be a new (re-)definition just because of this.
> 
> The issue is that MILLI from units.h is 1000UL, which causes unsigned
> promotion when multiplied with signed int values (e.g. negative
> temperatures or two's complement mantissa). There is
> MILLIDEGREE_PER_DEGREE (signed 1000) but using it for voltage
> channel conversions would be semantically wrong. Will either use
> (int)MILLI at the call sites or just use literal 1000 -- happy to
> go with whichever you prefer.

Let's wait for resolution WRT hwmon vs. IIO.


-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-05-05  7:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-02 11:19 [PATCH v2 0/5] iio: adc: add AMD/Xilinx Versal SysMon driver Salih Erim
2026-05-02 11:19 ` [PATCH v2 1/5] dt-bindings: iio: adc: add xlnx,versal-sysmon binding Salih Erim
2026-05-03 14:20   ` Krzysztof Kozlowski
2026-05-03 22:52     ` Salih Erim
2026-05-02 11:19 ` [PATCH v2 2/5] iio: adc: add Versal SysMon driver Salih Erim
2026-05-04 10:18   ` Andy Shevchenko
2026-05-04 15:50     ` Salih Erim
2026-05-05  7:12       ` Andy Shevchenko [this message]
2026-05-04 17:32   ` Jonathan Cameron
2026-05-04 19:26     ` Guenter Roeck
2026-05-02 11:19 ` [PATCH v2 3/5] iio: adc: versal-sysmon: add I2C driver Salih Erim
2026-05-04 10:25   ` Andy Shevchenko
2026-05-02 11:19 ` [PATCH v2 4/5] iio: adc: versal-sysmon: add threshold event support Salih Erim
2026-05-04 10:52   ` Andy Shevchenko
2026-05-04 17:44   ` Jonathan Cameron
2026-05-02 11:19 ` [PATCH v2 5/5] iio: adc: versal-sysmon: add oversampling support Salih Erim

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=afmYbF8sLXugL-EE@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=conall.ogriofa@amd.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=erimsalih@gmail.com \
    --cc=git@amd.com \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=nuno.sa@analog.com \
    --cc=robh@kernel.org \
    --cc=salih.erim@amd.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