Skip to contentSkip to conversation

iio: afe: rescale: Make use of device properties

PATCH In review Andy Shevchenko 3 participants 5 messages Apr 13, 2022 – Apr 16, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: afe: rescale: Make use of device properties

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

---
 drivers/iio/afe/Kconfig       | 1 -
 drivers/iio/afe/iio-rescale.c | 5 ++---
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/iio/afe/Kconfig +0 -1
index 4fa397822cff..9a1d95c1c7ed 100644
@@ -8,7 +8,6 @@ menu "Analog Front Ends"
 
 config IIO_RESCALE
 	tristate "IIO rescale"
-	depends on OF || COMPILE_TEST
 	help
 	  Say yes here to build support for the IIO rescaling
 	  that handles voltage dividers, current sense shunts and
drivers/iio/afe/iio-rescale.c +2 -3
index 7e511293d6d1..c6cf709f0f05 100644
@@ -10,9 +10,8 @@
 
 #include <linux/err.h>
 #include <linux/gcd.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/property.h>
 
@@ -536,7 +535,7 @@ static int rescale_probe(struct platform_device *pdev)
 
 	rescale = iio_priv(indio_dev);
 
-	rescale->cfg = of_device_get_match_data(dev);
+	rescale->cfg = device_get_match_data(dev);
 	rescale->numerator = 1;
 	rescale->denominator = 1;
 	rescale->offset = 0;
Signature · 1 line
2.35.1
#1 lore raw

Hi Andy,

Quoted 26 lines · Andy Shevchenko

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

---
 drivers/iio/afe/Kconfig       | 1 -
 drivers/iio/afe/iio-rescale.c | 5 ++---
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/iio/afe/Kconfig +0 -1
index 4fa397822cff..9a1d95c1c7ed 100644
@@ -8,7 +8,6 @@ menu "Analog Front Ends"
 
 config IIO_RESCALE
 	tristate "IIO rescale"
-	depends on OF || COMPILE_TEST
 	help
 	  Say yes here to build support for the IIO rescaling
 	  that handles voltage dividers, current sense shunts and
drivers/iio/afe/iio-rescale.c +0 -0
index 7e511293d6d1..c6cf709f0f05 100644

drivers/iio/afe/iio-rescale.c line 13

Quoted 4 lines
drivers/iio/afe/iio-rescale.c +1 -0
@@ -10,9 +10,8 @@
 
 #include <linux/err.h>
 #include <linux/gcd.h>
+#include <linux/mod_devicetable.h>

Is this really needed?
device_get_match_data() is already defined in <linux/property.h>

Cheers,
Liam

Quoted 18 lines
drivers/iio/afe/iio-rescale.c +1 -3
 #include <linux/module.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/property.h>
 
@@ -536,7 +535,7 @@ static int rescale_probe(struct platform_device *pdev)
 
 	rescale = iio_priv(indio_dev);
 
-	rescale->cfg = of_device_get_match_data(dev);
+	rescale->cfg = device_get_match_data(dev);
 	rescale->numerator = 1;
 	rescale->denominator = 1;
 	rescale->offset = 0;
Signature · 1 line
2.35.1
#2 lore raw
Quoted 9 lines · Liam Beguin

Hi Andy,

Quoted 4 lines · Andy Shevchenko

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

+#include <linux/mod_devicetable.h>

Is this really needed?

Yes.
This header is missed. I can split its addition to a separate patch.

Quoted 1 line

device_get_match_data() is already defined in <linux/property.h>

It's indirectly related (just like we do when we clean up of.h). Since the original of.h is missed there is no header replacement, just adding.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 7 lines · Andy Shevchenko
Quoted 5 lines · Liam Beguin

Hi Andy,

Quoted 2 lines · Andy Shevchenko

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

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

+#include <linux/mod_devicetable.h>

Is this really needed?

Yes.
This header is missed. I can split its addition to a separate patch.

Understood, maybe a separate patch would make it more explicit.

Cheers,
Liam

Quoted 10 lines
Quoted 1 line

device_get_match_data() is already defined in <linux/property.h>

It's indirectly related (just like we do when we clean up of.h). Since the original of.h is missed there is no header replacement, just adding.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#4 lore raw
Quoted 8 lines · On Fri, 15 Apr 2022 10:47:23 -0400 Liam Beguin <[email protected]> wrote:
Quoted 7 lines · Andy Shevchenko
Quoted 5 lines · Liam Beguin

Hi Andy,

Quoted 2 lines · Andy Shevchenko

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

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

+#include <linux/mod_devicetable.h>

Is this really needed?

Yes.
This header is missed. I can split its addition to a separate patch.

Understood, maybe a separate patch would make it more explicit.

You could also argue that the main route people 'expect' that header via is of.h and given that include is dropped in this patch, we have even more reason mod_devicetable.h should be included.

So I'm fine with this in one patch on that basis.

Also I'm lazy and not having to go to v2 on this saves me a little bit of effort :)

Hence applied.

Jonathan

Quoted 14 lines

Cheers,
Liam

Quoted 10 lines
Quoted 1 line

device_get_match_data() is already defined in <linux/property.h>

It's indirectly related (just like we do when we clean up of.h). Since the original of.h is missed there is no header replacement, just adding.

Signature · 2 lines
With Best Regards,
Andy Shevchenko