public inbox for linux-doc@vger.kernel.org
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: nuno.sa@analog.com, linux-hwmon@vger.kernel.org,
	linux-gpio@vger.kernel.org, 	devicetree@vger.kernel.org,
	linux-doc@vger.kernel.org,
	Krzysztof Kozlowski	 <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Jean Delvare	 <jdelvare@suse.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Linus Walleij	 <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	"Rob Herring (Arm)"	 <robh@kernel.org>,
	Linus Walleij <linusw@kernel.org>,
	Bartosz Golaszewski	 <brgl@kernel.org>
Subject: Re: [PATCH v5 0/3] hwmon: Add support for the LTC4283 Hot Swap Controller
Date: Mon, 02 Feb 2026 09:40:18 +0000	[thread overview]
Message-ID: <0f6c51ed27643a7fc94df0a40c476326cfeb0043.camel@gmail.com> (raw)
In-Reply-To: <e2208717-0f47-48d6-9cf2-20196e13a3d0@roeck-us.net>

On Wed, 2026-01-28 at 10:22 -0800, Guenter Roeck wrote:
> On Wed, Jan 28, 2026 at 06:07:24PM +0000, Nuno Sá wrote:
> > > [ ... ]
> > > 
> > > > +static int ltc4283_read_power_word(const struct ltc4283_hwmon *st,
> > > > +				   u32 reg, long *val)
> > > > +{
> > > > +	u64 temp = (u64)LTC4283_ADC1_FS_uV * LTC4283_ADC2_FS_mV * DECA * MILLI;
> > > > +	unsigned int __raw;
> > > > +	int ret;
> > > > +
> > > > +	ret = regmap_read(st->map_word, reg, &__raw);
> > > > +	if (ret)
> > > > +		return ret;
> > > > +
> > > > +	/*
> > > > +	 * Power is given by:
> > > > +	 *     P = CODE(16b) * 32.768mV * 2.048V / (2^16 * Rsense)
> > > > +	 */
> > > > +	*val = DIV64_U64_ROUND_CLOSEST(temp * __raw, BIT_ULL(16) * st->rsense);
> > > 
> > > Does this overflow *val on 32-bit systems if the calculated power exceeds
> > > 2000 Watts (approx 2^31 microWatts)?  The intermediate calculation is
> > > u64, but the result is assigned to a signed long.
> > > 
> > 
> > I'll have to double check this one but IIRC 2000W is not a realistic value for
> > these applications. One thing that could overflow is power_max given that the default
> > register value is 0xff but we do write the proper max value depending on
> > rsense (I actually need to check how will this behave in case we use a default
> > rsense value - ie with no DT property).
> > 
> 
> I have been wondering if I should introduce a hwmon_power64 sensor type, similar to
> hwmon_energy64. WDYT ?
> 

No strong opinion. As I said, not sure if it's needed here but OTOH given that power is
microWatts I guess it's a matter of time. Anyways, if you do it, I might as well just play safe
and use it in here (and ltc4282 should also be converted - likely).

- Nuno Sá

      reply	other threads:[~2026-02-02  9:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-23 12:21 [PATCH v5 0/3] hwmon: Add support for the LTC4283 Hot Swap Controller Nuno Sá via B4 Relay
2025-12-23 12:21 ` [PATCH v5 1/3] dt-bindings: hwmon: Document the LTC4283 " Nuno Sá via B4 Relay
2025-12-23 12:21 ` [PATCH v5 2/3] hwmon: ltc4283: Add support for " Nuno Sá via B4 Relay
2025-12-23 12:21 ` [PATCH v5 3/3] gpio: gpio-ltc4283: " Nuno Sá via B4 Relay
2026-01-18  0:27 ` [PATCH v5 0/3] hwmon: Add support for the LTC4283 Hot " Guenter Roeck
2026-01-18 10:12   ` Nuno Sá
2026-01-18 15:39     ` Guenter Roeck
2026-02-17 13:39   ` Nuno Sá
2026-02-21  1:17     ` Guenter Roeck
2026-01-27 17:39 ` Guenter Roeck
2026-01-28  9:44   ` Nuno Sá
2026-01-28 10:04     ` Guenter Roeck
2026-01-28 16:55       ` Guenter Roeck
2026-01-28 18:07         ` Nuno Sá
2026-01-28 18:22           ` Guenter Roeck
2026-02-02  9:40             ` Nuno Sá [this message]

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=0f6c51ed27643a7fc94df0a40c476326cfeb0043.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=brgl@bgdev.pl \
    --cc=brgl@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=jdelvare@suse.com \
    --cc=krzk+dt@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linusw@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=nuno.sa@analog.com \
    --cc=robh@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