From: sashiko-bot@kernel.org
To: "Marius Cristea" <marius.cristea@microchip.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v10 2/2] hwmon: temperature: add support for EMC1812
Date: Wed, 29 Apr 2026 18:35:34 +0000 [thread overview]
Message-ID: <20260429183534.B9A77C19425@smtp.kernel.org> (raw)
In-Reply-To: <20260429-hw_mon-emc1812-v10-2-a8ca1d779502@microchip.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] `emc1812_is_visible()` returns `-EOPNOTSUPP` instead of `0` to hide unsupported channels, exposing them with garbage sysfs permissions.
- [Medium] Incorrect bit indices are used when checking the active channels to configure the ideality factors, leading to an off-by-one error.
- [Low] Variables of type `int` are passed to `regmap_read()`, which expects an `unsigned int *`, causing `-Wpointer-sign` compiler warnings.
--
commit 334894f6ed5a53fe9f4a36ce3c196060e9967729
Author: Marius Cristea <marius.cristea@microchip.com>
hwmon: temperature: add support for EMC1812
This commit introduces the hardware monitoring driver for the Microchip
EMC1812/13/14/15/33 family of remote diode temperature sensors.
> diff --git a/drivers/hwmon/emc1812.c b/drivers/hwmon/emc1812.c
> index 000000000000..94e2709a566f
> --- /dev/null
> +++ b/drivers/hwmon/emc1812.c
[ ... ]
> +static umode_t emc1812_is_visible(const void *_data, enum hwmon_sensor_types type,
> + u32 attr, int channel)
> +{
> + const struct emc1812_data *data = _data;
> +
> + switch (type) {
> + case hwmon_temp:
> + /* Don't show channels which are not physically available */
> + if (channel >= data->chip->phys_channels)
> + return -EOPNOTSUPP;
Does this correctly hide the unsupported channels?
The hwmon core interprets the returned umode_t value as file permissions.
Returning a negative error code like -EOPNOTSUPP results in a large
positive non-zero value, which unintentionally creates sysfs attributes
with malformed permissions instead of hiding them. It seems returning 0
would properly hide the attributes.
[ ... ]
> +static int emc1812_read_reg(struct device *dev, struct emc1812_data *data, u32 attr,
> + int channel, long *val)
> +{
> + int hyst, ret;
> +
> + switch (attr) {
[ ... ]
> + case hwmon_temp_max_hyst:
> + ret = emc1812_get_limit_temp(data, channel, temp_max, val);
> + if (ret < 0)
> + return ret;
> +
> + ret = regmap_read(data->regmap, EMC1812_THRM_HYS_ADDR, &hyst);
Does this trigger a -Wpointer-sign compiler warning? The regmap_read API
expects an unsigned int pointer, but the hyst variable is declared as a signed
int.
[ ... ]
> +static int emc1812_set_hyst(struct emc1812_data *data, int channel, int val)
> +{
> + int hyst, ret;
> + int limit;
> +
> + /* Critical register is 8bits long and keeps only integer part of temperature */
> + ret = regmap_read(data->regmap, emc1812_temp_crit_regs[channel], &limit);
Similar to the above, limit is declared as a signed int. Does passing it
here cause a pointer signedness mismatch warning?
[ ... ]
> +static int emc1812_init(struct emc1812_data *priv)
> +{
> + int i, ret;
> + u8 val;
[ ... ]
> + /* Set the ideality factor only for the channels enabled on the chip */
> + if (test_bit(2, &priv->active_ch_mask)) {
> + ret = regmap_write(priv->regmap, EMC1812_EXT1_IDEALITY_FACTOR_ADDR,
> + EMC1812_DEFAULT_IDEALITY_FACTOR);
Since channel 0 corresponds to the internal diode, shouldn't EXT1 correspond
to bit 1, EXT2 to bit 2, and so on?
If so, checking bit 2 for EXT1 (and continuing up to bit 5 for EXT4) will result
in an off-by-one misalignment. This means EXT1 won't be configured if only
channel 1 is active, and the out-of-bounds bit 5 will be checked for EXT4 since
the bitmask has a maximum of 5 channels.
[ ... ]
> +static int emc1812_chip_identify(struct emc1812_data *data, struct i2c_client *client)
> +{
> + const struct emc1812_features *chip;
> + struct device *dev = &client->dev;
> + int ret, tmp;
> +
> + ret = regmap_read(data->regmap, EMC1812_PRODUCT_ID_ADDR, &tmp);
This also passes a signed int pointer to regmap_read. Can tmp be declared
as an unsigned int to avoid compiler warnings?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260429-hw_mon-emc1812-v10-0-a8ca1d779502@microchip.com?part=2
next prev parent reply other threads:[~2026-04-29 18:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 12:58 [PATCH v10 0/2] Add support for Microchip EMC1812 Marius Cristea
2026-04-29 12:58 ` [PATCH v10 1/2] dt-bindings: hwmon: temperature: add support for EMC1812 Marius Cristea
2026-04-29 13:24 ` sashiko-bot
2026-05-06 15:34 ` Rob Herring
2026-05-06 15:37 ` Rob Herring (Arm)
2026-04-29 12:58 ` [PATCH v10 2/2] " Marius Cristea
2026-04-29 18:35 ` sashiko-bot [this message]
2026-04-30 23:33 ` 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=20260429183534.B9A77C19425@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=marius.cristea@microchip.com \
--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 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.