2022-12-19 17:52:45

by Alexander Sverdlin

[permalink] [raw]
Subject: [PATCH v2 2/2] iio: adc: ep93xx: Add OF support

Prepare for EP93xx conversion to DT.

Signed-off-by: Alexander Sverdlin <[email protected]>
---
drivers/iio/adc/ep93xx_adc.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/drivers/iio/adc/ep93xx_adc.c b/drivers/iio/adc/ep93xx_adc.c
index fd5a9404c8dc..e530a37180e1 100644
--- a/drivers/iio/adc/ep93xx_adc.c
+++ b/drivers/iio/adc/ep93xx_adc.c
@@ -21,6 +21,7 @@
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/platform_device.h>
+#include <linux/of.h>

/*
* This code could benefit from real HR Timers, but jiffy granularity would
@@ -227,9 +228,18 @@ static int ep93xx_adc_remove(struct platform_device *pdev)
return 0;
}

+#ifdef CONFIG_OF
+static const struct of_device_id ep93xx_adc_of_ids[] = {
+ { .compatible = "cirrus,ep9301-adc" },
+ {},
+};
+MODULE_DEVICE_TABLE(of, ep93xx_adc_of_ids);
+#endif
+
static struct platform_driver ep93xx_adc_driver = {
.driver = {
.name = "ep93xx-adc",
+ .of_match_table = of_match_ptr(ep93xx_adc_of_ids),
},
.probe = ep93xx_adc_probe,
.remove = ep93xx_adc_remove,
--
2.39.0


2022-12-23 16:28:24

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] iio: adc: ep93xx: Add OF support

On Mon, 19 Dec 2022 18:36:18 +0100
Alexander Sverdlin <[email protected]> wrote:

> Prepare for EP93xx conversion to DT.
>
> Signed-off-by: Alexander Sverdlin <[email protected]>
Hi Alexander,

Comments inline,

Jonathan

> ---
> drivers/iio/adc/ep93xx_adc.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/iio/adc/ep93xx_adc.c b/drivers/iio/adc/ep93xx_adc.c
> index fd5a9404c8dc..e530a37180e1 100644
> --- a/drivers/iio/adc/ep93xx_adc.c
> +++ b/drivers/iio/adc/ep93xx_adc.c
> @@ -21,6 +21,7 @@
> #include <linux/module.h>
> #include <linux/mutex.h>
> #include <linux/platform_device.h>
> +#include <linux/of.h>
>
> /*
> * This code could benefit from real HR Timers, but jiffy granularity would
> @@ -227,9 +228,18 @@ static int ep93xx_adc_remove(struct platform_device *pdev)
> return 0;
> }
>
> +#ifdef CONFIG_OF
> +static const struct of_device_id ep93xx_adc_of_ids[] = {
> + { .compatible = "cirrus,ep9301-adc" },
> + {},

No comma needed for 'NULL' terminator of the array.

> +};
> +MODULE_DEVICE_TABLE(of, ep93xx_adc_of_ids);
> +#endif
> +
> static struct platform_driver ep93xx_adc_driver = {
> .driver = {
> .name = "ep93xx-adc",
> + .of_match_table = of_match_ptr(ep93xx_adc_of_ids),
drop the of_match_ptr() protection and the ifdefs.
They only save a tiny amount of space, and add complexity that outweighs it.
The other normal reason we don't like these is that there are ACPI paths
that use of_match_table and this breaks them. Not likely to be relevant
here though I guess.

Jonathan




> },
> .probe = ep93xx_adc_probe,
> .remove = ep93xx_adc_remove,