hwmon: (iio_hwmon) Make use of device properties
PATCH 1/1 hwmon: (iio_hwmon) Make use of device properties
Convert the module to be property provider agnostic and allow it to be used on non-OF platforms.
Add mod_devicetable.h include.
--- drivers/hwmon/iio_hwmon.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/hwmon/iio_hwmon.c +5 -3
@@ -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,'-' ,'_' );
Signature · 1 line
2.35.1
Guenter Roeck
maintainerQuoted 5 lines · Andy Shevchenko
Convert the module to be property provider agnostic and allow it to be used on non-OF platforms.
Add
mod_devicetable.hinclude.
What does that have to do with this patch ?
Quoted 35 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/hwmon/iio_hwmon.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/hwmon/iio_hwmon.c +5
-3@@ -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,'-' ,'_' );
Quoted 7 lines · Guenter Roeck
Quoted 5 lines · Andy Shevchenko
Convert the module to be property provider agnostic and allow it to be used on non-OF platforms.
Add
mod_devicetable.hinclude.What does that have to do with this patch ?
See below.
Quoted 3 lines
drivers/hwmon/iio_hwmon.c line 13
Quoted 3 lines
drivers/hwmon/iio_hwmon.c +1
-1+#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).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Guenter Roeck
maintainerQuoted 13 lines · Andy Shevchenko
Quoted 7 lines · Guenter Roeck
Quoted 5 lines · Andy Shevchenko
Convert the module to be property provider agnostic and allow it to be used on non-OF platforms.
Add
mod_devicetable.hinclude.What does that have to do with this patch ?
See below.
Quoted 1 line
Quoted 1 line
+#include <
linux/mod_devicetable.h>
Quoted 8 lines
Quoted 1 line
Quoted 1 line
-#include <
linux/of.h>The
of.himplicitly included missed headers. Themod_devicetable.his necessary when we dropof.h. OTOH I haven't checked ifmod_devicetable.his still included indirectly. Either way the correct approach is to includemod_devicetable.hsince we use a data type from it (of_device_idIIRC).
Something like
"Include mod_devicetable.h explicitly to replace the dropped of.h which
included mod_devicetable.h indirectly"
might be useful.
Thanks,
Guenter
Quoted 3 lines
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 3 lines · Guenter Roeck
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Guenter Roeck
On Sat, Jul 30, 2022 at 03:50:24PM +0300, Andy Shevchenko wrote:
...
Quoted 16 lines
Quoted 8 lines
Quoted 3 lines
Quoted 2 lines
Add
mod_devicetable.hinclude.What does that have to do with this patch ?
See below.
Quoted 1 line
Quoted 1 line
+#include <
linux/mod_devicetable.h>Quoted 8 lines
Quoted 1 line
Quoted 1 line
-#include <
linux/of.h>The
of.himplicitly included missed headers. Themod_devicetable.his necessary when we dropof.h. OTOH I haven't checked ifmod_devicetable.his still included indirectly. Either way the correct approach is to includemod_devicetable.hsince we use a data type from it (of_device_idIIRC).
Quoted 6 lines
Something like
"Include
mod_devicetable.hexplicitly to replace the droppedof.hwhich
includedmod_devicetable.hindirectly"might be useful.
Sure, I will add it in v2.
Thanks for review!
Signature · 2 lines
With Best Regards, Andy Shevchenko