Skip to contentSkip to conversation

iio:adc:axp20x: Convert from OF to generic fw / device properties

PATCH In review Jonathan Cameron 2 participants 3 messages Aug 9, 2020 – Aug 16, 2020

Subsystems (2)
lore
Share & tools
lore

Jonathan Cameron

author maintainer
#0 lore raw

PATCH v3 1/1 iio:adc:axp20x: Convert from OF to generic fw / device properties

From: Jonathan Cameron <[email protected]>

Whilst fairly unlikely anyone will ever use this driver with anything other than DT, we are trying to move IIO over to the generic interfaces where easy to do so.

In this case this involved moving to generic check on presence of fwnode, generic device_get_match_data() and dropping the of_match_ptr protection. Also relevant header changes to have property.h and mod_devicetable.h only.

Also drop the casting away of a const in favour of retaining the const throughout.

Cc Quentin Schulz <[email protected]>
Cc Andy Shevchenko <[email protected]>

---
V3 changes: Tidy up the commit message as suggested by Andy Schevchenko.

drivers/iio/adc/axp20x_adc.c | 14 +++++++-------

 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/iio/adc/axp20x_adc.c +7 -7
index 798ff2d89691..3e0c0233b431 100644
@@ -9,10 +9,10 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/module.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
+#include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/thermal.h>
 
@@ -67,7 +67,7 @@ struct axp_data;
 
 struct axp20x_adc_iio {
 	struct regmap		*regmap;
-	struct axp_data		*data;
+	const struct axp_data	*data;
 };
 
 enum axp20x_adc_channel_v {
@@ -670,15 +670,15 @@ static int axp20x_probe(struct platform_device *pdev)
 	info->regmap = axp20x_dev->regmap;
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
-	if (!pdev->dev.of_node) {
+	if (!dev_fwnode(&pdev->dev)) {
 		const struct platform_device_id *id;
 
 		id = platform_get_device_id(pdev);
-		info->data = (struct axp_data *)id->driver_data;
+		info->data = (const struct axp_data *)id->driver_data;
 	} else {
 		struct device *dev = &pdev->dev;
 
-		info->data = (struct axp_data *)of_device_get_match_data(dev);
+		info->data = device_get_match_data(dev);
 	}
 
 	indio_dev->name = platform_get_device_id(pdev)->name;
@@ -742,7 +742,7 @@ static int axp20x_remove(struct platform_device *pdev)
 static struct platform_driver axp20x_adc_driver = {
 	.driver = {
 		.name = "axp20x-adc",
-		.of_match_table = of_match_ptr(axp20x_adc_of_match),
+		.of_match_table = axp20x_adc_of_match,
 	},
 	.id_table = axp20x_adc_id_match,
 	.probe = axp20x_probe,
Signature · 1 line
2.28.0
Reviewed-by on v3 1/1
#1 lore raw
Quoted 7 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Whilst fairly unlikely anyone will ever use this driver with anything other than DT, we are trying to move IIO over to the generic interfaces where easy to do so.

Quoted 7 lines

In this case this involved moving to generic check on presence of fwnode, generic device_get_match_data() and dropping the of_match_ptr protection. Also relevant header changes to have property.h and mod_devicetable.h only.

Also drop the casting away of a const in favour of retaining the const throughout.

Quoted 67 lines
Cc Quentin Schulz <[email protected]>
Cc Andy Shevchenko <[email protected]>

---
V3 changes: Tidy up the commit message as suggested by Andy Schevchenko.

drivers/iio/adc/axp20x_adc.c | 14 +++++++-------

 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/iio/adc/axp20x_adc.c +7 -8
index 798ff2d89691..3e0c0233b431 100644
@@ -9,10 +9,10 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/module.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
+#include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/thermal.h>
 
@@ -67,7 +67,7 @@ struct axp_data;
 
 struct axp20x_adc_iio {
        struct regmap           *regmap;
-       struct axp_data         *data;
+       const struct axp_data   *data;
 };
 
 enum axp20x_adc_channel_v {
@@ -670,15 +670,15 @@ static int axp20x_probe(struct platform_device *pdev)
        info->regmap = axp20x_dev->regmap;
        indio_dev->modes = INDIO_DIRECT_MODE;
 
-       if (!pdev->dev.of_node) {
+       if (!dev_fwnode(&pdev->dev)) {
                const struct platform_device_id *id;
 
                id = platform_get_device_id(pdev);
-               info->data = (struct axp_data *)id->driver_data;
+               info->data = (const struct axp_data *)id->driver_data;
        } else {
                struct device *dev = &pdev->dev;
 
-               info->data = (struct axp_data *)of_device_get_match_data(dev);
+               info->data = device_get_match_data(dev);
        }
 
        indio_dev->name = platform_get_device_id(pdev)->name;
@@ -742,7 +742,7 @@ static int axp20x_remove(struct platform_device *pdev)
 static struct platform_driver axp20x_adc_driver = {
        .driver = {
                .name = "axp20x-adc",
-               .of_match_table = of_match_ptr(axp20x_adc_of_match),
+               .of_match_table = axp20x_adc_of_match,
        },
        .id_table = axp20x_adc_id_match,
        .probe = axp20x_probe,
--

2.28.0

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#2 lore raw
Quoted 13 lines · On Mon, 10 Aug 2020 11:01:22 +0300 Andy Shevchenko <[email protected]>…
Quoted 12 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Whilst fairly unlikely anyone will ever use this driver with anything other than DT, we are trying to move IIO over to the generic interfaces where easy to do so.

In this case this involved moving to generic check on presence of fwnode, generic device_get_match_data() and dropping the of_match_ptr protection. Also relevant header changes to have property.h and mod_devicetable.h only.

Quoted 5 lines
Quoted 2 lines

Also drop the casting away of a const in favour of retaining the const throughout.

Thanks. Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with them.

Thanks,

Jonathan

Quoted 70 lines
Quoted 68 lines
Cc Quentin Schulz <[email protected]>
Cc Andy Shevchenko <[email protected]>

---
V3 changes: Tidy up the commit message as suggested by Andy Schevchenko.

drivers/iio/adc/axp20x_adc.c | 14 +++++++-------

 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/iio/adc/axp20x_adc.c +7 -8
index 798ff2d89691..3e0c0233b431 100644
@@ -9,10 +9,10 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/module.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
+#include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/thermal.h>
 
@@ -67,7 +67,7 @@ struct axp_data;
 
 struct axp20x_adc_iio {
        struct regmap           *regmap;
-       struct axp_data         *data;
+       const struct axp_data   *data;
 };
 
 enum axp20x_adc_channel_v {
@@ -670,15 +670,15 @@ static int axp20x_probe(struct platform_device *pdev)
        info->regmap = axp20x_dev->regmap;
        indio_dev->modes = INDIO_DIRECT_MODE;
 
-       if (!pdev->dev.of_node) {
+       if (!dev_fwnode(&pdev->dev)) {
                const struct platform_device_id *id;
 
                id = platform_get_device_id(pdev);
-               info->data = (struct axp_data *)id->driver_data;
+               info->data = (const struct axp_data *)id->driver_data;
        } else {
                struct device *dev = &pdev->dev;
 
-               info->data = (struct axp_data *)of_device_get_match_data(dev);
+               info->data = device_get_match_data(dev);
        }
 
        indio_dev->name = platform_get_device_id(pdev)->name;
@@ -742,7 +742,7 @@ static int axp20x_remove(struct platform_device *pdev)
 static struct platform_driver axp20x_adc_driver = {
        .driver = {
                .name = "axp20x-adc",
-               .of_match_table = of_match_ptr(axp20x_adc_of_match),
+               .of_match_table = axp20x_adc_of_match,
        },
        .id_table = axp20x_adc_id_match,
        .probe = axp20x_probe,
--

2.28.0