2020-04-24 22:46:39

by Nishant Malpani

[permalink] [raw]
Subject: [PATCH 0/3] iio: accel: Abandon of_match_ptr macro

This patchset extends Jonathan's and Alexandru's work [1] on removing the instances of
of_match_ptr macro. Motivation to do so is two-fold:
1. to have an option of probing from ACPI using PRP0001
2. prevent people from copying to new driver code

[1] https://patchwork.kernel.org/cover/11497535/

Nishant Malpani (3):
iio: accel: dmard06: Use mod_devicetable.h and drop of_match_ptr macro
iio: accel: kxsd9-i2c: Use mod_devicetable.h and drop of_match_ptr
macro
iio: accel: mma8452: Drop of_match_ptr macro

drivers/iio/accel/dmard06.c | 3 ++-
drivers/iio/accel/kxsd9-i2c.c | 7 ++-----
drivers/iio/accel/mma8452.c | 2 +-
3 files changed, 5 insertions(+), 7 deletions(-)

--
2.20.1


2020-04-24 22:47:04

by Nishant Malpani

[permalink] [raw]
Subject: [PATCH 2/3] iio: accel: kxsd9-i2c: Use mod_devicetable.h and drop of_match_ptr macro

Enables ACPI DSDT to probe via PRP0001 and the compatible property. Also
removes the ifdef protections for CONFIG_OF.

Signed-off-by: Nishant Malpani <[email protected]>
---
drivers/iio/accel/kxsd9-i2c.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/accel/kxsd9-i2c.c b/drivers/iio/accel/kxsd9-i2c.c
index b6f3de7ef8ea..b580d605f848 100644
--- a/drivers/iio/accel/kxsd9-i2c.c
+++ b/drivers/iio/accel/kxsd9-i2c.c
@@ -2,6 +2,7 @@
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/mod_devicetable.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/delay.h>
@@ -36,15 +37,11 @@ static int kxsd9_i2c_remove(struct i2c_client *client)
return kxsd9_common_remove(&client->dev);
}

-#ifdef CONFIG_OF
static const struct of_device_id kxsd9_of_match[] = {
{ .compatible = "kionix,kxsd9", },
{ },
};
MODULE_DEVICE_TABLE(of, kxsd9_of_match);
-#else
-#define kxsd9_of_match NULL
-#endif

static const struct i2c_device_id kxsd9_i2c_id[] = {
{"kxsd9", 0},
@@ -55,7 +52,7 @@ MODULE_DEVICE_TABLE(i2c, kxsd9_i2c_id);
static struct i2c_driver kxsd9_i2c_driver = {
.driver = {
.name = "kxsd9",
- .of_match_table = of_match_ptr(kxsd9_of_match),
+ .of_match_table = kxsd9_of_match,
.pm = &kxsd9_dev_pm_ops,
},
.probe = kxsd9_i2c_probe,
--
2.20.1

2020-04-24 22:47:18

by Nishant Malpani

[permalink] [raw]
Subject: [PATCH 3/3] iio: accel: mma8452: Drop of_match_ptr macro

Enables ACPI DSDT to probe via PRP0001 and the compatible property.

Signed-off-by: Nishant Malpani <[email protected]>
---
drivers/iio/accel/mma8452.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index 00e100fc845a..66217fbcc7af 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -1815,7 +1815,7 @@ MODULE_DEVICE_TABLE(i2c, mma8452_id);
static struct i2c_driver mma8452_driver = {
.driver = {
.name = "mma8452",
- .of_match_table = of_match_ptr(mma8452_dt_ids),
+ .of_match_table = mma8452_dt_ids,
.pm = &mma8452_pm_ops,
},
.probe = mma8452_probe,
--
2.20.1

2020-04-24 22:49:02

by Nishant Malpani

[permalink] [raw]
Subject: [PATCH 1/3] iio: accel: dmard06: Use mod_devicetable.h and drop of_match_ptr macro

Enables ACPI DSDT to probe via PRP0001 and the compatible property.

Signed-off-by: Nishant Malpani <[email protected]>
---
drivers/iio/accel/dmard06.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/accel/dmard06.c b/drivers/iio/accel/dmard06.c
index 2bf210fa4ba6..ef89bded7390 100644
--- a/drivers/iio/accel/dmard06.c
+++ b/drivers/iio/accel/dmard06.c
@@ -6,6 +6,7 @@
*/

#include <linux/module.h>
+#include <linux/mod_devicetable.h>
#include <linux/i2c.h>
#include <linux/iio/iio.h>

@@ -226,7 +227,7 @@ static struct i2c_driver dmard06_driver = {
.id_table = dmard06_id,
.driver = {
.name = DMARD06_DRV_NAME,
- .of_match_table = of_match_ptr(dmard06_of_match),
+ .of_match_table = dmard06_of_match,
.pm = DMARD06_PM_OPS,
},
};
--
2.20.1

2020-04-25 14:37:41

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH 3/3] iio: accel: mma8452: Drop of_match_ptr macro

On Sat, 25 Apr 2020 04:14:39 +0530
Nishant Malpani <[email protected]> wrote:

> Enables ACPI DSDT to probe via PRP0001 and the compatible property.
>
> Signed-off-by: Nishant Malpani <[email protected]>

No on this one. There is a whole load of device tree specific code in
the driver. Now that could be moved over to the device properties
approach but that's a much less trivial job. Its probably too major
to do without someone giving a tested-by, or whoever does it
having the device to test - or setting up emulation to check
everything works as expected before and after the change.

So far I've been restricting this tidying up to the drivers that are
really simple to review (no other device tree functions called).

Jonathan

> ---
> drivers/iio/accel/mma8452.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
> index 00e100fc845a..66217fbcc7af 100644
> --- a/drivers/iio/accel/mma8452.c
> +++ b/drivers/iio/accel/mma8452.c
> @@ -1815,7 +1815,7 @@ MODULE_DEVICE_TABLE(i2c, mma8452_id);
> static struct i2c_driver mma8452_driver = {
> .driver = {
> .name = "mma8452",
> - .of_match_table = of_match_ptr(mma8452_dt_ids),
> + .of_match_table = mma8452_dt_ids,
> .pm = &mma8452_pm_ops,
> },
> .probe = mma8452_probe,

2020-04-25 14:38:07

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH 1/3] iio: accel: dmard06: Use mod_devicetable.h and drop of_match_ptr macro

On Sat, 25 Apr 2020 04:14:37 +0530
Nishant Malpani <[email protected]> wrote:

> Enables ACPI DSDT to probe via PRP0001 and the compatible property.
>
> Signed-off-by: Nishant Malpani <[email protected]>

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

Thanks,

Jonathan

> ---
> drivers/iio/accel/dmard06.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/accel/dmard06.c b/drivers/iio/accel/dmard06.c
> index 2bf210fa4ba6..ef89bded7390 100644
> --- a/drivers/iio/accel/dmard06.c
> +++ b/drivers/iio/accel/dmard06.c
> @@ -6,6 +6,7 @@
> */
>
> #include <linux/module.h>
> +#include <linux/mod_devicetable.h>
> #include <linux/i2c.h>
> #include <linux/iio/iio.h>
>
> @@ -226,7 +227,7 @@ static struct i2c_driver dmard06_driver = {
> .id_table = dmard06_id,
> .driver = {
> .name = DMARD06_DRV_NAME,
> - .of_match_table = of_match_ptr(dmard06_of_match),
> + .of_match_table = dmard06_of_match,
> .pm = DMARD06_PM_OPS,
> },
> };

2020-04-25 14:38:49

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH 2/3] iio: accel: kxsd9-i2c: Use mod_devicetable.h and drop of_match_ptr macro

On Sat, 25 Apr 2020 04:14:38 +0530
Nishant Malpani <[email protected]> wrote:

> Enables ACPI DSDT to probe via PRP0001 and the compatible property. Also
> removes the ifdef protections for CONFIG_OF.
>
> Signed-off-by: Nishant Malpani <[email protected]>

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

Thanks,

Jonathan

> ---
> drivers/iio/accel/kxsd9-i2c.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iio/accel/kxsd9-i2c.c b/drivers/iio/accel/kxsd9-i2c.c
> index b6f3de7ef8ea..b580d605f848 100644
> --- a/drivers/iio/accel/kxsd9-i2c.c
> +++ b/drivers/iio/accel/kxsd9-i2c.c
> @@ -2,6 +2,7 @@
> #include <linux/device.h>
> #include <linux/kernel.h>
> #include <linux/module.h>
> +#include <linux/mod_devicetable.h>
> #include <linux/slab.h>
> #include <linux/i2c.h>
> #include <linux/delay.h>
> @@ -36,15 +37,11 @@ static int kxsd9_i2c_remove(struct i2c_client *client)
> return kxsd9_common_remove(&client->dev);
> }
>
> -#ifdef CONFIG_OF
> static const struct of_device_id kxsd9_of_match[] = {
> { .compatible = "kionix,kxsd9", },
> { },
> };
> MODULE_DEVICE_TABLE(of, kxsd9_of_match);
> -#else
> -#define kxsd9_of_match NULL
> -#endif
>
> static const struct i2c_device_id kxsd9_i2c_id[] = {
> {"kxsd9", 0},
> @@ -55,7 +52,7 @@ MODULE_DEVICE_TABLE(i2c, kxsd9_i2c_id);
> static struct i2c_driver kxsd9_i2c_driver = {
> .driver = {
> .name = "kxsd9",
> - .of_match_table = of_match_ptr(kxsd9_of_match),
> + .of_match_table = kxsd9_of_match,
> .pm = &kxsd9_dev_pm_ops,
> },
> .probe = kxsd9_i2c_probe,