mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Carsten Spieß" <mail@carsten-spiess.de>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Jean Delvare <jdelvare@suse.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Magnus Damm <magnus.damm@gmail.com>,
	linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH 1/2] hwmon: (isl28022) new driver for ISL28022 power monitor
Date: Thu, 27 Jul 2023 17:28:42 +0200	[thread overview]
Message-ID: <20230727172842.3fe20026.mail@carsten-spiess.de> (raw)
In-Reply-To: <bbf1aba4-48ce-289d-aaa9-bc861effaffd@roeck-us.net>

[-- Attachment #1: Type: text/plain, Size: 923 bytes --]


> On 7/26/23 18:19, Guenter Roeck wrote:
> I strongly suspect that the conversions will result in overflows and that they are not always correct.
> I'll want to write unit test code before accepting the driver.
I changed the conversion for current to 
				*val = ((long)regval * 1250L * (long)data->gain) /
					(long)data->shunt;

The term (1250 * gain) will be 10000 max, fits to 14 bit.
So no risk for 32bit overflow when multiply with 16bit value.

And changed the conversion for power to 
				*val = ((51200000L * ((long)data->gain)) /
					(long)data->shunt) * (long)regval;

The first term (51200000 * gain / shunt) will be larger than 16bit when 
(shunt/gain) is less than ~800. So min values for shunt are 
- 6400 µOhm for 320 mV range
- 3200 µOhm for 160 mV range
- 1600 µOhm for 80 mV range
- 800 µOhm for 40 mV range
Can i set this conditionally in the .yaml file?

Regards Carsten

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2023-07-27 15:29 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230726152235.249569-1-mail@carsten-spiess.de>
2023-07-26 15:22 ` Carsten Spieß
2023-07-26 16:14   ` Guenter Roeck
2023-07-27  7:35     ` Carsten Spieß
2023-07-27 14:30       ` Guenter Roeck
2023-07-27 15:13         ` Carsten Spieß
2023-07-26 16:19   ` Guenter Roeck
2023-07-27  7:35     ` Carsten Spieß
2023-07-27 15:28     ` Carsten Spieß [this message]
2023-07-26 20:16   ` Randy Dunlap
2023-07-26 15:22 ` [PATCH 2/2] dt-bindings: hwmon: add renesas,isl28022 Carsten Spieß
2023-07-26 16:14   ` Krzysztof Kozlowski
2023-07-26 16:19     ` Krzysztof Kozlowski
2023-07-26 18:19     ` Guenter Roeck
2023-07-26 18:27       ` Krzysztof Kozlowski
2023-07-26 18:59         ` Guenter Roeck
2023-07-26 19:05           ` Krzysztof Kozlowski
2023-07-26 16:16   ` Guenter Roeck
2023-07-27  7:35     ` Carsten Spieß
2023-07-27  8:07       ` Conor Dooley
2023-07-27  8:25       ` Krzysztof Kozlowski
2023-07-27  9:30         ` Carsten Spieß
2023-07-27 13:55       ` Guenter Roeck
2023-07-26 17:13   ` Rob Herring
     [not found] <20230727194813.2245116-1-mail@carsten-spiess.de>
2023-07-27 19:48 ` [PATCH 1/2] hwmon: (isl28022) new driver for ISL28022 power monitor Carsten Spieß

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=20230727172842.3fe20026.mail@carsten-spiess.de \
    --to=mail@carsten-spiess.de \
    --cc=corbet@lwn.net \
    --cc=geert+renesas@glider.be \
    --cc=jdelvare@suse.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=magnus.damm@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®