From: sashiko-bot@kernel.org
To: "Markus Stockhausen" <markus.stockhausen@gmx.de>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v3 2/2] hwmon: (lm75) Fix configuration register writes.
Date: Sat, 02 May 2026 18:19:42 +0000 [thread overview]
Message-ID: <20260502181943.1857CC19425@smtp.kernel.org> (raw)
In-Reply-To: <20260502173207.3567876-3-markus.stockhausen@gmx.de>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Applying this fix without correcting the 16-bit sensor masks causes `tmp112` and `as6200` to be severely misconfigured during probe.
--
commit 0da1c5266106ec86191304203df47a352a002b92
Author: Markus Stockhausen <markus.stockhausen@gmx.de>
hwmon: (lm75) Fix configuration register writes.
This commit fixes a bug in lm75_write_config() where set mask bits not
defined in the clear mask were being dropped. It ensures both masks are
properly combined for the regmap update.
> diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
> index 7efcef7768cd..8b74cc314196 100644
> --- a/drivers/hwmon/lm75.c
> +++ b/drivers/hwmon/lm75.c
> @@ -353,7 +353,7 @@ static inline int lm75_write_config(struct lm75_data *data, u16 set_mask,
> u16 clr_mask)
> {
> return regmap_update_bits(data->regmap, LM75_REG_CONF,
> - clr_mask | LM75_SHUTDOWN, set_mask);
> + clr_mask | set_mask | LM75_SHUTDOWN, set_mask);
Will applying this fix without correcting the 16-bit sensor masks cause
sensors like tmp112 and as6200 to be misconfigured during probe?
I2C temperature sensors transmit and receive the MSB first, but
i2c_smbus_read_word_data() and i2c_smbus_write_word_data() read and write the
LSB first. This causes the driver's memory representation of the configuration
register to be byte-swapped, with the sensor's physical MSB in the lower 8
bits and the physical LSB in the upper 8 bits.
The set_mask for tmp112 (0x60C0) and as6200 (0x10C0) are defined assuming
native byte order. Prior to this patch, the logical bug in
lm75_write_config() silently dropped the set_mask bits because they were not
in clr_mask, leaving the sensors at their power-on defaults.
By fixing the helper, 0x60C0 is actively written to the byte-swapped register
value. Due to the byte-swap, the 0xC0 byte is applied to the lower 8 bits
(sensor MSB) and 0x60 to the upper 8 bits (sensor LSB).
For tmp112, the device receives 0xC0 as its MSB and 0x60 as its LSB. Does
this configure the sensor to 11-bit resolution and 1 Hz sample rate instead
of the intended 12-bit, 8 Hz configuration?
Could the endianness of the masks for 16-bit devices be fixed simultaneously
to avoid this regression?
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260502173207.3567876-1-markus.stockhausen@gmx.de?part=2
prev parent reply other threads:[~2026-05-02 18:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-02 17:32 [PATCH v3 0/2] hwmon: (lm75) Fix AS6200 and config register handling Markus Stockhausen
2026-05-02 17:32 ` [PATCH v3 1/2] hwmon: (lm75) Fix AS6200 setup and alarm handling Markus Stockhausen
2026-05-02 17:58 ` sashiko-bot
2026-05-02 18:13 ` Guenter Roeck
2026-05-02 17:32 ` [PATCH v3 2/2] hwmon: (lm75) Fix configuration register writes Markus Stockhausen
2026-05-02 18:14 ` Guenter Roeck
2026-05-02 18:19 ` 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=20260502181943.1857CC19425@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=markus.stockhausen@gmx.de \
--cc=sashiko@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