All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwmon: (lm90) Switch channel parsing to fwnode APIs
@ 2026-07-13 19:06 Flaviu Nistor
  2026-07-13 19:16 ` sashiko-bot
  2026-07-14 12:22 ` Uwe Kleine-König
  0 siblings, 2 replies; 5+ messages in thread
From: Flaviu Nistor @ 2026-07-13 19:06 UTC (permalink / raw)
  To: Guenter Roeck, Jean Delvare; +Cc: Flaviu Nistor, linux-hwmon, linux-kernel

Replace OF property handling with fwnode API in the probe function to read
the channels properties, improving the driver compatibility since this
method is not limited to Device Tree only.
Add also the needed headers for explicit include and clean up related
function naming.

Signed-off-by: Flaviu Nistor <flaviu.nistor@gmail.com>
---
 drivers/hwmon/lm90.c | 48 +++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 25 deletions(-)

diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 4b9c0ccdf260..045977e30cf4 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -101,14 +101,16 @@
 #include <linux/bits.h>
 #include <linux/device.h>
 #include <linux/err.h>
+#include <linux/fwnode.h>
 #include <linux/i2c.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/jiffies.h>
 #include <linux/hwmon.h>
 #include <linux/kstrtox.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
-#include <linux/of.h>
+#include <linux/property.h>
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
 #include <linux/workqueue.h>
@@ -295,7 +297,7 @@ static const struct i2c_device_id lm90_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, lm90_id);
 
-static const struct of_device_id __maybe_unused lm90_of_match[] = {
+static const struct of_device_id lm90_of_match[] = {
 	{
 		.compatible = "adi,adm1032",
 		.data = (void *)adm1032
@@ -2602,7 +2604,6 @@ static void lm90_stop_work(void *_data)
 
 static int lm90_init_client(struct i2c_client *client, struct lm90_data *data)
 {
-	struct device_node *np = client->dev.of_node;
 	int config, convrate;
 
 	if (data->flags & LM90_HAVE_CONVRATE) {
@@ -2626,7 +2627,7 @@ static int lm90_init_client(struct i2c_client *client, struct lm90_data *data)
 
 	/* Check Temperature Range Select */
 	if (data->flags & LM90_HAVE_EXTENDED_TEMP) {
-		if (of_property_read_bool(np, "ti,extended-range-enable"))
+		if (device_property_read_bool(&client->dev, "ti,extended-range-enable"))
 			config |= 0x04;
 		if (!(config & 0x04))
 			data->flags &= ~LM90_HAVE_EXTENDED_TEMP;
@@ -2692,8 +2693,8 @@ static irqreturn_t lm90_irq_thread(int irq, void *dev_id)
 		return IRQ_NONE;
 }
 
-static int lm90_probe_channel_from_dt(struct i2c_client *client,
-				      struct device_node *child,
+static int lm90_probe_channel(struct i2c_client *client,
+				      struct fwnode_handle *child,
 				      struct lm90_data *data)
 {
 	u32 id;
@@ -2701,27 +2702,27 @@ static int lm90_probe_channel_from_dt(struct i2c_client *client,
 	int err;
 	struct device *dev = &client->dev;
 
-	err = of_property_read_u32(child, "reg", &id);
+	err = fwnode_property_read_u32(child, "reg", &id);
 	if (err) {
-		dev_err(dev, "missing reg property of %pOFn\n", child);
+		dev_err(dev, "missing reg property of %pfw\n", child);
 		return err;
 	}
 
 	if (id >= MAX_CHANNELS) {
-		dev_err(dev, "invalid reg property value %d in %pOFn\n", id, child);
+		dev_err(dev, "invalid reg property value %d in %pfw\n", id, child);
 		return -EINVAL;
 	}
 
-	err = of_property_read_string(child, "label", &data->channel_label[id]);
+	err = fwnode_property_read_string(child, "label", &data->channel_label[id]);
 	if (err == -ENODATA || err == -EILSEQ) {
-		dev_err(dev, "invalid label property in %pOFn\n", child);
+		dev_err(dev, "invalid label property in %pfw\n", child);
 		return err;
 	}
 
 	if (data->channel_label[id])
 		data->channel_config[id] |= HWMON_T_LABEL;
 
-	err = of_property_read_s32(child, "temperature-offset-millicelsius", &val);
+	err = fwnode_property_read_u32(child, "temperature-offset-millicelsius", &val);
 	if (!err) {
 		if (id == 0) {
 			dev_err(dev, "temperature-offset-millicelsius can't be set for internal channel\n");
@@ -2739,18 +2740,17 @@ static int lm90_probe_channel_from_dt(struct i2c_client *client,
 	return 0;
 }
 
-static int lm90_parse_dt_channel_info(struct i2c_client *client,
-				      struct lm90_data *data)
+static int lm90_parse_channel_info(struct i2c_client *client,
+				   struct lm90_data *data)
 {
 	int err;
 	struct device *dev = &client->dev;
-	const struct device_node *np = dev->of_node;
 
-	for_each_child_of_node_scoped(np, child) {
-		if (strcmp(child->name, "channel"))
+	device_for_each_child_node_scoped(dev, child) {
+		if (!fwnode_name_eq(child, "channel"))
 			continue;
 
-		err = lm90_probe_channel_from_dt(client, child, data);
+		err = lm90_probe_channel(client, child, data);
 		if (err)
 			return err;
 	}
@@ -2887,12 +2887,10 @@ static int lm90_probe(struct i2c_client *client)
 	/* Set maximum conversion rate */
 	data->max_convrate = lm90_params[data->kind].max_convrate;
 
-	/* Parse device-tree channel information */
-	if (client->dev.of_node) {
-		err = lm90_parse_dt_channel_info(client, data);
-		if (err)
-			return err;
-	}
+	/* Parse channel information */
+	err = lm90_parse_channel_info(client, data);
+	if (err)
+		return err;
 
 	/* Initialize the LM90 chip */
 	err = lm90_init_client(client, data);
@@ -2985,7 +2983,7 @@ static struct i2c_driver lm90_driver = {
 	.class		= I2C_CLASS_HWMON,
 	.driver = {
 		.name	= "lm90",
-		.of_match_table = of_match_ptr(lm90_of_match),
+		.of_match_table = lm90_of_match,
 		.pm	= pm_sleep_ptr(&lm90_pm_ops),
 	},
 	.probe		= lm90_probe,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] hwmon: (lm90) Switch channel parsing to fwnode APIs
  2026-07-13 19:06 [PATCH] hwmon: (lm90) Switch channel parsing to fwnode APIs Flaviu Nistor
@ 2026-07-13 19:16 ` sashiko-bot
  2026-07-14 12:22 ` Uwe Kleine-König
  1 sibling, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-07-13 19:16 UTC (permalink / raw)
  To: Flaviu Nistor; +Cc: linux-hwmon

> Replace OF property handling with fwnode API in the probe function to read
> the channels properties, improving the driver compatibility since this
> method is not limited to Device Tree only.
> Add also the needed headers for explicit include and clean up related
> function naming.
> 
> Signed-off-by: Flaviu Nistor <flaviu.nistor@gmail.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260713190659.4511-1-flaviu.nistor@gmail.com?part=1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hwmon: (lm90) Switch channel parsing to fwnode APIs
  2026-07-13 19:06 [PATCH] hwmon: (lm90) Switch channel parsing to fwnode APIs Flaviu Nistor
  2026-07-13 19:16 ` sashiko-bot
@ 2026-07-14 12:22 ` Uwe Kleine-König
  2026-07-14 14:43   ` Guenter Roeck
  1 sibling, 1 reply; 5+ messages in thread
From: Uwe Kleine-König @ 2026-07-14 12:22 UTC (permalink / raw)
  To: Flaviu Nistor; +Cc: Guenter Roeck, Jean Delvare, linux-hwmon, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1406 bytes --]

Hello,

On Mon, Jul 13, 2026 at 10:06:59PM +0300, Flaviu Nistor wrote:
> Replace OF property handling with fwnode API in the probe function to read
> the channels properties, improving the driver compatibility since this
> method is not limited to Device Tree only.
> Add also the needed headers for explicit include and clean up related
> function naming.
> 
> Signed-off-by: Flaviu Nistor <flaviu.nistor@gmail.com>
> ---
>  drivers/hwmon/lm90.c | 48 +++++++++++++++++++++-----------------------
>  1 file changed, 23 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
> index 4b9c0ccdf260..045977e30cf4 100644
> --- a/drivers/hwmon/lm90.c
> +++ b/drivers/hwmon/lm90.c
> @@ -101,14 +101,16 @@
>  #include <linux/bits.h>
>  #include <linux/device.h>
>  #include <linux/err.h>
> +#include <linux/fwnode.h>
>  #include <linux/i2c.h>
>  #include <linux/init.h>
>  #include <linux/interrupt.h>
>  #include <linux/jiffies.h>
>  #include <linux/hwmon.h>
>  #include <linux/kstrtox.h>
> +#include <linux/mod_devicetable.h>

<linux/mod_devicetable.h> is going away soon. Please rely on
<linux/i2c.h> to provide of_device_id.

>  #include <linux/module.h>
> -#include <linux/of.h>
> +#include <linux/property.h>
>  #include <linux/regulator/consumer.h>
>  #include <linux/slab.h>
>  #include <linux/workqueue.h>

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hwmon: (lm90) Switch channel parsing to fwnode APIs
  2026-07-14 12:22 ` Uwe Kleine-König
@ 2026-07-14 14:43   ` Guenter Roeck
  2026-07-14 17:09     ` Uwe Kleine-König
  0 siblings, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2026-07-14 14:43 UTC (permalink / raw)
  To: Uwe Kleine-König, Flaviu Nistor
  Cc: Jean Delvare, linux-hwmon, linux-kernel

On 7/14/26 05:22, Uwe Kleine-König wrote:
> Hello,
> 
> On Mon, Jul 13, 2026 at 10:06:59PM +0300, Flaviu Nistor wrote:
>> Replace OF property handling with fwnode API in the probe function to read
>> the channels properties, improving the driver compatibility since this
>> method is not limited to Device Tree only.
>> Add also the needed headers for explicit include and clean up related
>> function naming.
>>
>> Signed-off-by: Flaviu Nistor <flaviu.nistor@gmail.com>
>> ---
>>   drivers/hwmon/lm90.c | 48 +++++++++++++++++++++-----------------------
>>   1 file changed, 23 insertions(+), 25 deletions(-)
>>
>> diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
>> index 4b9c0ccdf260..045977e30cf4 100644
>> --- a/drivers/hwmon/lm90.c
>> +++ b/drivers/hwmon/lm90.c
>> @@ -101,14 +101,16 @@
>>   #include <linux/bits.h>
>>   #include <linux/device.h>
>>   #include <linux/err.h>
>> +#include <linux/fwnode.h>
>>   #include <linux/i2c.h>
>>   #include <linux/init.h>
>>   #include <linux/interrupt.h>
>>   #include <linux/jiffies.h>
>>   #include <linux/hwmon.h>
>>   #include <linux/kstrtox.h>
>> +#include <linux/mod_devicetable.h>
> 
> <linux/mod_devicetable.h> is going away soon. Please rely on
> <linux/i2c.h> to provide of_device_id.
> 

My hwmon-next branch is based off v7.2-rc1 and of_device_id
is declared in mod_devicetable.h.

Guenter


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hwmon: (lm90) Switch channel parsing to fwnode APIs
  2026-07-14 14:43   ` Guenter Roeck
@ 2026-07-14 17:09     ` Uwe Kleine-König
  0 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2026-07-14 17:09 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: Flaviu Nistor, Jean Delvare, linux-hwmon, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2053 bytes --]

Hello Guenter,

On Tue, Jul 14, 2026 at 07:43:13AM -0700, Guenter Roeck wrote:
> On 7/14/26 05:22, Uwe Kleine-König wrote:
> > On Mon, Jul 13, 2026 at 10:06:59PM +0300, Flaviu Nistor wrote:
> > > Replace OF property handling with fwnode API in the probe function to read
> > > the channels properties, improving the driver compatibility since this
> > > method is not limited to Device Tree only.
> > > Add also the needed headers for explicit include and clean up related
> > > function naming.
> > > 
> > > Signed-off-by: Flaviu Nistor <flaviu.nistor@gmail.com>
> > > ---
> > >   drivers/hwmon/lm90.c | 48 +++++++++++++++++++++-----------------------
> > >   1 file changed, 23 insertions(+), 25 deletions(-)
> > > 
> > > diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
> > > index 4b9c0ccdf260..045977e30cf4 100644
> > > --- a/drivers/hwmon/lm90.c
> > > +++ b/drivers/hwmon/lm90.c
> > > @@ -101,14 +101,16 @@
> > >   #include <linux/bits.h>
> > >   #include <linux/device.h>
> > >   #include <linux/err.h>
> > > +#include <linux/fwnode.h>
> > >   #include <linux/i2c.h>
> > >   #include <linux/init.h>
> > >   #include <linux/interrupt.h>
> > >   #include <linux/jiffies.h>
> > >   #include <linux/hwmon.h>
> > >   #include <linux/kstrtox.h>
> > > +#include <linux/mod_devicetable.h>
> > 
> > <linux/mod_devicetable.h> is going away soon. Please rely on
> > <linux/i2c.h> to provide of_device_id.
> 
> My hwmon-next branch is based off v7.2-rc1 and of_device_id
> is declared in mod_devicetable.h.

That sounds factual correct.

If you want to imply with that statement that my recommendation is
wrong, annoying or in other ways unsuitable to you I guess you either
have to be more explicit or live with it.

<linux/i2c.h> provides i2c_driver which uses of_device_id (via struct
device_driver) and thus includes a header that provides that struct.
That won't change in the foreseeable future. If that is not good enough
for you, find means to handle that in another way.

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-07-14 17:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-13 19:06 [PATCH] hwmon: (lm90) Switch channel parsing to fwnode APIs Flaviu Nistor
2026-07-13 19:16 ` sashiko-bot
2026-07-14 12:22 ` Uwe Kleine-König
2026-07-14 14:43   ` Guenter Roeck
2026-07-14 17:09     ` Uwe Kleine-König

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.