From: Guenter Roeck <linux@roeck-us.net>
To: Flaviu Nistor <flaviu.nistor@gmail.com>
Cc: Jean Delvare <jdelvare@suse.com>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] hwmon: lm75: Add support for label
Date: Fri, 13 Mar 2026 11:37:57 -0700 [thread overview]
Message-ID: <b1118a3d-85bb-4214-84f0-bf12e0cd4ade@roeck-us.net> (raw)
In-Reply-To: <20260311105809.107357-2-flaviu.nistor@gmail.com>
On Wed, Mar 11, 2026 at 12:58:08PM +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>
> ---
> 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..66178ac63e4f 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;
Unnecessary ()
> 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 */
> + of_property_read_string(dev->of_node, "label", &data->label);
Please use device_property_read_string().
Thanks,
Guenter
> +
> data->kind = kind;
> data->regmap = regmap;
>
next prev parent reply other threads:[~2026-03-13 18:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-11 10:58 [PATCH 1/2] dt-bindings: hwmon: lm75: Add label property Flaviu Nistor
2026-03-11 10:58 ` [PATCH 2/2] hwmon: lm75: Add support for label Flaviu Nistor
2026-03-13 18:37 ` Guenter Roeck [this message]
2026-03-13 13:26 ` [PATCH 1/2] dt-bindings: hwmon: lm75: Add label property Krzysztof Kozlowski
2026-03-14 7:48 ` Flaviu Nistor
2026-03-14 8:50 ` Krzysztof Kozlowski
2026-03-18 20:03 ` Flaviu Nistor
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=b1118a3d-85bb-4214-84f0-bf12e0cd4ade@roeck-us.net \
--to=linux@roeck-us.net \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=flaviu.nistor@gmail.com \
--cc=jdelvare@suse.com \
--cc=krzk+dt@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
/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 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®