From: sashiko-bot@kernel.org
To: hsyemail2@gmail.com
Cc: devicetree@vger.kernel.org, linux-hwmon@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v1 2/2] hwmon: (tmp401) Add support for Nuvoton NCT7719W
Date: Thu, 03 Dec 2026 09:08:51 +0000 [thread overview]
Message-ID: <sashiko-outbox-247426@kernel.org> (raw)
In-Reply-To: <20261203084635.5694-3-syhuang3@nuvoton.com>
Thank you for your contribution! Sashiko AI review found 6 potential
issues to consider:
- [Medium] hwmon: (tmp401) unguarded split byte reads in
tmp401_reg_read() for NCT7719W
- [Medium] hwmon: (tmp401) tmp401_detect() skips register checks for
NCT7719W
- [Low] hwmon: (tmp401) missing NCT7719W entry in SENSORS_TMP401 Kconfig
help text
- [Low] hwmon: (tmp401) nct7719w_set_convrate() floors update_interval
values
- [Low] hwmon: (tmp401) missing .data in tmp4xx_of_match for
nuvoton,nct7719w
- [Low] hwmon: (tmp401) tmp401_detect() truncates s32 SMBus errors into
u8 reg
--
commit f864dd6c74364eb055ac2dd4bb06ee2eab5a2c95
Author: Sheng-Yuan Huang <syhuang3@nuvoton.com>
hwmon: (tmp401) Add support for Nuvoton NCT7719W
This commit adds support for the Nuvoton NCT7719W temperature sensor to
the tmp401 driver and its documentation, using separate SMBus byte
accesses for remote temperatures and limits and signed temperature
conversion.
> diff --git a/Documentation/hwmon/tmp401.rst b/Documentation/hwmon/tmp401.rst
> index 3aacf3d3bdf33..35ca055be7cf8 100644
> --- a/Documentation/hwmon/tmp401.rst
> +++ b/Documentation/hwmon/tmp401.rst
> @@ -3,6 +3,12 @@ Kernel driver tmp401
>
> Supported chips:
>
> + * Nuvoton NCT7719W
> +
> + Prefix: 'nct7719w'
> +
> + Addresses scanned: I2C 0x4d
> +
[Severity: Low]
Should SENSORS_TMP401 in drivers/hwmon/Kconfig also be updated to list the
Nuvoton NCT7719W? Documentation/hwmon/submitting-patches.rst asks that
Kconfig stay in sync with the driver documentation when adding a new chip.
[ ... ]
> diff --git a/drivers/hwmon/tmp401.c b/drivers/hwmon/tmp401.c
> index 83aafe4bd3e72..745494acae0f2 100644
> --- a/drivers/hwmon/tmp401.c
> +++ b/drivers/hwmon/tmp401.c
[ ... ]
> @@ -143,6 +147,55 @@ static int tmp401_reg_read(void *context, unsigned int reg, unsigned int *val)
> struct tmp401_data *data = context;
> struct i2c_client *client = data->client;
> int regval;
> + int low_reg;
> + int low_val;
> +
> + /* NCT7719W remote values and limits require separate byte accesses. */
> + if (data->kind == nct7719w) {
[ ... ]
> + if (low_reg) {
> + regval = i2c_smbus_read_byte_data(client, reg);
> + if (regval < 0)
> + return regval;
> + low_val = i2c_smbus_read_byte_data(client, low_reg);
> + if (low_val < 0)
> + return low_val;
> + *val = (regval << 8) | (low_val & GENMASK(7, 5));
> + return 0;
> + }
> + }
[Severity: Medium]
Can reading the remote temperature high and low bytes (0x01/0x10 and
0x23/0x24) in two separate SMBus byte transactions return a torn value if
an ADC conversion completes between them?
If the NCT7719W does not latch the low byte on a high-byte read, an
integer rollover between the two reads can skew readings by up to 0.875 C
for sysfs and thermal zone consumers. Re-reading the high byte (and low
byte if it changed), as lm90_read16() does, avoids tearing either way.
[ ... ]
> @@ -409,6 +540,19 @@ static int tmp401_chip_read(struct device *dev, u32 attr, int channel, long *val
> return 0;
> }
>
> +static int nct7719w_set_convrate(struct regmap *regmap, long val)
> +{
> + int rate;
> + int interval;
> +
> + val = clamp_val(val, 63, 16000);
> + interval = 16000;
> + for (rate = 0; rate < 8 && val < interval; rate++)
> + interval /= 2;
> +
> + return regmap_write(regmap, TMP401_CONVERSION_RATE, rate);
> +}
[Severity: Low]
Does nct7719w_set_convrate() floor non-exact update_interval values
instead of rounding to the nearest supported rate?
Comparing val < interval rather than the midpoint means writing 15999 ms
selects 8000 ms (or 124 ms selects 63 ms), doubling the sampling rate
compared to tmp401_set_convrate() right below it.
[ ... ]
> @@ -605,6 +755,15 @@ static int tmp401_detect(struct i2c_client *client,
>
> /* Detect and identify the chip */
> reg = i2c_smbus_read_byte_data(client, TMP401_MANUFACTURER_ID_REG);
> + if (reg == NCT7719W_MANUFACTURER_ID) {
> + if (client->addr != 0x4d)
> + return -ENODEV;
> + reg = i2c_smbus_read_byte_data(client, TMP401_DEVICE_ID_REG);
> + if ((reg & NCT7719W_DEVICE_ID_MASK) != NCT7719W_DEVICE_ID)
> + return -ENODEV;
[Severity: Low]
Can truncating the signed return value of i2c_smbus_read_byte_data() into
u8 reg cause a false positive on an SMBus error?
On PA-RISC, -ETIMEDOUT (-238) truncates to 0x12, so a timeout reading
TMP401_DEVICE_ID_REG matches NCT7719W_DEVICE_ID and probes nct7719w. The
same u8 reg lets -ERESTARTSYS (0x00) bypass the TI checks below; making
reg an int and checking reg < 0 fixes both paths.
> + strscpy(info->type, "nct7719w", I2C_NAME_SIZE);
> + return 0;
> + }
[Severity: Medium]
Is matching only 12 ID bits at address 0x4d enough to detect the NCT7719W
reliably without checking any other registers?
Unlike the TI path below (and lm90_detect_nuvoton()), this skips checking
TMP401_CONVERSION_RATE (0..8), reserved TMP401_CONFIG bits, or unused LSB
and hysteresis bits. A false positive on an I2C_CLASS_HWMON bus causes
tmp401_init_client() to write to an unrelated chip at 0x4d.
[ ... ]
> @@ -741,6 +903,7 @@ static const struct of_device_id __maybe_unused tmp4xx_of_match[] = {
> { .compatible = "ti,tmp431", },
> { .compatible = "ti,tmp432", },
> { .compatible = "ti,tmp435", },
> + { .compatible = "nuvoton,nct7719w", },
> { },
> };
[Severity: Low]
Should this entry set .data = (void *)nct7719w instead of relying on the
i2c_match_id() fallback?
With .data omitted, i2c_get_match_data() falls back to case-sensitive
matching on client->name from index 0 of the compatible list. If a DT or
ACPI PRP0001 table puts a more specific compatible first with
nuvoton,nct7719w as a fallback, i2c_match_id() returns NULL.
tmp401_probe() then silently sets data->kind to tmp401, issuing
unsupported SMBus word accesses and misdecoding temperatures.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203084635.5694-1-syhuang3@nuvoton.com?part=2
prev parent reply other threads:[~2026-12-03 9:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 8:46 [PATCH v1 0/2] hwmon: (tmp401) Add support for Nuvoton NCT7719W hsyemail2
2026-12-03 8:46 ` [PATCH v1 1/2] dt-bindings: hwmon: tmp401: Add " hsyemail2
2026-12-03 8:57 ` sashiko-bot
2026-12-03 8:46 ` [PATCH v1 2/2] hwmon: (tmp401) Add support for " hsyemail2
2026-12-03 9:08 ` sashiko-bot [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=sashiko-outbox-247426@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=hsyemail2@gmail.com \
--cc=linux-hwmon@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox