* [PATCH v2] hwmon: lm75: Add support for label
@ 2026-03-22 16:26 Flaviu Nistor
2026-03-22 16:42 ` Guenter Roeck
0 siblings, 1 reply; 2+ messages in thread
From: Flaviu Nistor @ 2026-03-22 16:26 UTC (permalink / raw)
To: Guenter Roeck; +Cc: Flaviu Nistor, linux-hwmon, linux-kernel
Add support for label sysfs attribute similar to other hwmon devices.
This is particularly useful for systems with multiple sensors on the
same board, where identifying individual sensors is much easier since
labels can be defined via device tree.
Signed-off-by: Flaviu Nistor <flaviu.nistor@gmail.com>
---
- Drop the binding change since they are not necessary.
- Implement changes suggested by Guenter Roeck.
- Link to v1: https://lore.kernel.org/all/20260311105809.107357-2-flaviu.nistor@gmail.com/
drivers/hwmon/lm75.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index eda93a8c23c9..f1a1e5b888f6 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -108,6 +108,7 @@ static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
#define PCT2075_REG_IDLE 0x04
struct lm75_data {
+ const char *label;
struct regmap *regmap;
u16 orig_conf;
u8 resolution; /* In bits, 9 to 16 */
@@ -363,6 +364,16 @@ static irqreturn_t lm75_alarm_handler(int irq, void *private)
return IRQ_HANDLED;
}
+static int lm75_read_string(struct device *dev, enum hwmon_sensor_types type,
+ u32 attr, int channel, const char **str)
+{
+ struct lm75_data *data = dev_get_drvdata(dev);
+
+ *str = data->label;
+
+ return 0;
+}
+
static int lm75_read(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long *val)
{
@@ -534,6 +545,9 @@ static umode_t lm75_is_visible(const void *data, enum hwmon_sensor_types type,
switch (attr) {
case hwmon_temp_input:
return 0444;
+ case hwmon_temp_label:
+ /* Hide label node if label is not provided */
+ return config_data->label ? 0444 : 0;
case hwmon_temp_max:
case hwmon_temp_max_hyst:
return 0644;
@@ -553,13 +567,14 @@ static const struct hwmon_channel_info * const lm75_info[] = {
HWMON_CHANNEL_INFO(chip,
HWMON_C_REGISTER_TZ | HWMON_C_UPDATE_INTERVAL),
HWMON_CHANNEL_INFO(temp,
- HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_MAX_HYST |
+ HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_MAX | HWMON_T_MAX_HYST |
HWMON_T_ALARM),
NULL
};
static const struct hwmon_ops lm75_hwmon_ops = {
.is_visible = lm75_is_visible,
+ .read_string = lm75_read_string,
.read = lm75_read,
.write = lm75_write,
};
@@ -721,6 +736,9 @@ static int lm75_generic_probe(struct device *dev, const char *name,
/* needed by custom regmap callbacks */
dev_set_drvdata(dev, data);
+ /* Save the connected input label if available */
+ device_property_read_string(dev, "label", &data->label);
+
data->kind = kind;
data->regmap = regmap;
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] hwmon: lm75: Add support for label
2026-03-22 16:26 [PATCH v2] hwmon: lm75: Add support for label Flaviu Nistor
@ 2026-03-22 16:42 ` Guenter Roeck
0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2026-03-22 16:42 UTC (permalink / raw)
To: Flaviu Nistor; +Cc: linux-hwmon, linux-kernel
On Sun, Mar 22, 2026 at 06:26:16PM +0200, Flaviu Nistor wrote:
> Add support for label sysfs attribute similar to other hwmon devices.
> This is particularly useful for systems with multiple sensors on the
> same board, where identifying individual sensors is much easier since
> labels can be defined via device tree.
>
> Signed-off-by: Flaviu Nistor <flaviu.nistor@gmail.com>
Applied.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-22 16:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-22 16:26 [PATCH v2] hwmon: lm75: Add support for label Flaviu Nistor
2026-03-22 16:42 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®