From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796288932; b=YkHbQ7vGux0dXVeAQ0397SBnVs/MeoJf3piBSwIuVsapqnf6tF2PeBVP0NiX5Ia9pqot Cr+qt+hEFLkWmODahv9kmwP/gvD1qpOH9TGTqQZ5wJQdySsMXH4KeyMMgB5wcy3t13O+2 aejchfNxpSZS3O5bQoH+4cVelUed5h4HFM3jsF8/pMZhv6d7Akj2tzZ61i3yYyj+AOxLb QR6I+E/AO0DCEnjD5OFUAPtc/tRQpJ2lX44u48LqDnf1zFTI47SUeqbzeeo8b9OsUclOD DtVEkv3L7aYM+FHIPJ4WpaKhX7DNorUiptnnErXAnzJKl9Yn7d9XCrXGVL+4d2M56EQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796288932; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=7e/kY1gljUNyutj6Myn0Q4hqiTZT/L379d7U9hqn3uE=; b=GLP+pavPIA1hyt0YjjRT84hTcmNjrZgKRIwDtWlAlwH1uzLaz8ilTMmCp07lWQo3QSKE 4/SIZEHiDLWSXguCsqhuX1V+oC9bcx2oRMYUmQf1aEEzOSb5phsl+XZrhR5HxVt7wIfai QGDxrNGYdpO2kcHpaIpPcSbW/L9MMBq5d+V2PwoK9v6C4vT1p5Bm8d3S2gm6QcL4+vfmU GnJ1ff+LQL7IZ2hazfhrvn1slwqNIH+i1tC424TWZYcDH/YHnkokGbtePtSs7klI7o3YV 5Hu56PvixTMSrgDQyu7lNY9DiXQwaZ90l/64zczx69odxjLCUb1i7mie7KDB3/E0xhA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VJFdOQHA; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6EE05606A32C; Thu, 3 Dec 2026 09:08:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=VJFdOQHA Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2236A1F000C1; Thu, 3 Dec 2026 09:08:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796288932; bh=7e/kY1gljUNyutj6Myn0Q4hqiTZT/L379d7U9hqn3uE=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=VJFdOQHAqJvz+wTcUqOO7jGfDOnP56mMAtJ1+Rtv2XcC8YIA3WNgT4cQdmdbN3Rrf 1O8k69/KqtiuosJgeSIVL5rvwONhHRx+8gyYUePdkarDHUyGANOddd96/KtUP273o5 Sd+Zf7fdyjhSJfsCbBTtbV2/3dIlEqihQz/gfcutuX97koXBA19Pk/WGcjS4t9YreN LbfEdzlNmR2uyU4sOqhzkJ6zoMnmRVs//P+B+5i+BOm3aGnfiXRsNw5vG3G83uSok/ ycow7PcsJ3l7WUh9VPOLuQC+1r8PczMXQ4aKcmQkPt04B8I8iyu/Wej4O2GBaFWfcM xtJYTidW+S2hQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v1 2/2] hwmon: (tmp401) Add support for Nuvoton NCT7719W Reply-To: sashiko-reviews@lists.linux.dev To: hsyemail2@gmail.com Cc: devicetree@vger.kernel.org, linux-hwmon@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261203084635.5694-3-syhuang3@nuvoton.com> References: <20261203084635.5694-1-syhuang3@nuvoton.com> <20261203084635.5694-3-syhuang3@nuvoton.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 09:08:51 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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 > =20 > Supported chips: > =20 > + * 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 i= nt reg, unsigned int *val) > struct tmp401_data *data =3D context; > struct i2c_client *client =3D data->client; > int regval; > + int low_reg; > + int low_val; > + > + /* NCT7719W remote values and limits require separate byte accesses. */ > + if (data->kind =3D=3D nct7719w) { [ ... ] > + if (low_reg) { > + regval =3D i2c_smbus_read_byte_data(client, reg); > + if (regval < 0) > + return regval; > + low_val =3D i2c_smbus_read_byte_data(client, low_reg); > + if (low_val < 0) > + return low_val; > + *val =3D (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; > } > =20 > +static int nct7719w_set_convrate(struct regmap *regmap, long val) > +{ > + int rate; > + int interval; > + > + val =3D clamp_val(val, 63, 16000); > + interval =3D 16000; > + for (rate =3D 0; rate < 8 && val < interval; rate++) > + interval /=3D 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, > =20 > /* Detect and identify the chip */ > reg =3D i2c_smbus_read_byte_data(client, TMP401_MANUFACTURER_ID_REG); > + if (reg =3D=3D NCT7719W_MANUFACTURER_ID) { > + if (client->addr !=3D 0x4d) > + return -ENODEV; > + reg =3D i2c_smbus_read_byte_data(client, TMP401_DEVICE_ID_REG); > + if ((reg & NCT7719W_DEVICE_ID_MASK) !=3D 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 tmp4x= x_of_match[] =3D { > { .compatible =3D "ti,tmp431", }, > { .compatible =3D "ti,tmp432", }, > { .compatible =3D "ti,tmp435", }, > + { .compatible =3D "nuvoton,nct7719w", }, > { }, > }; [Severity: Low] Should this entry set .data =3D (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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203084635.5694= -1-syhuang3@nuvoton.com?part=3D2