hwmon: (sht3x) Add support for GXCAS GXHT30
Subsystems (2)
v6 cover hwmon: (sht3x) Add support for GXCAS GXHT30
Hi all,
This v6 addresses the feedback provided by Guenter on v5 regarding the Sashiko results.
In v5, I attempted to rely entirely on the I2C core's fallback matching and moved the devices to trivial-devices.yaml. However, as Guenter pointed out, the driver requires a proper of_device_id table to pass DT checks and function correctly.
Because an explicit of_match_table is necessary in the driver, it is no longer appropriate to list these sensors in trivial-devices.yaml. Therefore, in this v6, I have introduced a proper, dedicated YAML binding for the Sensirion SHT30 series and GXCAS GXHT30.
Changes in v6:
- Dropped the trivial-devices.yaml approach from v5.
- Added a dedicated YAML binding file (sensirion,sht30.yaml).
- Added standard devicetree support (of_device_id table) to sht3x.c as requested by Guenter.
- Split the patches into 4 logically separated commits (Vendor prefix, YAML binding, Driver DT support, Driver GXHT30 support).
Changes in v5:
- (Attempted) Move to trivial-devices.yaml and drop of_match_table.
- Dropped wildcards, added specific models.
- Wrapped commit messages to 72 characters.
v3 & v4:
- Standalone YAML binding (but incorrectly used wildcards).
v2:
- Fix placeholder "Your Name" in MODULE_AUTHOR.
v1:
- Initial submission.
Zaixiang Xu (4):
dt-bindings: vendor-prefixes: Add GXCAS Technology
dt-bindings: hwmon: Add Sensirion SHT30 series
hwmon: (sht3x) Add devicetree support
hwmon: (sht3x) Add support for GXCAS GXHT30
.../bindings/hwmon/sensirion,sht30.yaml | 67 +++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + drivers/hwmon/sht3x.c | 22 +++++- 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/hwmon/sensirion,sht30.yaml
Signature · 1 line
2.34.1
PATCH v6 1/4 dt-bindings: vendor-prefixes: Add GXCAS Technology
Add vendor prefix for Beijing Galaxy-CAS Technology Co., Ltd. (GXCAS). The prefix was confirmed from the manufacturer's website:
https://www.gxcas.com/en/index.html
--- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
@@ -676,6 +676,8 @@ patternProperties: description: Gateworks Corporation use "gateworks" vendor prefix deprecated: true + "^gxcas,.*": + description: Beijing Galaxy-CAS Technology Co., Ltd. "^hannstar,.*": description: HannStar Display Corporation "^haochuangyi,.*":
Signature · 1 line
2.34.1
PATCH v6 2/4 dt-bindings: hwmon: Add Sensirion SHT30 series
In reply to Zaixiang XuAdd YAML devicetree binding schema for Sensirion SHT30 series and the compatible GXCAS GXHT30 sensors.
Use fallback compatibles for compatible chips and add optional interrupts and vdd-supply properties.
--- .../bindings/hwmon/sensirion,sht30.yaml | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/sensirion,sht30.yaml
Documentation/devicetree/bindings/hwmon/sensirion,sht30.yaml new file +67 -0
@@ -0,0 +1,67 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/sensirion,sht30.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sensirion SHT3x and GXCAS GXHT30 humidity and temperature sensors + +maintainers: + - Zaixiang Xu <[email protected]> + +properties: + compatible: + oneOf: + - enum: + - sensirion,sht30 + - sensirion,sht31 + - sensirion,sht35 + - sensirion,sht85 + - sensirion,sts30 + - sensirion,sts31 + - sensirion,sts32 + - sensirion,sts35 + - items: + - const: gxcas,gxht30 + - const: sensirion,sht30 + + reg: + maxItems: 1 + + vdd-supply: + description: Regulator that provides power to the VDD pin. + + reset-gpios: + maxItems: 1 + description: + GPIO connected to the nRESET pin. Active low. + + interrupts: + maxItems: 1 + description: + Interrupt connected to the ALERT pin. + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/irq.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + humidity-sensor@44 { + compatible = "gxcas,gxht30", "sensirion,sht30"; + reg = <0x44>; + vdd-supply = <&vcc_3v3_reg>; + reset-gpios = <&gpio1 15 GPIO_ACTIVE_LOW>; + interrupt-parent = <&gpio1>; + interrupts = <16 IRQ_TYPE_LEVEL_HIGH>; + }; + };
Signature · 1 line
2.34.1
PATCH v6 3/4 hwmon: (sht3x) Add devicetree support
In reply to Zaixiang XuAdd of_match_table to support devicetree based instantiation. Specific match data is used to distinguish between temperature/humidity (SHT) and temperature-only (STS) sensors.
--- drivers/hwmon/sht3x.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/hwmon/sht3x.c +18 -1
@@ -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 }, + { } +}; + +MODULE_DEVICE_TABLE (of, sht3x_of_match); +static struct i2c_driver sht3x_i2c_driver = { - .driver.name ="sht3x" , + .driver = { + .name ="sht3x" , + .of_match_table = sht3x_of_match, + }, .probe = sht3x_probe, .id_table = sht3x_ids, };
Signature · 1 line
2.34.1
PATCH v6 4/4 hwmon: (sht3x) Add support for GXCAS GXHT30
In reply to Zaixiang XuAdd support for the GXCAS GXHT30 humidity and temperature sensor. The GXHT30 is software compatible with the Sensirion SHT30.
--- drivers/hwmon/sht3x.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/hwmon/sht3x.c +3 -0
@@ -934,6 +934,7 @@ static const struct i2c_device_id sht3x_ids[] = { {"sht3x", sht3x}, {"sts3x", sts3x}, {"sht85", sht3x}, + {"gxht30", sht3x}, {} };
@@ -948,6 +949,7 @@ static const struct of_device_id sht3x_of_match[] = { { .compatible = "sensirion,sts31", .data = (void *)(uintptr_t)sts3x }, { .compatible = "sensirion,sts32", .data = (void *)(uintptr_t)sts3x }, { .compatible = "sensirion,sts35", .data = (void *)(uintptr_t)sts3x }, + { .compatible = "gxcas,gxht30", .data = (void *)(uintptr_t)sht3x }, { } };
@@ -965,5 +967,6 @@ module_i2c_driver(sht3x_i2c_driver);MODULE_AUTHOR ("David Frey <[email protected]>" );MODULE_AUTHOR ("Pascal Sachs <[email protected]>" ); +MODULE_AUTHOR ("Zaixiang Xu <[email protected]>" );MODULE_DESCRIPTION ("Sensirion SHT3x humidity and temperature sensor driver" );MODULE_LICENSE ("GPL" );
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v6 2/4] dt-bindings: hwmon: Add Sensirion SHT30 series
In reply to Zaixiang XuThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The commit message fails to document the addition of the `reset-gpios` property. --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The commit message fails to document the addition of the reset-gpios property. --
commit 525f467a79c77fd6f91d6d35fc10f95495902569
Author: Zaixiang Xu <[email protected]>
dt-bindings: hwmon: Add Sensirion SHT30 series
This commit adds the YAML devicetree binding schema for the Sensirion SHT30 series and GXCAS GXHT30 sensors. It establishes fallback compatibles and introduces several optional properties for the devices.
Quoted 2 lines
Use fallback compatibles for compatible chips and add optional interrupts and vdd-supply properties.
This isn't a bug, but the commit message states that interrupts and vdd-supply are added as optional properties, while the actual schema also introduces a reset-gpios property.
Could the commit message be updated to also mention the addition of the reset-gpios property so it matches the changes in the schema?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
[email protected]
AI reviewRe: [PATCH v6 3/4] hwmon: (sht3x) Add devicetree support
In reply to Zaixiang XuThank 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…
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 <[email protected]>
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.
Quoted 9 lines
drivers/hwmon/sht3x.c +1
-0@@ -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[] = {
drivers/hwmon/sht3x.c static const struct i2c_device_id sht3x_ids[] = { · line 952
Quoted 10 lines
drivers/hwmon/sht3x.c +10
-0+ { .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?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [Low] Redundant compatible string in the OF match table. - [Low] Missing update to subsystem…
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Low] Redundant compatible string in the OF match table.
- [Low] Missing update to subsystem documentation (Documentation/hwmon/sht3x.rst).
- [Low] Missing Kconfig help text update.
--
commit 907d39a1530eacc8aee2b5e489cdd9c94b10ce78
Author: Zaixiang Xu <[email protected]>
hwmon: (sht3x) Add support for GXCAS GXHT30
This commit adds support for the GXCAS GXHT30 humidity and temperature sensor. The GXHT30 is described as being software compatible with the Sensirion SHT30.
Quoted 4 lines
drivers/hwmon/sht3x.c +0
-0
[ ... ]
drivers/hwmon/sht3x.c static const struct of_device_id sht3x_of_match[] = { · line 952
Quoted 5 lines
drivers/hwmon/sht3x.c +1
-0@@ -948,6 +949,7 @@ static const struct of_device_id sht3x_of_match[] = { { .compatible = "sensirion,sts31", .data = (void *)(uintptr_t)sts3x }, { .compatible = "sensirion,sts32", .data = (void *)(uintptr_t)sts3x }, { .compatible = "sensirion,sts35", .data = (void *)(uintptr_t)sts3x }, + { .compatible = "gxcas,gxht30", .data = (void *)(uintptr_t)sht3x },
Is this explicit compatible string entry necessary in the driver?
The device tree binding for the GXHT30 enforces using sensirion,sht30 as a fallback compatible string. Since the device tree node will provide sensirion,sht30 in its compatible list, and the driver already matches sensirion,sht30 using the same sht3x driver data, the fallback should handle the matching automatically without needing an explicit entry here.
This isn't a bug, but should the documentation and Kconfig be updated for the new chip?
The patch adds a new hardware chip but doesn't update the supported chips section in Documentation/hwmon/sht3x.rst, or the help text for CONFIG_SENSORS_SHT3x in drivers/hwmon/Kconfig. Updating these is expected when adding support for a new device to the hardware monitoring subsystem.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
Re: [PATCH v6 2/4] dt-bindings: hwmon: Add Sensirion SHT30 series
In reply to Zaixiang XuDocumentation/devicetree/bindings/hwmon/sensirion,sht30.yaml line 46
Quoted 8 lines · Zaixiang Xu
Documentation/devicetree/bindings/hwmon/sensirion,sht30.yaml new file +8
-0+ interrupts: + maxItems: 1 + description: + Interrupt connected to the ALERT pin. + +required: + - compatible + - reg
supply should not be optional.
Documentation/devicetree/bindings/hwmon/sensirion,sht30.yaml line 57
Quoted 11 lines
Documentation/devicetree/bindings/hwmon/sensirion,sht30.yaml new file +11
-0+ +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/irq.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>;
Best regards,
Krzysztof
Re: [PATCH v6 2/4] dt-bindings: hwmon: Add Sensirion SHT30 series
In reply to Zaixiang XuQuoted 31 lines · Zaixiang Xu
Add YAML devicetree binding schema for Sensirion SHT30 series and the compatible GXCAS GXHT30 sensors.
Use fallback compatibles for compatible chips and add optional interrupts and vdd-supply properties.
Signed-off-by Zaixiang Xu <[email protected]>--- .../bindings/hwmon/sensirion,sht30.yaml | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/sensirion,sht30.yamlDocumentation/devicetree/bindings/hwmon/sensirion,sht30.yaml new file +13
-0@@ -0,0 +1,67 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/sensirion,sht30.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sensirion SHT3x and GXCAS GXHT30 humidity and temperature sensors + +maintainers: + - Zaixiang Xu <[email protected]> + +properties: + compatible:
Documentation/devicetree/bindings/hwmon/sensirion,sht30.yaml line 23
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/sensirion,sht30.yaml new file +10
-0+ oneOf: + - enum: + - sensirion,sht30 + - sensirion,sht31 + - sensirion,sht35 + - sensirion,sht85 + - sensirion,sts30 + - sensirion,sts31 + - sensirion,sts32 + - sensirion,sts35
I don't understand this - it AGAIN does not match the driver. Your driver clearly claims all of these are compatible. But binding does not. Explain the reasons in commit msg.
Best regards,
Krzysztof
Quoted 21 lines · Zaixiang Xu
Add support for the GXCAS GXHT30 humidity and temperature sensor. The GXHT30 is software compatible with the Sensirion SHT30.
Signed-off-by Zaixiang Xu <[email protected]>--- drivers/hwmon/sht3x.c | 3 +++ 1 file changed, 3 insertions(+)drivers/hwmon/sht3x.c +1
-0@@ -934,6 +934,7 @@ static const struct i2c_device_id sht3x_ids[] = { {"sht3x", sht3x}, {"sts3x", sts3x}, {"sht85", sht3x}, + {"gxht30", sht3x}, {} };
drivers/hwmon/sht3x.c static const struct of_device_id sht3x_of_match[] = { · line 952
Quoted 4 lines
drivers/hwmon/sht3x.c +1
-0@@ -948,6 +949,7 @@ static const struct of_device_id sht3x_of_match[] = { { .compatible = "sensirion,sts31", .data = (void *)(uintptr_t)sts3x }, { .compatible = "sensirion,sts32", .data = (void *)(uintptr_t)sts3x }, { .compatible = "sensirion,sts35", .data = (void *)(uintptr_t)sts3x }, + { .compatible = "gxcas,gxht30", .data = (void *)(uintptr_t)sht3x },
Drop, this is completely pointless. We asked for fallbacks for a reason.
Best regards,
Krzysztof