Skip to contentSkip to conversation

iio: light: clean out of_match_ptr and tidy headers

PATCH In review [email protected] 4 participants 22 messages Apr 19, 2020 – Apr 25, 2020

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

cover iio: light: clean out of_match_ptr and tidy headers

From: Jonathan Cameron <[email protected]>

Hi All,

Given we keep having to explain to people that of_match_ptr is less than ideal now we have the option of ACPI DSDT using PRP0001 and the compatible, it seems sensible to reduce the number of instances that people might copy for a new driver.

Added theoretical benefit is that we can probe all these drivers from appropriate DSDT (though I doubt anyone will).

I'm sending this first set out to see if anyone has strong views against doing this for at least the simple drivers that have no other device tree dependence. Obviously more work would be needed to remove use of of_match_ptr from IIO completely.

Light sensors picked as a starting point as they tend to be simple.

I may do follow ups in larger blocks to avoid so many small patches (or indeed flatten these into one when applying)

Thanks

Jonathan

Jonathan Cameron (7):
iio: light: bh1780: use mod_devicetable.h and drop of_match_ptr macro
iio: light: cm32181: Add mod_devicetable.h and remove of_match_ptr
iio: light: cm3232: Add mod_devicetable.h include and drop
of_match_ptr
iio: light: gp2ap020a00f: Swap of.h for mod_devicetable.h + drop
of_match_ptr
iio: light: opt3001: Add mod_devicetable.h and drop use of
of_match_ptr
iio: light: st_uvis25: Add mod_devicetable.h and drop of_match_ptr
iio: light: vl6180: swap of.h for mod_devicetable.h and drop
of_match_ptr

 drivers/iio/light/bh1780.c        | 6 ++----
 drivers/iio/light/cm32181.c       | 3 ++-
 drivers/iio/light/cm3232.c        | 3 ++-
 drivers/iio/light/gp2ap020a00f.c  | 6 ++----
 drivers/iio/light/opt3001.c       | 3 ++-
 drivers/iio/light/st_uvis25_i2c.c | 3 ++-
 drivers/iio/light/st_uvis25_spi.c | 3 ++-
 drivers/iio/light/vl6180.c        | 2 +-
 8 files changed, 15 insertions(+), 14 deletions(-)
Signature · 1 line
2.26.1
author maintainer
#1 lore raw

PATCH 1/7 iio: light: bh1780: use mod_devicetable.h and drop of_match_ptr macro

From: Jonathan Cameron <[email protected]>

Whilst this enables ACPI binding or the device via PRP0001 the primary aim is to remove potential for these two things to be cut and paste into new drivers.

---
 drivers/iio/light/bh1780.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/iio/light/bh1780.c +2 -4
index a8361006dcd9..03f2d8d123c4 100644
@@ -13,7 +13,7 @@
 #include <linux/platform_device.h>
 #include <linux/delay.h>
 #include <linux/module.h>
-#include <linux/of.h>
+#include <linux/mod_devicetable.h>
 #include <linux/pm_runtime.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
@@ -273,13 +273,11 @@ static const struct i2c_device_id bh1780_id[] = {
 
 MODULE_DEVICE_TABLE(i2c, bh1780_id);
 
-#ifdef CONFIG_OF
 static const struct of_device_id of_bh1780_match[] = {
 	{ .compatible = "rohm,bh1780gli", },
 	{},
 };
 MODULE_DEVICE_TABLE(of, of_bh1780_match);
-#endif
 
 static struct i2c_driver bh1780_driver = {
 	.probe		= bh1780_probe,
@@ -288,7 +286,7 @@ static struct i2c_driver bh1780_driver = {
 	.driver = {
 		.name = "bh1780",
 		.pm = &bh1780_dev_pm_ops,
-		.of_match_table = of_match_ptr(of_bh1780_match),
+		.of_match_table = of_bh1780_match,
 	},
 };
 
Signature · 1 line
2.26.1
Reviewed-by on v1 1/7
#2 lore raw

Re: [PATCH 1/7] iio: light: bh1780: use mod_devicetable.h and drop of_match_ptr macro

Quoted 5 lines · On Sun, 2020-04-19 at 16:02 +0100, [email protected] wrote:

From: Jonathan Cameron <[email protected]>

Whilst this enables ACPI binding or the device via PRP0001 the primary aim is to remove potential for these two things to be cut and paste into new drivers.

Quoted 42 lines
---
 drivers/iio/light/bh1780.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/iio/light/bh1780.c +2 -4
index a8361006dcd9..03f2d8d123c4 100644
@@ -13,7 +13,7 @@
 #include <linux/platform_device.h>
 #include <linux/delay.h>
 #include <linux/module.h>
-#include <linux/of.h>
+#include <linux/mod_devicetable.h>
 #include <linux/pm_runtime.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
@@ -273,13 +273,11 @@ static const struct i2c_device_id bh1780_id[] = {
 
 MODULE_DEVICE_TABLE(i2c, bh1780_id);
 
-#ifdef CONFIG_OF
 static const struct of_device_id of_bh1780_match[] = {
 	{ .compatible = "rohm,bh1780gli", },
 	{},
 };
 MODULE_DEVICE_TABLE(of, of_bh1780_match);
-#endif
 
 static struct i2c_driver bh1780_driver = {
 	.probe		= bh1780_probe,
@@ -288,7 +286,7 @@ static struct i2c_driver bh1780_driver = {
 	.driver = {
 		.name = "bh1780",
 		.pm = &bh1780_dev_pm_ops,
-		.of_match_table = of_match_ptr(of_bh1780_match),
+		.of_match_table = of_bh1780_match,
 	},
 };
 
author maintainer
#3 lore raw

PATCH 2/7 iio: light: cm32181: Add mod_devicetable.h and remove of_match_ptr

In reply to [email protected]

From: Jonathan Cameron <[email protected]>

Enables probing via the ACPI PRP0001 route but more is mosty about removing examples of this that might get copied into new drivers.

---
 drivers/iio/light/cm32181.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/light/cm32181.c +2 -1
index 5f4fb5674fa0..73c48f46220c 100644
@@ -9,6 +9,7 @@
 #include <linux/i2c.h>
 #include <linux/mutex.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/interrupt.h>
 #include <linux/regulator/consumer.h>
 #include <linux/iio/iio.h>
@@ -354,7 +355,7 @@ MODULE_DEVICE_TABLE(of, cm32181_of_match);
 static struct i2c_driver cm32181_driver = {
 	.driver = {
 		.name	= "cm32181",
-		.of_match_table = of_match_ptr(cm32181_of_match),
+		.of_match_table = cm32181_of_match,
 	},
 	.id_table       = cm32181_id,
 	.probe		= cm32181_probe,
Signature · 1 line
2.26.1
Reviewed-by on v1 2/7
#4 lore raw

Re: [PATCH 2/7] iio: light: cm32181: Add mod_devicetable.h and remove of_match_ptr

Quoted 5 lines · On Sun, 2020-04-19 at 16:02 +0100, [email protected] wrote:

From: Jonathan Cameron <[email protected]>

Enables probing via the ACPI PRP0001 route but more is mosty about removing examples of this that might get copied into new drivers.

Quoted 26 lines
---
 drivers/iio/light/cm32181.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/light/cm32181.c +2 -1
index 5f4fb5674fa0..73c48f46220c 100644
@@ -9,6 +9,7 @@
 #include <linux/i2c.h>
 #include <linux/mutex.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/interrupt.h>
 #include <linux/regulator/consumer.h>
 #include <linux/iio/iio.h>
@@ -354,7 +355,7 @@ MODULE_DEVICE_TABLE(of, cm32181_of_match);
 static struct i2c_driver cm32181_driver = {
 	.driver = {
 		.name	= "cm32181",
-		.of_match_table = of_match_ptr(cm32181_of_match),
+		.of_match_table = cm32181_of_match,
 	},
 	.id_table       = cm32181_id,
 	.probe		= cm32181_probe,
author maintainer
#5 lore raw

PATCH 3/7 iio: light: cm3232: Add mod_devicetable.h include and drop of_match_ptr

In reply to [email protected]

From: Jonathan Cameron <[email protected]>

Enables ACPI probing via PRP0001 and removes an example that might be cut and paste to a new driver.

---
 drivers/iio/light/cm3232.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/light/cm3232.c +2 -1
index cd3cfb7d02bd..867200825686 100644
@@ -10,6 +10,7 @@
 
 #include <linux/i2c.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 #include <linux/init.h>
@@ -418,7 +419,7 @@ MODULE_DEVICE_TABLE(of, cm3232_of_match);
 static struct i2c_driver cm3232_driver = {
 	.driver = {
 		.name	= "cm3232",
-		.of_match_table = of_match_ptr(cm3232_of_match),
+		.of_match_table = cm3232_of_match,
 #ifdef CONFIG_PM_SLEEP
 		.pm	= &cm3232_pm_ops,
 #endif
Signature · 1 line
2.26.1
Reviewed-by on v1 3/7
#6 lore raw

Re: [PATCH 3/7] iio: light: cm3232: Add mod_devicetable.h include and drop of_match_ptr

Quoted 5 lines · On Sun, 2020-04-19 at 16:02 +0100, [email protected] wrote:

From: Jonathan Cameron <[email protected]>

Enables ACPI probing via PRP0001 and removes an example that might be cut and paste to a new driver.

Quoted 26 lines
---
 drivers/iio/light/cm3232.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/light/cm3232.c +2 -1
index cd3cfb7d02bd..867200825686 100644
@@ -10,6 +10,7 @@
 
 #include <linux/i2c.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 #include <linux/init.h>
@@ -418,7 +419,7 @@ MODULE_DEVICE_TABLE(of, cm3232_of_match);
 static struct i2c_driver cm3232_driver = {
 	.driver = {
 		.name	= "cm3232",
-		.of_match_table = of_match_ptr(cm3232_of_match),
+		.of_match_table = cm3232_of_match,
 #ifdef CONFIG_PM_SLEEP
 		.pm	= &cm3232_pm_ops,
 #endif
author maintainer
#7 lore raw

PATCH 4/7 iio: light: gp2ap020a00f: Swap of.h for mod_devicetable.h + drop of_match_ptr

In reply to [email protected]

From: Jonathan Cameron <[email protected]>

Also drops ifdef protections for CONFIG_OF.

Enables probing via ACPI PRP0001 and removes an example that might be cut and paste into new drivers.

---
 drivers/iio/light/gp2ap020a00f.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/iio/light/gp2ap020a00f.c +2 -4
index 7fbbce0d4bc7..070d4cd0cf54 100644
@@ -38,8 +38,8 @@
 #include <linux/irq.h>
 #include <linux/irq_work.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/mutex.h>
-#include <linux/of.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
@@ -1617,18 +1617,16 @@ static const struct i2c_device_id gp2ap020a00f_id[] = {
 
 MODULE_DEVICE_TABLE(i2c, gp2ap020a00f_id);
 
-#ifdef CONFIG_OF
 static const struct of_device_id gp2ap020a00f_of_match[] = {
 	{ .compatible = "sharp,gp2ap020a00f" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, gp2ap020a00f_of_match);
-#endif
 
 static struct i2c_driver gp2ap020a00f_driver = {
 	.driver = {
 		.name	= GP2A_I2C_NAME,
-		.of_match_table = of_match_ptr(gp2ap020a00f_of_match),
+		.of_match_table = gp2ap020a00f_of_match,
 	},
 	.probe		= gp2ap020a00f_probe,
 	.remove		= gp2ap020a00f_remove,
Signature · 1 line
2.26.1
Reviewed-by on v1 4/7
#8 lore raw

Re: [PATCH 4/7] iio: light: gp2ap020a00f: Swap of.h for mod_devicetable.h + drop of_match_ptr

Quoted 7 lines · On Sun, 2020-04-19 at 16:02 +0100, [email protected] wrote:

From: Jonathan Cameron <[email protected]>

Also drops ifdef protections for CONFIG_OF.

Enables probing via ACPI PRP0001 and removes an example that might be cut and paste into new drivers.

Quoted 41 lines
---
 drivers/iio/light/gp2ap020a00f.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/iio/light/gp2ap020a00f.c +2 -4
index 7fbbce0d4bc7..070d4cd0cf54 100644
@@ -38,8 +38,8 @@
 #include <linux/irq.h>
 #include <linux/irq_work.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/mutex.h>
-#include <linux/of.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
@@ -1617,18 +1617,16 @@ static const struct i2c_device_id gp2ap020a00f_id[] =
 {
 
 MODULE_DEVICE_TABLE(i2c, gp2ap020a00f_id);
 
-#ifdef CONFIG_OF
 static const struct of_device_id gp2ap020a00f_of_match[] = {
 	{ .compatible = "sharp,gp2ap020a00f" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, gp2ap020a00f_of_match);
-#endif
 
 static struct i2c_driver gp2ap020a00f_driver = {
 	.driver = {
 		.name	= GP2A_I2C_NAME,
-		.of_match_table = of_match_ptr(gp2ap020a00f_of_match),
+		.of_match_table = gp2ap020a00f_of_match,
 	},
 	.probe		= gp2ap020a00f_probe,

.remove = gp2ap020a00f_remove,

author maintainer
#9 lore raw

PATCH 5/7 iio: light: opt3001: Add mod_devicetable.h and drop use of of_match_ptr

In reply to [email protected]

From: Jonathan Cameron <[email protected]>

Enables probing via ACPI PRP0001 but mostly about removing examples that might be copied to new drivers.

---
 drivers/iio/light/opt3001.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/light/opt3001.c +2 -1
index 92004a2563ea..82abfa57b59c 100644
@@ -16,6 +16,7 @@
 #include <linux/irq.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/mutex.h>
 #include <linux/slab.h>
 #include <linux/types.h>
@@ -844,7 +845,7 @@ static struct i2c_driver opt3001_driver = {
 
 	.driver = {
 		.name = "opt3001",
-		.of_match_table = of_match_ptr(opt3001_of_match),
+		.of_match_table = opt3001_of_match,
 	},
 };
 
Signature · 1 line
2.26.1
Reviewed-by on v1 5/7
#10 lore raw

Re: [PATCH 5/7] iio: light: opt3001: Add mod_devicetable.h and drop use of of_match_ptr

Quoted 5 lines · On Sun, 2020-04-19 at 16:02 +0100, [email protected] wrote:

From: Jonathan Cameron <[email protected]>

Enables probing via ACPI PRP0001 but mostly about removing examples that might be copied to new drivers.

Quoted 26 lines
---
 drivers/iio/light/opt3001.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/light/opt3001.c +2 -1
index 92004a2563ea..82abfa57b59c 100644
@@ -16,6 +16,7 @@
 #include <linux/irq.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/mutex.h>
 #include <linux/slab.h>
 #include <linux/types.h>
@@ -844,7 +845,7 @@ static struct i2c_driver opt3001_driver = {
 
 	.driver = {
 		.name = "opt3001",
-		.of_match_table = of_match_ptr(opt3001_of_match),
+		.of_match_table = opt3001_of_match,
 	},
 };
 
author maintainer
#11 lore raw

PATCH 6/7 iio: light: st_uvis25: Add mod_devicetable.h and drop of_match_ptr

In reply to [email protected]

From: Jonathan Cameron <[email protected]>

Enables probing via ACPI PRP0001 and removes an example that we don't want people to cut and paste into new drivers.

---
 drivers/iio/light/st_uvis25_i2c.c | 3 ++-
 drivers/iio/light/st_uvis25_spi.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/iio/light/st_uvis25_i2c.c +2 -1
index 400724069d19..98cd49eefe45 100644
@@ -9,6 +9,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/i2c.h>
 #include <linux/slab.h>
 #include <linux/regmap.h>
@@ -55,7 +56,7 @@ static struct i2c_driver st_uvis25_driver = {
 	.driver = {
 		.name = "st_uvis25_i2c",
 		.pm = &st_uvis25_pm_ops,
-		.of_match_table = of_match_ptr(st_uvis25_i2c_of_match),
+		.of_match_table = st_uvis25_i2c_of_match,
 	},
 	.probe = st_uvis25_i2c_probe,
 	.id_table = st_uvis25_i2c_id_table,
drivers/iio/light/st_uvis25_spi.c +2 -1
index cd3761a3ee3f..af9d94d12787 100644
@@ -9,6 +9,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/spi/spi.h>
 #include <linux/slab.h>
 #include <linux/regmap.h>
@@ -55,7 +56,7 @@ static struct spi_driver st_uvis25_driver = {
 	.driver = {
 		.name = "st_uvis25_spi",
 		.pm = &st_uvis25_pm_ops,
-		.of_match_table = of_match_ptr(st_uvis25_spi_of_match),
+		.of_match_table = st_uvis25_spi_of_match,
 	},
 	.probe = st_uvis25_spi_probe,
 	.id_table = st_uvis25_spi_id_table,
Signature · 1 line
2.26.1
Reviewed-by on v1 6/7
#12 lore raw

Re: [PATCH 6/7] iio: light: st_uvis25: Add mod_devicetable.h and drop of_match_ptr

Quoted 5 lines · On Sun, 2020-04-19 at 16:02 +0100, [email protected] wrote:

From: Jonathan Cameron <[email protected]>

Enables probing via ACPI PRP0001 and removes an example that we don't want people to cut and paste into new drivers.

Quoted 50 lines
---
 drivers/iio/light/st_uvis25_i2c.c | 3 ++-
 drivers/iio/light/st_uvis25_spi.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/iio/light/st_uvis25_i2c.c +2 -1
index 400724069d19..98cd49eefe45 100644
@@ -9,6 +9,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/i2c.h>
 #include <linux/slab.h>
 #include <linux/regmap.h>
@@ -55,7 +56,7 @@ static struct i2c_driver st_uvis25_driver = {
 	.driver = {
 		.name = "st_uvis25_i2c",
 		.pm = &st_uvis25_pm_ops,
-		.of_match_table = of_match_ptr(st_uvis25_i2c_of_match),
+		.of_match_table = st_uvis25_i2c_of_match,
 	},
 	.probe = st_uvis25_i2c_probe,
 	.id_table = st_uvis25_i2c_id_table,
drivers/iio/light/st_uvis25_spi.c +2 -1
index cd3761a3ee3f..af9d94d12787 100644
@@ -9,6 +9,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/spi/spi.h>
 #include <linux/slab.h>
 #include <linux/regmap.h>
@@ -55,7 +56,7 @@ static struct spi_driver st_uvis25_driver = {
 	.driver = {
 		.name = "st_uvis25_spi",
 		.pm = &st_uvis25_pm_ops,
-		.of_match_table = of_match_ptr(st_uvis25_spi_of_match),
+		.of_match_table = st_uvis25_spi_of_match,
 	},
 	.probe = st_uvis25_spi_probe,
 	.id_table = st_uvis25_spi_id_table,
author maintainer
#13 lore raw

PATCH 7/7 iio: light: vl6180: swap of.h for mod_devicetable.h and drop of_match_ptr

In reply to [email protected]

From: Jonathan Cameron <[email protected]>

Enables probing via ACPI PRP0001 route and removes an example of an approach we no longer want people to copy.

---
 drivers/iio/light/vl6180.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/vl6180.c +1 -1
index d9533a76b8f6..7e67d7b3bfb6 100644
@@ -537,7 +537,7 @@ MODULE_DEVICE_TABLE(i2c, vl6180_id);
 static struct i2c_driver vl6180_driver = {
 	.driver = {
 		.name   = VL6180_DRV_NAME,
-		.of_match_table = of_match_ptr(vl6180_of_match),
+		.of_match_table = vl6180_of_match,
 	},
 	.probe  = vl6180_probe,
 	.id_table = vl6180_id,
Signature · 1 line
2.26.1
Reviewed-by on v1 7/7
#14 lore raw

Re: [PATCH 7/7] iio: light: vl6180: swap of.h for mod_devicetable.h and drop of_match_ptr

Quoted 5 lines · On Sun, 2020-04-19 at 16:02 +0100, [email protected] wrote:

From: Jonathan Cameron <[email protected]>

Enables probing via ACPI PRP0001 route and removes an example of an approach we no longer want people to copy.

This doesn't include 'linux/mod_devicetable.h'.
I'm wondering now if it is needed at all.
Should we remove it from the rest?

With that addressed:

Quoted 18 lines
---
 drivers/iio/light/vl6180.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/vl6180.c +1 -1
index d9533a76b8f6..7e67d7b3bfb6 100644
@@ -537,7 +537,7 @@ MODULE_DEVICE_TABLE(i2c, vl6180_id);
 static struct i2c_driver vl6180_driver = {
 	.driver = {
 		.name   = VL6180_DRV_NAME,
-		.of_match_table = of_match_ptr(vl6180_of_match),
+		.of_match_table = vl6180_of_match,
 	},
 	.probe  = vl6180_probe,
 	.id_table = vl6180_id,
#15 lore raw

Re: [PATCH 7/7] iio: light: vl6180: swap of.h for mod_devicetable.h and drop of_match_ptr

Quoted 11 lines · Alexandru
Quoted 5 lines · On Sun, 2020-04-19 at 16:02 +0100, [email protected] wrote:

From: Jonathan Cameron <[email protected]>

Enables probing via ACPI PRP0001 route and removes an example of an approach we no longer want people to copy.

This doesn't include 'linux/mod_devicetable.h'.
I'm wondering now if it is needed at all.
Should we remove it from the rest?

Oops.

So this is one of those classics. mod_devicetable is included by the spi and i2c headers but there is no actual 'need' for them to do so. The could (I think) get away with an appropriate forwards definition.

This is in contrast to the drivers that need to know what that structure looks like (as does the i2c core device tree code etc).

So should we include it or not? I'm generally of the view that we should for resilience but others favour minimal includes.

Jonathan

Quoted 22 lines

With that addressed:

Quoted 18 lines
---
 drivers/iio/light/vl6180.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/vl6180.c +1 -1
index d9533a76b8f6..7e67d7b3bfb6 100644
@@ -537,7 +537,7 @@ MODULE_DEVICE_TABLE(i2c, vl6180_id);
 static struct i2c_driver vl6180_driver = {
 	.driver = {
 		.name   = VL6180_DRV_NAME,
-		.of_match_table = of_match_ptr(vl6180_of_match),
+		.of_match_table = vl6180_of_match,
 	},
 	.probe  = vl6180_probe,
 	.id_table = vl6180_id,  
#16 lore raw

Re: [PATCH 7/7] iio: light: vl6180: swap of.h for mod_devicetable.h and drop of_match_ptr

Quoted 20 lines · Jonathan Cameron
Quoted 11 lines · Alexandru
Quoted 5 lines · On Sun, 2020-04-19 at 16:02 +0100, [email protected] wrote:

From: Jonathan Cameron <[email protected]>

Enables probing via ACPI PRP0001 route and removes an example of an approach we no longer want people to copy.

This doesn't include 'linux/mod_devicetable.h'.
I'm wondering now if it is needed at all.
Should we remove it from the rest?

Oops.

So this is one of those classics. mod_devicetable is included by the spi and i2c headers but there is no actual 'need' for them to do so. The could (I think) get away with an appropriate forwards definition.

Quoted 5 lines

This is in contrast to the drivers that need to know what that structure looks like (as does the i2c core device tree code etc).

So should we include it or not? I'm generally of the view that we should for resilience but others favour minimal includes.

I'm a bit in the middle here between minimalism & resilience/more-explicit- inclusions.

No strong opinions about it.
I've been through 1-2 inclusion-hell fixing; still no strong opinion. Maybe I need a few more.

I usually leave it to someone else's preference.

Quoted 28 lines

Jonathan

Quoted 22 lines

With that addressed:

Quoted 18 lines
---
 drivers/iio/light/vl6180.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/vl6180.c +1 -1
index d9533a76b8f6..7e67d7b3bfb6 100644
@@ -537,7 +537,7 @@ MODULE_DEVICE_TABLE(i2c, vl6180_id);
 static struct i2c_driver vl6180_driver = {
 	.driver = {
 		.name   = VL6180_DRV_NAME,
-		.of_match_table = of_match_ptr(vl6180_of_match),
+		.of_match_table = vl6180_of_match,
 	},
 	.probe  = vl6180_probe,
 	.id_table = vl6180_id,  
#17 lore raw
In reply to [email protected]
Quoted 17 lines · On Sun, 2020-04-19 at 16:01 +0100, [email protected] wrote:

From: Jonathan Cameron <[email protected]>

Hi All,

Given we keep having to explain to people that of_match_ptr is less than ideal now we have the option of ACPI DSDT using PRP0001 and the compatible, it seems sensible to reduce the number of instances that people might copy for a new driver.

Added theoretical benefit is that we can probe all these drivers from appropriate DSDT (though I doubt anyone will).

I'm sending this first set out to see if anyone has strong views against doing this for at least the simple drivers that have no other device tree dependence. Obviously more work would be needed to remove use of of_match_ptr from IIO completely.

Quoted 4 lines

Light sensors picked as a starting point as they tend to be simple.

I may do follow ups in larger blocks to avoid so many small patches (or indeed flatten these into one when applying)

fwiw: i was also planning to do a sweep of these;
well, tbh, the main intent was to target ADI drivers first and do a bigger conversion for them to make the slightly friendlier with ACPI;

aside from this, i'm also noticing some bad patterns being copied from older drivers, when asking new people to write Linux drivers;
i did not make a list, probably should have;
one is 'mlock' [still] being copied; and accessing other internal fields; but the internal fields accessing requires a bit of a cleanup in the form of privatizing the fields somehow;

Quoted 28 lines

Thanks

Jonathan

Jonathan Cameron (7):
iio: light: bh1780: use mod_devicetable.h and drop of_match_ptr macro
iio: light: cm32181: Add mod_devicetable.h and remove of_match_ptr
iio: light: cm3232: Add mod_devicetable.h include and drop
of_match_ptr
iio: light: gp2ap020a00f: Swap of.h for mod_devicetable.h + drop
of_match_ptr
iio: light: opt3001: Add mod_devicetable.h and drop use of
of_match_ptr
iio: light: st_uvis25: Add mod_devicetable.h and drop of_match_ptr
iio: light: vl6180: swap of.h for mod_devicetable.h and drop
of_match_ptr

 drivers/iio/light/bh1780.c        | 6 ++----
 drivers/iio/light/cm32181.c       | 3 ++-
 drivers/iio/light/cm3232.c        | 3 ++-
 drivers/iio/light/gp2ap020a00f.c  | 6 ++----
 drivers/iio/light/opt3001.c       | 3 ++-
 drivers/iio/light/st_uvis25_i2c.c | 3 ++-
 drivers/iio/light/st_uvis25_spi.c | 3 ++-
 drivers/iio/light/vl6180.c        | 2 +-
 8 files changed, 15 insertions(+), 14 deletions(-)
#18 lore raw
Quoted 29 lines · Alexandru

[External]

Quoted 17 lines · On Sun, 2020-04-19 at 16:01 +0100, [email protected] wrote:

From: Jonathan Cameron <[email protected]>

Hi All,

Given we keep having to explain to people that of_match_ptr is less than ideal now we have the option of ACPI DSDT using PRP0001 and the compatible, it seems sensible to reduce the number of instances that people might copy for a new driver.

Added theoretical benefit is that we can probe all these drivers from appropriate DSDT (though I doubt anyone will).

I'm sending this first set out to see if anyone has strong views against doing this for at least the simple drivers that have no other device tree dependence. Obviously more work would be needed to remove use of of_match_ptr from IIO completely.

Quoted 4 lines

Light sensors picked as a starting point as they tend to be simple.

I may do follow ups in larger blocks to avoid so many small patches (or indeed flatten these into one when applying)

fwiw: i was also planning to do a sweep of these;
well, tbh, the main intent was to target ADI drivers first and do a bigger conversion for them to make the slightly friendlier with ACPI;

Quoted 7 lines

aside from this, i'm also noticing some bad patterns being copied from older drivers, when asking new people to write Linux drivers;
i did not make a list, probably should have;
one is 'mlock' [still] being copied; and accessing other internal fields; but the internal fields accessing requires a bit of a cleanup in the form of privatizing the fields somehow;

One thing I noticed in the series.
No idea if it is needed or not; a build would tell:
Is '#include <linux/mod_devicetable.h>' required for this change?
Most patches add it, but I don't feel it is needed; I could be wrong though.

What I noticed is that all 'linux/of.h' , 'linux/of_device.h' & 'linux/of_platform.h' include it.

Quoted 28 lines
Quoted 28 lines

Thanks

Jonathan

Jonathan Cameron (7):
iio: light: bh1780: use mod_devicetable.h and drop of_match_ptr macro
iio: light: cm32181: Add mod_devicetable.h and remove of_match_ptr
iio: light: cm3232: Add mod_devicetable.h include and drop
of_match_ptr
iio: light: gp2ap020a00f: Swap of.h for mod_devicetable.h + drop
of_match_ptr
iio: light: opt3001: Add mod_devicetable.h and drop use of
of_match_ptr
iio: light: st_uvis25: Add mod_devicetable.h and drop of_match_ptr
iio: light: vl6180: swap of.h for mod_devicetable.h and drop
of_match_ptr

 drivers/iio/light/bh1780.c        | 6 ++----
 drivers/iio/light/cm32181.c       | 3 ++-
 drivers/iio/light/cm3232.c        | 3 ++-
 drivers/iio/light/gp2ap020a00f.c  | 6 ++----
 drivers/iio/light/opt3001.c       | 3 ++-
 drivers/iio/light/st_uvis25_i2c.c | 3 ++-
 drivers/iio/light/st_uvis25_spi.c | 3 ++-
 drivers/iio/light/vl6180.c        | 2 +-
 8 files changed, 15 insertions(+), 14 deletions(-)
#19 lore raw
Quoted 38 lines · Alexandru
Quoted 29 lines · Alexandru

[External]

Quoted 17 lines · On Sun, 2020-04-19 at 16:01 +0100, [email protected] wrote:

From: Jonathan Cameron <[email protected]>

Hi All,

Given we keep having to explain to people that of_match_ptr is less than ideal now we have the option of ACPI DSDT using PRP0001 and the compatible, it seems sensible to reduce the number of instances that people might copy for a new driver.

Added theoretical benefit is that we can probe all these drivers from appropriate DSDT (though I doubt anyone will).

I'm sending this first set out to see if anyone has strong views against doing this for at least the simple drivers that have no other device tree dependence. Obviously more work would be needed to remove use of of_match_ptr from IIO completely.

Quoted 4 lines

Light sensors picked as a starting point as they tend to be simple.

I may do follow ups in larger blocks to avoid so many small patches (or indeed flatten these into one when applying)

fwiw: i was also planning to do a sweep of these;
well, tbh, the main intent was to target ADI drivers first and do a bigger conversion for them to make the slightly friendlier with ACPI;

Quoted 7 lines

aside from this, i'm also noticing some bad patterns being copied from older drivers, when asking new people to write Linux drivers;
i did not make a list, probably should have;
one is 'mlock' [still] being copied; and accessing other internal fields; but the internal fields accessing requires a bit of a cleanup in the form of privatizing the fields somehow;

Quoted 4 lines

One thing I noticed in the series.
No idea if it is needed or not; a build would tell:
Is '#include <linux/mod_devicetable.h>' required for this change?
Most patches add it, but I don't feel it is needed; I could be wrong though.

I addressed this in reply to patch 7. It's mainly obtained via i2c.h and spi.h in these drivers. They don't have any particular need to include it as they could deal with an opaque pointer.

However, seems unlikely that'll get tidied up any time soon and debatable whether there is any point in doing so.

Quoted 3 lines

What I noticed is that all 'linux/of.h' , 'linux/of_device.h' & 'linux/of_platform.h' include it.

True, but we shouldn't include any of them unless we have reason to do so. They bring baggage we don't need for these drivers.

Jonathan

Quoted 29 lines
Quoted 29 lines
Quoted 29 lines

Thanks

Jonathan

Jonathan Cameron (7):
iio: light: bh1780: use mod_devicetable.h and drop of_match_ptr macro
iio: light: cm32181: Add mod_devicetable.h and remove of_match_ptr
iio: light: cm3232: Add mod_devicetable.h include and drop
of_match_ptr
iio: light: gp2ap020a00f: Swap of.h for mod_devicetable.h + drop
of_match_ptr
iio: light: opt3001: Add mod_devicetable.h and drop use of
of_match_ptr
iio: light: st_uvis25: Add mod_devicetable.h and drop of_match_ptr
iio: light: vl6180: swap of.h for mod_devicetable.h and drop
of_match_ptr

 drivers/iio/light/bh1780.c        | 6 ++----
 drivers/iio/light/cm32181.c       | 3 ++-
 drivers/iio/light/cm3232.c        | 3 ++-
 drivers/iio/light/gp2ap020a00f.c  | 6 ++----
 drivers/iio/light/opt3001.c       | 3 ++-
 drivers/iio/light/st_uvis25_i2c.c | 3 ++-
 drivers/iio/light/st_uvis25_spi.c | 3 ++-
 drivers/iio/light/vl6180.c        | 2 +-
 8 files changed, 15 insertions(+), 14 deletions(-)
#20 lore raw
Quoted 10 lines · Jonathan Cameron
Quoted 7 lines · Alexandru
Quoted 1 line · Alexandru

On Sun, 2020-04-19 at 16:01 +0100, [email protected] wrote:

One thing I noticed in the series.
No idea if it is needed or not; a build would tell:
Is '#include <linux/mod_devicetable.h>' required for this change?
Most patches add it, but I don't feel it is needed; I could be wrong though.

Quoted 6 lines

I addressed this in reply to patch 7. It's mainly obtained via i2c.h and spi.h in these drivers. They don't have any particular need to include it as they could deal with an opaque pointer.

However, seems unlikely that'll get tidied up any time soon and debatable whether there is any point in doing so.

I would use the simple rule, we include header if we have direct user of it.

Quoted 5 lines
Quoted 2 lines

What I noticed is that all 'linux/of.h' , 'linux/of_device.h' & 'linux/of_platform.h' include it.

True, but we shouldn't include any of them unless we have reason to do so. They bring baggage we don't need for these drivers.

--
With Best Regards,
Andy Shevchenko

author maintainer
#21 lore raw
Quoted 12 lines · On Tue, 21 Apr 2020 03:50:57 +0300 Andy Shevchenko <[email protected]>…
Quoted 10 lines · Jonathan Cameron
Quoted 7 lines · Alexandru
Quoted 1 line · Alexandru

On Sun, 2020-04-19 at 16:01 +0100, [email protected] wrote:

One thing I noticed in the series.
No idea if it is needed or not; a build would tell:
Is '#include <linux/mod_devicetable.h>' required for this change?
Most patches add it, but I don't feel it is needed; I could be wrong though.

Quoted 8 lines
Quoted 6 lines

I addressed this in reply to patch 7. It's mainly obtained via i2c.h and spi.h in these drivers. They don't have any particular need to include it as they could deal with an opaque pointer.

However, seems unlikely that'll get tidied up any time soon and debatable whether there is any point in doing so.

I would use the simple rule, we include header if we have direct user of it.

Sensible and easy to understand basis to make the decision. Let's go with that (though I don't want to see lots of isolated 'fixes' for 'missing' headers!)

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

What I noticed is that all 'linux/of.h' , 'linux/of_device.h' & 'linux/of_platform.h' include it.

True, but we shouldn't include any of them unless we have reason to do so. They bring baggage we don't need for these drivers.

All applied with patch 7 amended to add the include.

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

Thanks,

Jonathan

Quoted 5 lines

--
With Best Regards,
Andy Shevchenko