linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] hwmon: (iio_hwmon) Make use of device properties
@ 2022-07-30 12:50 Andy Shevchenko
  2022-08-18 23:22 ` Guenter Roeck
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2022-07-30 12:50 UTC (permalink / raw)
  To: Andy Shevchenko, linux-hwmon, linux-kernel; +Cc: Jean Delvare, Guenter Roeck

Convert the module to be property provider agnostic and allow
it to be used on non-OF platforms.

Add mod_devicetable.h include.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/hwmon/iio_hwmon.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
index 580a7d125b88..3aa40893fc09 100644
--- a/drivers/hwmon/iio_hwmon.c
+++ b/drivers/hwmon/iio_hwmon.c
@@ -6,11 +6,13 @@
 
 #include <linux/kernel.h>
 #include <linux/slab.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/err.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
+
 #include <linux/hwmon.h>
-#include <linux/of.h>
 #include <linux/hwmon-sysfs.h>
 #include <linux/iio/consumer.h>
 #include <linux/iio/types.h>
@@ -149,8 +151,8 @@ static int iio_hwmon_probe(struct platform_device *pdev)
 	st->attr_group.attrs = st->attrs;
 	st->groups[0] = &st->attr_group;
 
-	if (dev->of_node) {
-		sname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn", dev->of_node);
+	if (dev_fwnode(dev)) {
+		sname = devm_kasprintf(dev, GFP_KERNEL, "%pfwP", dev_fwnode(dev));
 		if (!sname)
 			return -ENOMEM;
 		strreplace(sname, '-', '_');
-- 
2.35.1


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

* Re: [PATCH v1 1/1] hwmon: (iio_hwmon) Make use of device properties
  2022-07-30 12:50 [PATCH v1 1/1] hwmon: (iio_hwmon) Make use of device properties Andy Shevchenko
@ 2022-08-18 23:22 ` Guenter Roeck
  2022-08-19  9:50   ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2022-08-18 23:22 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-hwmon, linux-kernel, Jean Delvare

On Sat, Jul 30, 2022 at 03:50:24PM +0300, Andy Shevchenko wrote:
> Convert the module to be property provider agnostic and allow
> it to be used on non-OF platforms.
> 
> Add mod_devicetable.h include.
> 
What does that have to do with this patch ?

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/hwmon/iio_hwmon.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
> index 580a7d125b88..3aa40893fc09 100644
> --- a/drivers/hwmon/iio_hwmon.c
> +++ b/drivers/hwmon/iio_hwmon.c
> @@ -6,11 +6,13 @@
>  
>  #include <linux/kernel.h>
>  #include <linux/slab.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/err.h>
>  #include <linux/platform_device.h>
> +#include <linux/property.h>
> +
>  #include <linux/hwmon.h>
> -#include <linux/of.h>
>  #include <linux/hwmon-sysfs.h>
>  #include <linux/iio/consumer.h>
>  #include <linux/iio/types.h>
> @@ -149,8 +151,8 @@ static int iio_hwmon_probe(struct platform_device *pdev)
>  	st->attr_group.attrs = st->attrs;
>  	st->groups[0] = &st->attr_group;
>  
> -	if (dev->of_node) {
> -		sname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn", dev->of_node);
> +	if (dev_fwnode(dev)) {
> +		sname = devm_kasprintf(dev, GFP_KERNEL, "%pfwP", dev_fwnode(dev));
>  		if (!sname)
>  			return -ENOMEM;
>  		strreplace(sname, '-', '_');

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

* Re: [PATCH v1 1/1] hwmon: (iio_hwmon) Make use of device properties
  2022-08-18 23:22 ` Guenter Roeck
@ 2022-08-19  9:50   ` Andy Shevchenko
  2022-08-19 13:03     ` Guenter Roeck
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2022-08-19  9:50 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Andy Shevchenko, linux-hwmon, Linux Kernel Mailing List, Jean Delvare

On Fri, Aug 19, 2022 at 2:52 AM Guenter Roeck <linux@roeck-us.net> wrote:
> On Sat, Jul 30, 2022 at 03:50:24PM +0300, Andy Shevchenko wrote:
> > Convert the module to be property provider agnostic and allow
> > it to be used on non-OF platforms.
> >
> > Add mod_devicetable.h include.
> >
> What does that have to do with this patch ?

See below.

> > +#include <linux/mod_devicetable.h>

> > -#include <linux/of.h>

The of.h implicitly included missed headers. The mod_devicetable.h is
necessary when we drop of.h. OTOH I haven't checked if
mod_devicetable.h is still included indirectly. Either way the correct
approach is to include mod_devicetable.h since we use a data type from
it (of_device_id IIRC).

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH v1 1/1] hwmon: (iio_hwmon) Make use of device properties
  2022-08-19  9:50   ` Andy Shevchenko
@ 2022-08-19 13:03     ` Guenter Roeck
  2022-08-19 22:07       ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2022-08-19 13:03 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Andy Shevchenko, linux-hwmon, Linux Kernel Mailing List, Jean Delvare

On Fri, Aug 19, 2022 at 12:50:46PM +0300, Andy Shevchenko wrote:
> On Fri, Aug 19, 2022 at 2:52 AM Guenter Roeck <linux@roeck-us.net> wrote:
> > On Sat, Jul 30, 2022 at 03:50:24PM +0300, Andy Shevchenko wrote:
> > > Convert the module to be property provider agnostic and allow
> > > it to be used on non-OF platforms.
> > >
> > > Add mod_devicetable.h include.
> > >
> > What does that have to do with this patch ?
> 
> See below.
> 
> > > +#include <linux/mod_devicetable.h>
> 
> > > -#include <linux/of.h>
> 
> The of.h implicitly included missed headers. The mod_devicetable.h is
> necessary when we drop of.h. OTOH I haven't checked if
> mod_devicetable.h is still included indirectly. Either way the correct
> approach is to include mod_devicetable.h since we use a data type from
> it (of_device_id IIRC).
> 
Something like

"Include mod_devicetable.h explicitly to replace the dropped of.h which
 included mod_devicetable.h indirectly"

might be useful.

Thanks,
Guenter

> -- 
> With Best Regards,
> Andy Shevchenko

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

* Re: [PATCH v1 1/1] hwmon: (iio_hwmon) Make use of device properties
  2022-08-19 13:03     ` Guenter Roeck
@ 2022-08-19 22:07       ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-08-19 22:07 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Andy Shevchenko, linux-hwmon, Linux Kernel Mailing List, Jean Delvare

On Fri, Aug 19, 2022 at 4:03 PM Guenter Roeck <linux@roeck-us.net> wrote:
> On Fri, Aug 19, 2022 at 12:50:46PM +0300, Andy Shevchenko wrote:
> > On Fri, Aug 19, 2022 at 2:52 AM Guenter Roeck <linux@roeck-us.net> wrote:
> > > On Sat, Jul 30, 2022 at 03:50:24PM +0300, Andy Shevchenko wrote:

...

> > > > Add mod_devicetable.h include.
> > > >
> > > What does that have to do with this patch ?
> >
> > See below.
> >
> > > > +#include <linux/mod_devicetable.h>
> >
> > > > -#include <linux/of.h>
> >
> > The of.h implicitly included missed headers. The mod_devicetable.h is
> > necessary when we drop of.h. OTOH I haven't checked if
> > mod_devicetable.h is still included indirectly. Either way the correct
> > approach is to include mod_devicetable.h since we use a data type from
> > it (of_device_id IIRC).
> >
> Something like
>
> "Include mod_devicetable.h explicitly to replace the dropped of.h which
>  included mod_devicetable.h indirectly"
>
> might be useful.

Sure, I will add it in v2.
Thanks for review!

-- 
With Best Regards,
Andy Shevchenko

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

end of thread, other threads:[~2022-08-19 22:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-30 12:50 [PATCH v1 1/1] hwmon: (iio_hwmon) Make use of device properties Andy Shevchenko
2022-08-18 23:22 ` Guenter Roeck
2022-08-19  9:50   ` Andy Shevchenko
2022-08-19 13:03     ` Guenter Roeck
2022-08-19 22:07       ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).