All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Matti Vaittinen" <matti.vaittinen@linux.dev>
Cc: linux-hwmon@vger.kernel.org, robh@kernel.org,
	conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 9/9] hwmon: adm1275: Support ROHM BD12790
Date: Fri, 26 Jun 2026 07:33:47 +0000	[thread overview]
Message-ID: <20260626073347.A06981F000E9@smtp.kernel.org> (raw)
In-Reply-To: <b209c1b47712b69f17b52cfd7a7a38ed76024ca7.1782458224.git.mazziesaccount@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The mathematical formula documented in the comment for computing the power coefficient contradicts the actual mathematically correct implementation in the code.
--

commit 7dff114234776369f1046124af65696c292fcd41
Author: Matti Vaittinen <mazziesaccount@gmail.com>

hwmon: adm1275: Support ROHM BD12790

This commit adds support for the ROHM BD12790 hot-swap controller to the
adm1275 driver. It introduces a dedicated coefficient table for the new
device based on its voltage and current-sense ranges.

> diff --git a/drivers/hwmon/pmbus/adm1275.c b/drivers/hwmon/pmbus/adm1275.c
> index 81c50fab7687b..406b448523769 100644
> --- a/drivers/hwmon/pmbus/adm1275.c
> +++ b/drivers/hwmon/pmbus/adm1275.c

[ ... ]

> @@ -136,6 +136,30 @@ static const struct coefficients adm1272_coefficients[] = {
>  
>  };
>  
> +/*
> + * BD12790 coefficients derived from preliminary datasheet, Table 1 (p.18)
> + * and the PMBus direct-format relationship X = (Y * 10^(-R) - b) / m.
> + *
> + * Voltage: V[V] = 14.77e-3 * code (60V) / 24.62e-3 * code (100V)
> + *   -> m = 6770, R=-2 / m = 4062, R=-2
> + * Current: code = I[A] * RS * 132802.1 + 2048 (15mV) / * 66401.06 + 2048 (30mV)
> + *   -> m = 1328, b = 2048 * 10^(-R) = 20480, R=-1 / m = 664, same b and R
> + * Power: code = k * RS * PIN, k = 35119.94 / 17559.97 / 21071.44 / 10535.72
> + *   -> m = round(k / 10^(-3-R)), R=-2 for 60V/15mV, R=-3 for the other three

[Severity: Low]
This isn't a bug, but does the formula in this comment correctly document
how the power coefficients are calculated?

If we evaluate m = round(k / 10^(-3-R)) for a value of R=-2 and k=35119.94,
it yields 351199.4. However, the actual code below correctly implements the
value as 3512, which implies the formula should use multiplication rather
than division.

> + * Temperature: code = 4.2 * T + 3188 -> m = 42, b = 3188 * 10 = 31880, R=-1
> + */
> +static const struct coefficients bd12790_coefficients[] = {
> +	[0] = { 6770, 0, -2 },		/* voltage, vrange 60V */
> +	[1] = { 4062, 0, -2 },		/* voltage, vrange 100V */
> +	[2] = { 1328, 20480, -1 },	/* current, vsense range 15mV */
> +	[3] = { 664, 20480, -1 },	/* current, vsense range 30mV */
> +	[4] = { 3512, 0, -2 },		/* power, vrange 60V, irange 15mV */
> +	[5] = { 21071, 0, -3 },		/* power, vrange 100V, irange 15mV */
> +	[6] = { 17560, 0, -3 },		/* power, vrange 60V, irange 30mV */
> +	[7] = { 10536, 0, -3 },		/* power, vrange 100V, irange 30mV */
> +	[8] = { 42, 31880, -1 },	/* temperature */
> +};
> +

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1782458224.git.mazziesaccount@gmail.com?part=9

  reply	other threads:[~2026-06-26  7:33 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26  7:21 [PATCH v2 0/9] Support ROHM BD127x0 hot-swap controllers Matti Vaittinen
2026-06-26  7:21 ` [PATCH v2 1/9] dt-bindings: adm1275: ROHM BD12780 hot-swap controller Matti Vaittinen
2026-06-26  7:31   ` sashiko-bot
2026-06-26 15:58   ` Conor Dooley
2026-06-26  7:22 ` [PATCH v2 2/9] hwmon: adm1275: Prevent reading uninitialized stack Matti Vaittinen
2026-06-26  7:32   ` sashiko-bot
2026-06-26  7:23 ` [PATCH v2 3/9] hwmon: adm1275: Detect coefficient overflow Matti Vaittinen
2026-06-26  7:35   ` sashiko-bot
2026-06-26  7:24 ` [PATCH v2 4/9] hwmon: adm1275: Support module auto-loading Matti Vaittinen
2026-06-26  7:31   ` sashiko-bot
2026-06-26  7:24 ` [PATCH v2 5/9] doc: Add ROHM BD12780 and BD12780A Matti Vaittinen
2026-06-26  7:36   ` sashiko-bot
2026-06-26  7:24 ` [PATCH v2 6/9] hwmon: adm1275: Support ROHM BD12780 Matti Vaittinen
2026-06-26  7:32   ` sashiko-bot
2026-06-26  7:25 ` [PATCH v2 7/9] dt-bindings: adm1275: ROHM BD12790 hot-swap controller Matti Vaittinen
2026-06-26  7:35   ` sashiko-bot
2026-06-26  7:25 ` [PATCH v2 8/9] doc: adm1275: Add ROHM BD12790 Matti Vaittinen
2026-06-26  7:32   ` sashiko-bot
2026-06-26  7:26 ` [PATCH v2 9/9] hwmon: adm1275: Support " Matti Vaittinen
2026-06-26  7:33   ` sashiko-bot [this message]
2026-06-26  7:49     ` Matti Vaittinen

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=20260626073347.A06981F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=matti.vaittinen@linux.dev \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.