2018-10-26 13:26:07

by Nishad Kamdar

[permalink] [raw]
Subject: [PATCH v5 0/2] staging: iio: ad2s1210: Switch to the gpio descriptor interface.

Use the gpiod interface instead of the deprecated old non-descriptor

Changes in v5:
- Add device tree support.
- Add device tree table for matching vendor ID.
- Add Support for retrieving platform data from device tree.
Changes in v4:
- Add spaces after { and before } in gpios[]
initialization.
- Check the correct pointer for error.
- Align the dev_err msg to existing format in the code.
Changes in v3:
- Use a pointer to pointer for gpio_desc in
struct ad2s1210_gpio as it will be used to
modify a pointer.
- Use dot notation to initialize the structure.
- Use a pointer variable to avoid writing gpios[i].
Changes in v2:
- Use the spi_device struct embedded in st instead
of passing it as an argument to ad2s1210_setup_gpios().
- Use an array of structs to reduce redundant code in
in ad2s1210_setup_gpios().
- Remove ad2s1210_free_gpios() as devm API is being used.
-
Nishad Kamdar (2):
staging: iio: ad2s1210: Switch to the gpio descriptor interface
staging: iio: ad2s1210: Add device tree support.

drivers/staging/iio/resolver/ad2s1210.c | 129 ++++++++++++++++--------
drivers/staging/iio/resolver/ad2s1210.h | 3 -
2 files changed, 89 insertions(+), 43 deletions(-)

--
2.17.1



2018-10-26 13:26:38

by Nishad Kamdar

[permalink] [raw]
Subject: [PATCH v5 2/2] staging: iio: ad2s1210: Add device tree support.

Add device tree table for matching vendor ID
and support for retrieving platform data
from device tree.

Signed-off-by: Nishad Kamdar <[email protected]>
---
drivers/staging/iio/resolver/ad2s1210.c | 43 ++++++++++++++++++++++++-
1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c
index 93c3c70ce62e..9fd5461c4ed0 100644
--- a/drivers/staging/iio/resolver/ad2s1210.c
+++ b/drivers/staging/iio/resolver/ad2s1210.c
@@ -17,6 +17,7 @@
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
+#include <linux/of.h>

#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
@@ -669,6 +670,27 @@ static int ad2s1210_setup_gpios(struct ad2s1210_state *st)
return 0;
}

+#ifdef CONFIG_OF
+static struct ad2s1210_platform_data *ad2s1210_parse_dt(struct device *dev)
+{
+ struct device_node *np = dev->of_node;
+ struct ad2s1210_platform_data *pdata;
+
+ pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+ if (!pdata)
+ return NULL;
+
+ pdata->gpioin = of_property_read_bool(np, "adi,gpioin");
+
+ return pdata;
+}
+#else
+static struct ad2s1210_platform_data *ad2s1210_parse_dt(struct device *dev)
+{
+ return NULL;
+}
+#endif
+
static int ad2s1210_probe(struct spi_device *spi)
{
struct iio_dev *indio_dev;
@@ -682,7 +704,19 @@ static int ad2s1210_probe(struct spi_device *spi)
if (!indio_dev)
return -ENOMEM;
st = iio_priv(indio_dev);
- st->pdata = spi->dev.platform_data;
+ if (spi->dev.of_node) {
+ st->pdata = ad2s1210_parse_dt(&spi->dev);
+ if (!st->pdata)
+ return -EINVAL;
+ } else {
+ st->pdata = spi->dev.platform_data;
+ }
+
+ if (!st->pdata) {
+ dev_err(&spi->dev, "ad2s1210: no platform data supplied\n");
+ return -EINVAL;
+ }
+
ret = ad2s1210_setup_gpios(st);
if (ret < 0)
return ret;
@@ -724,6 +758,12 @@ static int ad2s1210_remove(struct spi_device *spi)
return 0;
}

+static const struct of_device_id ad2s1210_of_match[] = {
+ { .compatible = "adi,ad2s1210", },
+ { }
+};
+MODULE_DEVICE_TABLE(of, ad2s1210_of_match);
+
static const struct spi_device_id ad2s1210_id[] = {
{ "ad2s1210" },
{}
@@ -733,6 +773,7 @@ MODULE_DEVICE_TABLE(spi, ad2s1210_id);
static struct spi_driver ad2s1210_driver = {
.driver = {
.name = DRV_NAME,
+ .of_match_table = of_match_ptr(ad2s1210_of_match),
},
.probe = ad2s1210_probe,
.remove = ad2s1210_remove,
--
2.17.1


2018-10-26 13:27:11

by Nishad Kamdar

[permalink] [raw]
Subject: [PATCH v5 1/2] staging: iio: ad2s1210: Switch to the gpio descriptor interface

Use the gpiod interface instead of the deprecated old non-descriptor
interface.

Signed-off-by: Nishad Kamdar <[email protected]>
---
Changes in v4:
- Add spaces after { and before } in gpios[]
initialization.
- Check the correct pointer for error.
- Align the dev_err msg to existing format in the code.
Changes in v3:
- Use a pointer to pointer for gpio_desc in
struct ad2s1210_gpio as it will be used to
modify a pointer.
- Use dot notation to initialize the structure.
- Use a pointer variable to avoid writing gpios[i].
Changes in v2:
- Use the spi_device struct embedded in st instead
of passing it as an argument to ad2s1210_setup_gpios().
- Use an array of structs to reduce redundant code in
in ad2s1210_setup_gpios().
- Remove ad2s1210_free_gpios() as devm API is being used.
---
drivers/staging/iio/resolver/ad2s1210.c | 92 ++++++++++++++-----------
drivers/staging/iio/resolver/ad2s1210.h | 3 -
2 files changed, 50 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c
index ac13b99bd9cb..93c3c70ce62e 100644
--- a/drivers/staging/iio/resolver/ad2s1210.c
+++ b/drivers/staging/iio/resolver/ad2s1210.c
@@ -15,7 +15,7 @@
#include <linux/slab.h>
#include <linux/sysfs.h>
#include <linux/delay.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/module.h>

#include <linux/iio/iio.h>
@@ -69,10 +69,21 @@ enum ad2s1210_mode {

static const unsigned int ad2s1210_resolution_value[] = { 10, 12, 14, 16 };

+struct ad2s1210_gpio {
+ struct gpio_desc **ptr;
+ const char *name;
+ unsigned long flags;
+};
+
struct ad2s1210_state {
const struct ad2s1210_platform_data *pdata;
struct mutex lock;
struct spi_device *sdev;
+ struct gpio_desc *sample;
+ struct gpio_desc *a0;
+ struct gpio_desc *a1;
+ struct gpio_desc *res0;
+ struct gpio_desc *res1;
unsigned int fclkin;
unsigned int fexcit;
bool hysteresis;
@@ -91,8 +102,8 @@ static const int ad2s1210_mode_vals[4][2] = {
static inline void ad2s1210_set_mode(enum ad2s1210_mode mode,
struct ad2s1210_state *st)
{
- gpio_set_value(st->pdata->a[0], ad2s1210_mode_vals[mode][0]);
- gpio_set_value(st->pdata->a[1], ad2s1210_mode_vals[mode][1]);
+ gpiod_set_value(st->a0, ad2s1210_mode_vals[mode][0]);
+ gpiod_set_value(st->a1, ad2s1210_mode_vals[mode][1]);
st->mode = mode;
}

@@ -152,8 +163,8 @@ int ad2s1210_update_frequency_control_word(struct ad2s1210_state *st)

static unsigned char ad2s1210_read_resolution_pin(struct ad2s1210_state *st)
{
- int resolution = (gpio_get_value(st->pdata->res[0]) << 1) |
- gpio_get_value(st->pdata->res[1]);
+ int resolution = (gpiod_get_value(st->res0) << 1) |
+ gpiod_get_value(st->res1);

return ad2s1210_resolution_value[resolution];
}
@@ -164,10 +175,10 @@ static const int ad2s1210_res_pins[4][2] = {

static inline void ad2s1210_set_resolution_pin(struct ad2s1210_state *st)
{
- gpio_set_value(st->pdata->res[0],
- ad2s1210_res_pins[(st->resolution - 10) / 2][0]);
- gpio_set_value(st->pdata->res[1],
- ad2s1210_res_pins[(st->resolution - 10) / 2][1]);
+ gpiod_set_value(st->res0,
+ ad2s1210_res_pins[(st->resolution - 10) / 2][0]);
+ gpiod_set_value(st->res1,
+ ad2s1210_res_pins[(st->resolution - 10) / 2][1]);
}

static inline int ad2s1210_soft_reset(struct ad2s1210_state *st)
@@ -401,15 +412,15 @@ static ssize_t ad2s1210_clear_fault(struct device *dev,
int ret;

mutex_lock(&st->lock);
- gpio_set_value(st->pdata->sample, 0);
+ gpiod_set_value(st->sample, 0);
/* delay (2 * tck + 20) nano seconds */
udelay(1);
- gpio_set_value(st->pdata->sample, 1);
+ gpiod_set_value(st->sample, 1);
ret = ad2s1210_config_read(st, AD2S1210_REG_FAULT);
if (ret < 0)
goto error_ret;
- gpio_set_value(st->pdata->sample, 0);
- gpio_set_value(st->pdata->sample, 1);
+ gpiod_set_value(st->sample, 0);
+ gpiod_set_value(st->sample, 1);
error_ret:
mutex_unlock(&st->lock);

@@ -466,7 +477,7 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev,
s16 vel;

mutex_lock(&st->lock);
- gpio_set_value(st->pdata->sample, 0);
+ gpiod_set_value(st->sample, 0);
/* delay (6 * tck + 20) nano seconds */
udelay(1);

@@ -512,7 +523,7 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev,
}

error_ret:
- gpio_set_value(st->pdata->sample, 1);
+ gpiod_set_value(st->sample, 1);
/* delay (2 * tck + 20) nano seconds */
udelay(1);
mutex_unlock(&st->lock);
@@ -630,30 +641,32 @@ static const struct iio_info ad2s1210_info = {

static int ad2s1210_setup_gpios(struct ad2s1210_state *st)
{
- unsigned long flags = st->pdata->gpioin ? GPIOF_DIR_IN : GPIOF_DIR_OUT;
- struct gpio ad2s1210_gpios[] = {
- { st->pdata->sample, GPIOF_DIR_IN, "sample" },
- { st->pdata->a[0], flags, "a0" },
- { st->pdata->a[1], flags, "a1" },
- { st->pdata->res[0], flags, "res0" },
- { st->pdata->res[0], flags, "res1" },
+ int ret, i;
+ struct spi_device *spi = st->sdev;
+ struct ad2s1210_gpio *pin;
+ unsigned long flags = st->pdata->gpioin ? GPIOD_IN : GPIOD_OUT_LOW;
+
+ struct ad2s1210_gpio gpios[] = {
+ { .ptr = &st->sample, .name = "sample", .flags = GPIOD_IN },
+ { .ptr = &st->a0, .name = "a0", .flags = flags },
+ { .ptr = &st->a1, .name = "a1", .flags = flags },
+ { .ptr = &st->res0, .name = "res0", .flags = flags },
+ { .ptr = &st->res1, .name = "res1", .flags = flags },
};

- return gpio_request_array(ad2s1210_gpios, ARRAY_SIZE(ad2s1210_gpios));
-}
-
-static void ad2s1210_free_gpios(struct ad2s1210_state *st)
-{
- unsigned long flags = st->pdata->gpioin ? GPIOF_DIR_IN : GPIOF_DIR_OUT;
- struct gpio ad2s1210_gpios[] = {
- { st->pdata->sample, GPIOF_DIR_IN, "sample" },
- { st->pdata->a[0], flags, "a0" },
- { st->pdata->a[1], flags, "a1" },
- { st->pdata->res[0], flags, "res0" },
- { st->pdata->res[0], flags, "res1" },
- };
+ for (i = 0; i < ARRAY_SIZE(gpios); i++) {
+ pin = &gpios[i];
+ *pin->ptr = devm_gpiod_get(&spi->dev, pin->name, pin->flags);
+ if (IS_ERR(*pin->ptr)) {
+ ret = PTR_ERR(*pin->ptr);
+ dev_err(&spi->dev,
+ "ad2s1210: failed to request %s GPIO: %d\n",
+ pin->name, ret);
+ return ret;
+ }
+ }

- gpio_free_array(ad2s1210_gpios, ARRAY_SIZE(ad2s1210_gpios));
+ return 0;
}

static int ad2s1210_probe(struct spi_device *spi)
@@ -692,7 +705,7 @@ static int ad2s1210_probe(struct spi_device *spi)

ret = iio_device_register(indio_dev);
if (ret)
- goto error_free_gpios;
+ return ret;

st->fclkin = spi->max_speed_hz;
spi->mode = SPI_MODE_3;
@@ -700,10 +713,6 @@ static int ad2s1210_probe(struct spi_device *spi)
ad2s1210_initial(st);

return 0;
-
-error_free_gpios:
- ad2s1210_free_gpios(st);
- return ret;
}

static int ad2s1210_remove(struct spi_device *spi)
@@ -711,7 +720,6 @@ static int ad2s1210_remove(struct spi_device *spi)
struct iio_dev *indio_dev = spi_get_drvdata(spi);

iio_device_unregister(indio_dev);
- ad2s1210_free_gpios(iio_priv(indio_dev));

return 0;
}
diff --git a/drivers/staging/iio/resolver/ad2s1210.h b/drivers/staging/iio/resolver/ad2s1210.h
index e9b2147701fc..63d479b20a6c 100644
--- a/drivers/staging/iio/resolver/ad2s1210.h
+++ b/drivers/staging/iio/resolver/ad2s1210.h
@@ -12,9 +12,6 @@
#define _AD2S1210_H

struct ad2s1210_platform_data {
- unsigned int sample;
- unsigned int a[2];
- unsigned int res[2];
bool gpioin;
};
#endif /* _AD2S1210_H */
--
2.17.1


2018-10-27 15:49:34

by Slawomir Stepien

[permalink] [raw]
Subject: Re: [PATCH v5 2/2] staging: iio: ad2s1210: Add device tree support.

Hi

On paź 26, 2018 18:55, Nishad Kamdar wrote:
> Add device tree table for matching vendor ID
> and support for retrieving platform data
> from device tree.

So maybe you should make 2 commits?

> Signed-off-by: Nishad Kamdar <[email protected]>
> ---
> drivers/staging/iio/resolver/ad2s1210.c | 43 ++++++++++++++++++++++++-
> 1 file changed, 42 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c
> index 93c3c70ce62e..9fd5461c4ed0 100644
> --- a/drivers/staging/iio/resolver/ad2s1210.c
> +++ b/drivers/staging/iio/resolver/ad2s1210.c
> @@ -17,6 +17,7 @@
> #include <linux/delay.h>
> #include <linux/gpio/consumer.h>
> #include <linux/module.h>
> +#include <linux/of.h>
>
> #include <linux/iio/iio.h>
> #include <linux/iio/sysfs.h>
> @@ -669,6 +670,27 @@ static int ad2s1210_setup_gpios(struct ad2s1210_state *st)
> return 0;
> }
>
> +#ifdef CONFIG_OF
> +static struct ad2s1210_platform_data *ad2s1210_parse_dt(struct device *dev)
> +{
> + struct device_node *np = dev->of_node;
> + struct ad2s1210_platform_data *pdata;
> +
> + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> + if (!pdata)
> + return NULL;
> +
> + pdata->gpioin = of_property_read_bool(np, "adi,gpioin");

Why here you are adding "adi", but you are not adding it to the gpios in prev
commit?

I've also seen this: https://patchwork.kernel.org/patch/10355839/. However I do
not understand why adding vendor id to props is needed...

> +
> + return pdata;
> +}
> +#else
> +static struct ad2s1210_platform_data *ad2s1210_parse_dt(struct device *dev)
> +{
> + return NULL;
> +}
> +#endif
> +
> static int ad2s1210_probe(struct spi_device *spi)
> {
> struct iio_dev *indio_dev;
> @@ -682,7 +704,19 @@ static int ad2s1210_probe(struct spi_device *spi)
> if (!indio_dev)
> return -ENOMEM;
> st = iio_priv(indio_dev);
> - st->pdata = spi->dev.platform_data;
> + if (spi->dev.of_node) {
> + st->pdata = ad2s1210_parse_dt(&spi->dev);
> + if (!st->pdata)
> + return -EINVAL;
> + } else {
> + st->pdata = spi->dev.platform_data;
> + }
> +
> + if (!st->pdata) {
> + dev_err(&spi->dev, "ad2s1210: no platform data supplied\n");
> + return -EINVAL;
> + }
> +

Why not just use only device-tree here? The ad2s1210_platform_data has now only
one entry... In that case remember to add "depends on OF" in Kconfig.

> ret = ad2s1210_setup_gpios(st);
> if (ret < 0)
> return ret;
> @@ -724,6 +758,12 @@ static int ad2s1210_remove(struct spi_device *spi)
> return 0;
> }
>
> +static const struct of_device_id ad2s1210_of_match[] = {
> + { .compatible = "adi,ad2s1210", },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, ad2s1210_of_match);
> +
> static const struct spi_device_id ad2s1210_id[] = {
> { "ad2s1210" },
> {}
> @@ -733,6 +773,7 @@ MODULE_DEVICE_TABLE(spi, ad2s1210_id);
> static struct spi_driver ad2s1210_driver = {
> .driver = {
> .name = DRV_NAME,
> + .of_match_table = of_match_ptr(ad2s1210_of_match),
> },
> .probe = ad2s1210_probe,
> .remove = ad2s1210_remove,

--
Slawomir Stepien

2018-10-28 06:14:37

by Nishad Kamdar

[permalink] [raw]
Subject: Re: [PATCH v5 2/2] staging: iio: ad2s1210: Add device tree support.

On Sat, Oct 27, 2018 at 05:49:03PM +0200, Slawomir Stepien wrote:
> Hi
>
> On paź 26, 2018 18:55, Nishad Kamdar wrote:
> > Add device tree table for matching vendor ID
> > and support for retrieving platform data
> > from device tree.
>
> So maybe you should make 2 commits?
>
Ok. I'll do that.
> > Signed-off-by: Nishad Kamdar <[email protected]>
> > ---
> > drivers/staging/iio/resolver/ad2s1210.c | 43 ++++++++++++++++++++++++-
> > 1 file changed, 42 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c
> > index 93c3c70ce62e..9fd5461c4ed0 100644
> > --- a/drivers/staging/iio/resolver/ad2s1210.c
> > +++ b/drivers/staging/iio/resolver/ad2s1210.c
> > @@ -17,6 +17,7 @@
> > #include <linux/delay.h>
> > #include <linux/gpio/consumer.h>
> > #include <linux/module.h>
> > +#include <linux/of.h>
> >
> > #include <linux/iio/iio.h>
> > #include <linux/iio/sysfs.h>
> > @@ -669,6 +670,27 @@ static int ad2s1210_setup_gpios(struct ad2s1210_state *st)
> > return 0;
> > }
> >
> > +#ifdef CONFIG_OF
> > +static struct ad2s1210_platform_data *ad2s1210_parse_dt(struct device *dev)
> > +{
> > + struct device_node *np = dev->of_node;
> > + struct ad2s1210_platform_data *pdata;
> > +
> > + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> > + if (!pdata)
> > + return NULL;
> > +
> > + pdata->gpioin = of_property_read_bool(np, "adi,gpioin");
>
> Why here you are adding "adi", but you are not adding it to the gpios in prev
> commit?
>
> I've also seen this: https://patchwork.kernel.org/patch/10355839/. However I do
> not understand why adding vendor id to props is needed...
>
> > +
> > + return pdata;
> > +}
> > +#else
> > +static struct ad2s1210_platform_data *ad2s1210_parse_dt(struct device *dev)
> > +{
> > + return NULL;
> > +}
> > +#endif
> > +
> > static int ad2s1210_probe(struct spi_device *spi)
> > {
> > struct iio_dev *indio_dev;
> > @@ -682,7 +704,19 @@ static int ad2s1210_probe(struct spi_device *spi)
> > if (!indio_dev)
> > return -ENOMEM;
> > st = iio_priv(indio_dev);
> > - st->pdata = spi->dev.platform_data;
> > + if (spi->dev.of_node) {
> > + st->pdata = ad2s1210_parse_dt(&spi->dev);
> > + if (!st->pdata)
> > + return -EINVAL;
> > + } else {
> > + st->pdata = spi->dev.platform_data;
> > + }
> > +
> > + if (!st->pdata) {
> > + dev_err(&spi->dev, "ad2s1210: no platform data supplied\n");
> > + return -EINVAL;
> > + }
> > +
>
> Why not just use only device-tree here? The ad2s1210_platform_data has now only
> one entry... In that case remember to add "depends on OF" in Kconfig.
>

Ok. I'll do that.
> > ret = ad2s1210_setup_gpios(st);
> > if (ret < 0)
> > return ret;
> > @@ -724,6 +758,12 @@ static int ad2s1210_remove(struct spi_device *spi)
> > return 0;
> > }
> >
> > +static const struct of_device_id ad2s1210_of_match[] = {
> > + { .compatible = "adi,ad2s1210", },
> > + { }
> > +};
> > +MODULE_DEVICE_TABLE(of, ad2s1210_of_match);
> > +
> > static const struct spi_device_id ad2s1210_id[] = {
> > { "ad2s1210" },
> > {}
> > @@ -733,6 +773,7 @@ MODULE_DEVICE_TABLE(spi, ad2s1210_id);
> > static struct spi_driver ad2s1210_driver = {
> > .driver = {
> > .name = DRV_NAME,
> > + .of_match_table = of_match_ptr(ad2s1210_of_match),
> > },
> > .probe = ad2s1210_probe,
> > .remove = ad2s1210_remove,
>
> --
> Slawomir Stepien

Thanks for the review.

Regards,
Nishad

2018-10-28 14:57:47

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH v5 2/2] staging: iio: ad2s1210: Add device tree support.

On Sat, 27 Oct 2018 17:49:03 +0200
Slawomir Stepien <[email protected]> wrote:

> Hi
>
> On paź 26, 2018 18:55, Nishad Kamdar wrote:
> > Add device tree table for matching vendor ID
> > and support for retrieving platform data
> > from device tree.
>
> So maybe you should make 2 commits?
>
> > Signed-off-by: Nishad Kamdar <[email protected]>
> > ---
> > drivers/staging/iio/resolver/ad2s1210.c | 43 ++++++++++++++++++++++++-
> > 1 file changed, 42 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c
> > index 93c3c70ce62e..9fd5461c4ed0 100644
> > --- a/drivers/staging/iio/resolver/ad2s1210.c
> > +++ b/drivers/staging/iio/resolver/ad2s1210.c
> > @@ -17,6 +17,7 @@
> > #include <linux/delay.h>
> > #include <linux/gpio/consumer.h>
> > #include <linux/module.h>
> > +#include <linux/of.h>
> >
> > #include <linux/iio/iio.h>
> > #include <linux/iio/sysfs.h>
> > @@ -669,6 +670,27 @@ static int ad2s1210_setup_gpios(struct ad2s1210_state *st)
> > return 0;
> > }
> >
> > +#ifdef CONFIG_OF
> > +static struct ad2s1210_platform_data *ad2s1210_parse_dt(struct device *dev)
> > +{
> > + struct device_node *np = dev->of_node;
> > + struct ad2s1210_platform_data *pdata;
> > +
> > + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> > + if (!pdata)
> > + return NULL;
> > +
> > + pdata->gpioin = of_property_read_bool(np, "adi,gpioin");
>
> Why here you are adding "adi", but you are not adding it to the gpios in prev
> commit?
>
> I've also seen this: https://patchwork.kernel.org/patch/10355839/. However I do
> not understand why adding vendor id to props is needed...
This is not standard ABI, hence we define it as being under the scope of
a particular manufacturer (and hope they use it consistently ;)

So this should have a the prefix, as should the gpios now you mention it.

We have gotten that bit wrong a lot in the past in IIO. If the gpio is
standard, i.e. reset or similar it doesn't need it, but for very much device
specific gpios like these it should have the prefix
(similar reasons to any other property - different manufacturers might
use the same name for different things).

Jonathan

>
> > +
> > + return pdata;
> > +}
> > +#else
> > +static struct ad2s1210_platform_data *ad2s1210_parse_dt(struct device *dev)
> > +{
> > + return NULL;
> > +}
> > +#endif
> > +
> > static int ad2s1210_probe(struct spi_device *spi)
> > {
> > struct iio_dev *indio_dev;
> > @@ -682,7 +704,19 @@ static int ad2s1210_probe(struct spi_device *spi)
> > if (!indio_dev)
> > return -ENOMEM;
> > st = iio_priv(indio_dev);
> > - st->pdata = spi->dev.platform_data;
> > + if (spi->dev.of_node) {
> > + st->pdata = ad2s1210_parse_dt(&spi->dev);
> > + if (!st->pdata)
> > + return -EINVAL;
> > + } else {
> > + st->pdata = spi->dev.platform_data;
> > + }
> > +
> > + if (!st->pdata) {
> > + dev_err(&spi->dev, "ad2s1210: no platform data supplied\n");
> > + return -EINVAL;
> > + }
> > +
>
> Why not just use only device-tree here? The ad2s1210_platform_data has now only
> one entry... In that case remember to add "depends on OF" in Kconfig.
>
> > ret = ad2s1210_setup_gpios(st);
> > if (ret < 0)
> > return ret;
> > @@ -724,6 +758,12 @@ static int ad2s1210_remove(struct spi_device *spi)
> > return 0;
> > }
> >
> > +static const struct of_device_id ad2s1210_of_match[] = {
> > + { .compatible = "adi,ad2s1210", },
> > + { }
> > +};
> > +MODULE_DEVICE_TABLE(of, ad2s1210_of_match);
> > +
> > static const struct spi_device_id ad2s1210_id[] = {
> > { "ad2s1210" },
> > {}
> > @@ -733,6 +773,7 @@ MODULE_DEVICE_TABLE(spi, ad2s1210_id);
> > static struct spi_driver ad2s1210_driver = {
> > .driver = {
> > .name = DRV_NAME,
> > + .of_match_table = of_match_ptr(ad2s1210_of_match),
> > },
> > .probe = ad2s1210_probe,
> > .remove = ad2s1210_remove,
>