From: sashiko-bot@kernel.org
To: "Markus Stockhausen" <markus.stockhausen@gmx.de>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH 2/2] hwmon: (lm75) Support active-high alert polarity
Date: Fri, 01 May 2026 12:45:39 +0000 [thread overview]
Message-ID: <20260501124540.0C11CC2BCB4@smtp.kernel.org> (raw)
In-Reply-To: <20260501120518.3085501-3-markus.stockhausen@gmx.de>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The active-high alert polarity configuration is completely ignored by the hardware because it is not added to the register update mask.
- [High] LM75_ALERT_POLARITY_HIGH_16_BIT targets the wrong byte of the configuration register.
- [High] Changing the AS6200 default from active-high to active-low breaks devicetree backward compatibility.
--
commit bf60f0ac922f126e93d4f54ae47d4c76d1c9caa9
Author: Markus Stockhausen <markus.stockhausen@gmx.de>
hwmon: (lm75) Support active-high alert polarity
This commit adds support for configuring active-high alert polarity based
on the devicetree property for LM75-compatible devices. It also adjusts
the default configuration value for the AS6200 to be active-low for
consistency.
> diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
> index f1a1e5b888f64..4b075a7b1cd76 100644
> --- a/drivers/hwmon/lm75.c
> +++ b/drivers/hwmon/lm75.c
> @@ -123,7 +123,9 @@ struct lm75_data {
>
> static const u8 lm75_sample_set_masks[] = { 0 << 5, 1 << 5, 2 << 5, 3 << 5 };
>
> -#define LM75_SAMPLE_CLEAR_MASK (3 << 5)
> +#define LM75_ALERT_POLARITY_HIGH_8_BIT (BIT(2))
> +#define LM75_ALERT_POLARITY_HIGH_16_BIT (BIT(2) << 8)
Should the 16-bit mask also use BIT(2)?
Since 16-bit configuration register accesses use i2c_smbus_read_word_data()
and i2c_smbus_write_word_data() which process the LSB first, the standard
LM75 configuration byte maps to the LSB (bits 0-7) of the 16-bit word. Using
BIT(2) << 8 seems to target the MSB instead.
> +#define LM75_SAMPLE_CLEAR_MASK (3 << 5)
>
> /* The structure below stores the configuration values of the supported devices.
> * In case of being supported multiple configurations, the default one must
> @@ -137,7 +139,7 @@ static const struct lm75_params device_params[] = {
> },
> [as6200] = {
> .config_reg_16bits = true,
> - .set_mask = 0x94C0, /* 8 sample/s, 4 CF, positive polarity */
> + .set_mask = 0x90C0, /* 8 sample/s, 4 CF */
Does changing this default mask break backward compatibility for existing
devicetrees using the AS6200?
Systems currently using this chip might lack the newly introduced
lm75,alert-polarity-active-high property and rely on the previous
active-high default to route alarms correctly.
[ ... ]
> @@ -762,8 +765,15 @@ static int lm75_generic_probe(struct device *dev, const char *name,
> return err;
> data->orig_conf = status;
>
> - err = lm75_write_config(data, data->params->set_mask,
> - data->params->clr_mask);
> + set_mask = data->params->set_mask;
> + if (of_property_read_bool(dev->of_node, "lm75,alert-polarity-active-high")) {
> + if (!data->params->config_reg_16bits)
> + set_mask |= LM75_ALERT_POLARITY_HIGH_8_BIT;
> + else
> + set_mask |= LM75_ALERT_POLARITY_HIGH_16_BIT;
> + }
> +
> + err = lm75_write_config(data, set_mask, data->params->clr_mask);
Will the new polarity bits added to set_mask be ignored by the hardware?
Looking at lm75_write_config(), the clr_mask is passed as the mask argument
to regmap_update_bits():
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);
}
Because clr_mask is not updated to include the polarity bits,
regmap_update_bits() won't modify them in the hardware register.
Would it also be safer to explicitly include the polarity bit in the
clr_mask so the hardware is deterministically reset from whatever state
the bootloader left it in?
> if (err)
> return err;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260501120518.3085501-1-markus.stockhausen@gmx.de?part=2
next prev parent reply other threads:[~2026-05-01 12:45 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-01 12:05 [PATCH 0/2] Support active-high alert polarity for LM75 Markus Stockhausen
2026-05-01 12:05 ` [PATCH 1/2] dt-bindings: hwmon: lm75: Add lm75,alert-polarity-active-high property Markus Stockhausen
2026-05-01 12:24 ` sashiko-bot
2026-05-02 17:37 ` AW: " markus.stockhausen
2026-05-02 18:10 ` Guenter Roeck
2026-05-03 18:02 ` Conor Dooley
2026-05-01 12:05 ` [PATCH 2/2] hwmon: (lm75) Support active-high alert polarity Markus Stockhausen
2026-05-01 12:45 ` sashiko-bot [this message]
2026-05-01 14:06 ` AW: " markus.stockhausen
2026-05-01 17:37 ` Guenter Roeck
2026-05-01 19:00 ` AW: " markus.stockhausen
2026-05-01 19:24 ` Guenter Roeck
2026-05-01 20:14 ` Guenter Roeck
2026-05-01 20:42 ` AW: " markus.stockhausen
2026-05-01 21:19 ` Guenter Roeck
2026-05-01 17:05 ` Conor Dooley
2026-05-01 19:32 ` Guenter Roeck
2026-05-03 18:00 ` Conor Dooley
-- strict thread matches above, loose matches on Subject: below --
2026-05-02 19:04 [PATCH v2 0/2] Support active-high alert polarity for LM75 Markus Stockhausen
2026-05-02 19:04 ` [PATCH 2/2] hwmon: (lm75) Support active-high alert polarity Markus Stockhausen
2026-05-02 19:36 ` sashiko-bot
2026-05-03 19:06 ` Guenter Roeck
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=20260501124540.0C11CC2BCB4@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