dt-bindings: hwmon: ti,tmp401: Add label property
Subsystems (2)
PATCH 1/2 dt-bindings: hwmon: ti,tmp401: Add label property
Add support for an optional channel label property similar to other hwmon devices.
--- .../devicetree/bindings/hwmon/ti,tmp401.yaml | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+)
Documentation/devicetree/bindings/hwmon/ti,tmp401.yaml +58 -0
@@ -30,6 +30,12 @@ properties: reg: maxItems: 1 + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + ti,extended-range-enable: description: When set, this sensor measures over extended temperature range.
@@ -50,6 +56,26 @@ properties: minimum: 0 maximum: 15 +patternProperties: + "^channel@([0-2])$": + type: object + description: Represents channels of the device and their specific configuration. + + properties: + reg: + description: The channel number. 0 is local channel, 1-2 are remote channels. + items: + minimum: 0 + maximum: 2 + + label: + description: A descriptive name for this channel, like "ambient" or "psu". + + required: + - reg + + additionalProperties: false + allOf: - if: properties:
@@ -72,6 +98,16 @@ allOf: properties: ti,beta-compensation: false + - if: + not: + properties: + compatible: + contains: + const: ti,tmp432 + then: + properties: + channel@2: false + required: - compatible - reg
@@ -102,3 +138,25 @@ examples: ti,beta-compensation = <0x7>; }; }; + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + sensor@4c { + compatible = "ti,tmp431"; + reg = <0x4c>; + #address-cells = <1>; + #size-cells = <0>; + + channel@0 { + reg = <0x0>; + label = "front"; + }; + + channel@1 { + reg = <0x1>; + label = "back"; + }; + }; + };
base-commit: 11028ab62899e4191e074ee364c712b77823a9c4
Signature · 1 line
2.55.0
PATCH 2/2 hwmon: (tmp401) add channel label support
Allow userspace application to select temperature sensor based on channel label in device tree, just like it's possible in lm90.
--- drivers/hwmon/tmp401.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/hwmon/tmp401.c +34 -0
@@ -117,6 +117,7 @@ struct tmp401_data {struct hwmon_channel_info temp_info;const struct hwmon_channel_info *info[3 ];struct hwmon_chip_info chip; +const char *channel_label[4 ]; };/* regmap */
@@ -467,6 +468,16 @@ static int tmp401_read(struct device *dev, enum hwmon_sensor_types type, } } +static int tmp401_read_string (struct device *dev,enum hwmon_sensor_types type, +u32 attr,int channel,const char **str) +{ +struct tmp401_data *data =dev_get_drvdata (dev); + + *str = data->channel_label[channel]; + +return 0 ; +} +static int tmp401_write (struct device *dev,enum hwmon_sensor_types type,u32 attr,int channel,long val) {
@@ -502,6 +513,7 @@ static umode_t tmp401_is_visible(const void *data, enum hwmon_sensor_types type,case hwmon_temp_fault:case hwmon_temp_lowest:case hwmon_temp_highest: +case hwmon_temp_label:return 0444 ;case hwmon_temp_min:case hwmon_temp_max:
@@ -521,6 +533,7 @@ static umode_t tmp401_is_visible(const void *data, enum hwmon_sensor_types type,static const struct hwmon_ops tmp401_ops = { .is_visible = tmp401_is_visible, .read = tmp401_read, + .read_string = tmp401_read_string, .write = tmp401_write, };
@@ -531,6 +544,7 @@ static int tmp401_init_client(struct tmp401_data *data)struct regmap *regmap = data->regmap;u32 config, config_orig;int ret; +u32 ch;u32 val =0 ;s32 nfactor =0 ;
@@ -590,6 +604,26 @@ static int tmp401_init_client(struct tmp401_data *data)return ret; } +for_each_child_of_node_scoped (data->client->dev.of_node, child) { + ret =of_property_read_u32 (child,"reg" , &ch); +if (ret) { +dev_err (&data->client->dev,"missing reg property of %pOFn\n" , child); +return ret; + } +if (ch >=ARRAY_SIZE (data->temp_channel_config) || + !data->temp_channel_config[ch]) { +dev_err (&data->client->dev,"invalid reg %u of %pOFn\n" , ch, child); +return -EINVAL ; + } + ret =of_property_read_string (child,"label" , &data->channel_label[ch]); +if (ret == -ENODATA || ret == -EILSEQ ) { +dev_err (&data->client->dev,"invalid label property in %pOFn\n" , child); +return ret; + } +if (data->channel_label[ch]) + data->temp_channel_config[ch] |=HWMON_T_LABEL ; + } +return 0 ; }
Signature · 1 line
2.55.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 4 lines
Add support for an optional channel label property similar to other hwmon devices.
Signed-off-by Bruno Thomsen <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
[email protected]
AI reviewRe: [PATCH 2/2] hwmon: (tmp401) add channel label support
In reply to Bruno ThomsenSashiko has reviewed this patch and found no issues. It looks great!
Quoted 4 lines
Allow userspace application to select temperature sensor based on channel label in device tree, just like it's possible in lm90.
Signed-off-by Bruno Thomsen <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Quoted 2 lines · Bruno Thomsen
Add support for an optional channel label property similar to other hwmon devices.
No, you need to provide reasons. Other bindings need properties per channel, but yours do not, so you do not have a valid case.
Quoted 11 lines
Signed-off-by Bruno Thomsen <[email protected]>--- .../devicetree/bindings/hwmon/ti,tmp401.yaml | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+)Documentation/devicetree/bindings/hwmon/ti,tmp401.yaml +0
-0
Documentation/devicetree/bindings/hwmon/ti,tmp401.yaml properties: · line 36
Quoted 7 lines
Documentation/devicetree/bindings/hwmon/ti,tmp401.yaml +4
-0@@ -30,6 +30,12 @@ properties: reg: maxItems: 1 + '#address-cells': + const: 1 + + '#size-cells':
Use consistent quotes.
Quoted 50 lines
Documentation/devicetree/bindings/hwmon/ti,tmp401.yaml +32
-0+ const: 0 + ti,extended-range-enable: description: When set, this sensor measures over extended temperature range.@@ -50,6 +56,26 @@ properties: minimum: 0 maximum: 15 +patternProperties: + "^channel@([0-2])$": + type: object + description: Represents channels of the device and their specific configuration. + + properties: + reg: + description: The channel number. 0 is local channel, 1-2 are remote channels. + items: + minimum: 0 + maximum: 2 + + label: + description: A descriptive name for this channel, like "ambient" or "psu". + + required: + - reg + + additionalProperties: false + allOf: - if: properties:@@ -72,6 +98,16 @@ allOf: properties: ti,beta-compensation: false + - if: + not: + properties: + compatible: + contains: + const: ti,tmp432 + then: + properties: + channel@2: false + required: - compatible - reg
Documentation/devicetree/bindings/hwmon/ti,tmp401.yaml examples: · line 144
Quoted 7 lines
Documentation/devicetree/bindings/hwmon/ti,tmp401.yaml +4
-0@@ -102,3 +138,25 @@ examples: ti,beta-compensation = <0x7>; }; }; + - | + i2c { + #address-cells = <1>; + #size-cells = <0>;
No need for new example, just grow existing.
Best regards,
Krzysztof