From: sashiko-bot@kernel.org
To: "Zaixiang Xu" <zaixiang.xu.dev@gmail.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v6 3/4] hwmon: (sht3x) Add devicetree support
Date: Tue, 28 Apr 2026 22:09:05 +0000 [thread overview]
Message-ID: <20260428220906.73A40C2BCAF@smtp.kernel.org> (raw)
In-Reply-To: <1777374569-59233-4-git-send-email-zaixiang.xu.dev@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Using enum value 0 as OF match data combined with missing I2C ID table entries causes incorrect device identification and brittle fallback logic.
--
commit e029bdd9863615efb54ed7864138224170daf0d1
Author: Zaixiang Xu <zaixiang.xu.dev@gmail.com>
hwmon: (sht3x) Add devicetree support
Add of_match_table to support devicetree based instantiation.
Specific match data is used to distinguish between temperature/humidity
(SHT) and temperature-only (STS) sensors.
> diff --git a/drivers/hwmon/sht3x.c b/drivers/hwmon/sht3x.c
> index 08306ccb6d0b..6437568aaf73 100644
> --- a/drivers/hwmon/sht3x.c
> +++ b/drivers/hwmon/sht3x.c
> @@ -939,8 +939,25 @@ static const struct i2c_device_id sht3x_ids[] = {
>
> MODULE_DEVICE_TABLE(i2c, sht3x_ids);
>
> +static const struct of_device_id sht3x_of_match[] = {
> + { .compatible = "sensirion,sht30", .data = (void *)(uintptr_t)sht3x },
> + { .compatible = "sensirion,sht31", .data = (void *)(uintptr_t)sht3x },
> + { .compatible = "sensirion,sht35", .data = (void *)(uintptr_t)sht3x },
> + { .compatible = "sensirion,sht85", .data = (void *)(uintptr_t)sht3x },
> + { .compatible = "sensirion,sts30", .data = (void *)(uintptr_t)sts3x },
> + { .compatible = "sensirion,sts31", .data = (void *)(uintptr_t)sts3x },
> + { .compatible = "sensirion,sts32", .data = (void *)(uintptr_t)sts3x },
> + { .compatible = "sensirion,sts35", .data = (void *)(uintptr_t)sts3x },
> + { }
> +};
Since sht3x is the first element of enum sht3x_chips and evaluates to 0, does
setting .data to (void *)(uintptr_t)sht3x essentially set it to NULL?
When instantiated via device tree, does device_get_match_data() return NULL
for these entries, causing i2c_get_match_data() to incorrectly fall back to
i2c_match_id()?
If instantiated manually via sysfs without a device tree node,
device_get_match_data() also returns NULL. If i2c_get_match_data() then falls
back to i2c_match_id(), does it fail to match the STS devices because they
are missing from sht3x_ids, causing it to return NULL?
When sht3x_probe() casts this NULL back to 0, does it incorrectly identify an
STS sensor as an SHT sensor, exposing non-functional humidity attributes?
Would it help to offset the chip enum values so they avoid 0, and to
explicitly add the newly added string variants to the I2C id_table?
--
Sashiko AI review · https://sashiko.dev/#/patchset/1777374569-59233-1-git-send-email-zaixiang.xu.dev@gmail.com?part=3
next prev parent reply other threads:[~2026-04-28 22:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-28 11:09 [PATCH v6 0/4] hwmon: (sht3x) Add support for GXCAS GXHT30 Zaixiang Xu
2026-04-28 11:09 ` [PATCH v6 1/4] dt-bindings: vendor-prefixes: Add GXCAS Technology Zaixiang Xu
2026-04-28 11:09 ` [PATCH v6 2/4] dt-bindings: hwmon: Add Sensirion SHT30 series Zaixiang Xu
2026-04-28 21:52 ` sashiko-bot
2026-04-29 6:27 ` Krzysztof Kozlowski
2026-04-29 6:28 ` Krzysztof Kozlowski
2026-04-28 11:09 ` [PATCH v6 3/4] hwmon: (sht3x) Add devicetree support Zaixiang Xu
2026-04-28 22:09 ` sashiko-bot [this message]
2026-04-28 11:09 ` [PATCH v6 4/4] hwmon: (sht3x) Add support for GXCAS GXHT30 Zaixiang Xu
2026-04-28 22:16 ` sashiko-bot
2026-04-29 6:29 ` Krzysztof Kozlowski
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=20260428220906.73A40C2BCAF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=sashiko@lists.linux.dev \
--cc=zaixiang.xu.dev@gmail.com \
/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.