2022-08-22 13:16:34

by Ciprian Regus

[permalink] [raw]
Subject: [PATCH 3/3] drivers: iio: adc: Rename the LTC249x iio device

Set the iio device's name based on the chip used.

Signed-off-by: Ciprian Regus <[email protected]>
---
drivers/iio/adc/ltc2496.c | 1 +
drivers/iio/adc/ltc2497-core.c | 2 +-
drivers/iio/adc/ltc2497.c | 2 ++
drivers/iio/adc/ltc2497.h | 1 +
4 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ltc2496.c b/drivers/iio/adc/ltc2496.c
index 98338104c24a..86470f49e8ca 100644
--- a/drivers/iio/adc/ltc2496.c
+++ b/drivers/iio/adc/ltc2496.c
@@ -89,6 +89,7 @@ static void ltc2496_remove(struct spi_device *spi)

static struct chip_info ltc2496_info = {
.resolution = 16,
+ .name = "ltc2496"
};

static const struct of_device_id ltc2496_of_match[] = {
diff --git a/drivers/iio/adc/ltc2497-core.c b/drivers/iio/adc/ltc2497-core.c
index b2752399402c..6dd9ab601904 100644
--- a/drivers/iio/adc/ltc2497-core.c
+++ b/drivers/iio/adc/ltc2497-core.c
@@ -169,7 +169,7 @@ int ltc2497core_probe(struct device *dev, struct iio_dev *indio_dev)
struct ltc2497core_driverdata *ddata = iio_priv(indio_dev);
int ret;

- indio_dev->name = dev_name(dev);
+ indio_dev->name = ddata->chip_info->name;
indio_dev->info = &ltc2497core_info;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = ltc2497core_channel;
diff --git a/drivers/iio/adc/ltc2497.c b/drivers/iio/adc/ltc2497.c
index bb5e0d4301e2..a0aad71c8130 100644
--- a/drivers/iio/adc/ltc2497.c
+++ b/drivers/iio/adc/ltc2497.c
@@ -99,9 +99,11 @@ static int ltc2497_remove(struct i2c_client *client)
static struct chip_info ltc2497_info[] = {
[TYPE_LTC2497] = {
.resolution = 16,
+ .name = "ltc2497"
},
[TYPE_LTC2499] = {
.resolution = 24,
+ .name = "ltc2499"
}
};

diff --git a/drivers/iio/adc/ltc2497.h b/drivers/iio/adc/ltc2497.h
index f4d939cfd48b..0e86e38248ee 100644
--- a/drivers/iio/adc/ltc2497.h
+++ b/drivers/iio/adc/ltc2497.h
@@ -12,6 +12,7 @@ enum chip_type {

struct chip_info {
u32 resolution;
+ char *name;
};

struct ltc2497core_driverdata {
--
2.30.2


2022-08-22 14:30:42

by Lars-Peter Clausen

[permalink] [raw]
Subject: Re: [PATCH 3/3] drivers: iio: adc: Rename the LTC249x iio device

On 8/22/22 14:51, Ciprian Regus wrote:
> Set the iio device's name based on the chip used.

While the change is correct it breaks the ABI. This needs a bit of a
better explanation what is being done, why, what are the potential
problems, why do we want to do it anyway.

>
> Signed-off-by: Ciprian Regus <[email protected]>
> ---
> drivers/iio/adc/ltc2496.c | 1 +
> drivers/iio/adc/ltc2497-core.c | 2 +-
> drivers/iio/adc/ltc2497.c | 2 ++
> drivers/iio/adc/ltc2497.h | 1 +
> 4 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/ltc2496.c b/drivers/iio/adc/ltc2496.c
> index 98338104c24a..86470f49e8ca 100644
> --- a/drivers/iio/adc/ltc2496.c
> +++ b/drivers/iio/adc/ltc2496.c
> @@ -89,6 +89,7 @@ static void ltc2496_remove(struct spi_device *spi)
>
> static struct chip_info ltc2496_info = {
> .resolution = 16,
> + .name = "ltc2496"
> };
>
> static const struct of_device_id ltc2496_of_match[] = {
> diff --git a/drivers/iio/adc/ltc2497-core.c b/drivers/iio/adc/ltc2497-core.c
> index b2752399402c..6dd9ab601904 100644
> --- a/drivers/iio/adc/ltc2497-core.c
> +++ b/drivers/iio/adc/ltc2497-core.c
> @@ -169,7 +169,7 @@ int ltc2497core_probe(struct device *dev, struct iio_dev *indio_dev)
> struct ltc2497core_driverdata *ddata = iio_priv(indio_dev);
> int ret;
>
> - indio_dev->name = dev_name(dev);
> + indio_dev->name = ddata->chip_info->name;
> indio_dev->info = &ltc2497core_info;
> indio_dev->modes = INDIO_DIRECT_MODE;
> indio_dev->channels = ltc2497core_channel;
> diff --git a/drivers/iio/adc/ltc2497.c b/drivers/iio/adc/ltc2497.c
> index bb5e0d4301e2..a0aad71c8130 100644
> --- a/drivers/iio/adc/ltc2497.c
> +++ b/drivers/iio/adc/ltc2497.c
> @@ -99,9 +99,11 @@ static int ltc2497_remove(struct i2c_client *client)
> static struct chip_info ltc2497_info[] = {
> [TYPE_LTC2497] = {
> .resolution = 16,
> + .name = "ltc2497"
> },
> [TYPE_LTC2499] = {
> .resolution = 24,
> + .name = "ltc2499"
> }
> };
>
> diff --git a/drivers/iio/adc/ltc2497.h b/drivers/iio/adc/ltc2497.h
> index f4d939cfd48b..0e86e38248ee 100644
> --- a/drivers/iio/adc/ltc2497.h
> +++ b/drivers/iio/adc/ltc2497.h
> @@ -12,6 +12,7 @@ enum chip_type {
>
> struct chip_info {
> u32 resolution;
> + char *name;
> };
>
> struct ltc2497core_driverdata {


2022-08-22 20:00:26

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH 3/3] drivers: iio: adc: Rename the LTC249x iio device

On Mon, 22 Aug 2022 16:08:12 +0200
Lars-Peter Clausen <[email protected]> wrote:

> On 8/22/22 14:51, Ciprian Regus wrote:
> > Set the iio device's name based on the chip used.
>
> While the change is correct it breaks the ABI. This needs a bit of a
> better explanation what is being done, why, what are the potential
> problems, why do we want to do it anyway.

+ it's a fix, so if we are doing this we need to enable backporting
by moving to first patch in series (obviously just for the
already supported parts).

Jonathan

>
> >
> > Signed-off-by: Ciprian Regus <[email protected]>
> > ---
> > drivers/iio/adc/ltc2496.c | 1 +
> > drivers/iio/adc/ltc2497-core.c | 2 +-
> > drivers/iio/adc/ltc2497.c | 2 ++
> > drivers/iio/adc/ltc2497.h | 1 +
> > 4 files changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/iio/adc/ltc2496.c b/drivers/iio/adc/ltc2496.c
> > index 98338104c24a..86470f49e8ca 100644
> > --- a/drivers/iio/adc/ltc2496.c
> > +++ b/drivers/iio/adc/ltc2496.c
> > @@ -89,6 +89,7 @@ static void ltc2496_remove(struct spi_device *spi)
> >
> > static struct chip_info ltc2496_info = {
> > .resolution = 16,
> > + .name = "ltc2496"
> > };
> >
> > static const struct of_device_id ltc2496_of_match[] = {
> > diff --git a/drivers/iio/adc/ltc2497-core.c b/drivers/iio/adc/ltc2497-core.c
> > index b2752399402c..6dd9ab601904 100644
> > --- a/drivers/iio/adc/ltc2497-core.c
> > +++ b/drivers/iio/adc/ltc2497-core.c
> > @@ -169,7 +169,7 @@ int ltc2497core_probe(struct device *dev, struct iio_dev *indio_dev)
> > struct ltc2497core_driverdata *ddata = iio_priv(indio_dev);
> > int ret;
> >
> > - indio_dev->name = dev_name(dev);
> > + indio_dev->name = ddata->chip_info->name;
> > indio_dev->info = &ltc2497core_info;
> > indio_dev->modes = INDIO_DIRECT_MODE;
> > indio_dev->channels = ltc2497core_channel;
> > diff --git a/drivers/iio/adc/ltc2497.c b/drivers/iio/adc/ltc2497.c
> > index bb5e0d4301e2..a0aad71c8130 100644
> > --- a/drivers/iio/adc/ltc2497.c
> > +++ b/drivers/iio/adc/ltc2497.c
> > @@ -99,9 +99,11 @@ static int ltc2497_remove(struct i2c_client *client)
> > static struct chip_info ltc2497_info[] = {
> > [TYPE_LTC2497] = {
> > .resolution = 16,
> > + .name = "ltc2497"
> > },
> > [TYPE_LTC2499] = {
> > .resolution = 24,
> > + .name = "ltc2499"
> > }
> > };
> >
> > diff --git a/drivers/iio/adc/ltc2497.h b/drivers/iio/adc/ltc2497.h
> > index f4d939cfd48b..0e86e38248ee 100644
> > --- a/drivers/iio/adc/ltc2497.h
> > +++ b/drivers/iio/adc/ltc2497.h
> > @@ -12,6 +12,7 @@ enum chip_type {
> >
> > struct chip_info {
> > u32 resolution;
> > + char *name;
> > };
> >
> > struct ltc2497core_driverdata {
>
>

2022-08-23 15:34:18

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 3/3] drivers: iio: adc: Rename the LTC249x iio device

On 22/08/2022 15:51, Ciprian Regus wrote:

(...)

>
> diff --git a/drivers/iio/adc/ltc2497.h b/drivers/iio/adc/ltc2497.h
> index f4d939cfd48b..0e86e38248ee 100644
> --- a/drivers/iio/adc/ltc2497.h
> +++ b/drivers/iio/adc/ltc2497.h
> @@ -12,6 +12,7 @@ enum chip_type {
>
> struct chip_info {
> u32 resolution;
> + char *name;

const char *


Best regards,
Krzysztof

2022-08-29 06:27:27

by Ciprian Regus

[permalink] [raw]
Subject: RE: [PATCH 3/3] drivers: iio: adc: Rename the LTC249x iio device

Hi Lars,

Thanks for the review. I have one question before going further
with this patch.

> On 8/22/22 14:51, Ciprian Regus wrote:
> > Set the iio device's name based on the chip used.
>
> While the change is correct it breaks the ABI. This needs a bit of a
> better explanation what is being done, why, what are the potential
> problems, why do we want to do it anyway.

The reason for this change is to make it easier to identify the device
(by having a generic name) when using an IIO client. The current name is
based on the i2c_client's kobj name, which has the format
"i2c_instance -i2c_address " (e.g. 1-0076). So, the renaming would allow
for interacting with the device without knowing which bus it's connected
to.

Also, as far as I can see, the IIO ABI states that the device's name is
"Typically a part number".

For the reason given, would this change be considered an
improvement, or is the ABI breaking too much of a drawback?
(in which case I'll just drop this patch)

Thanks,
Ciprian
>
> >
> > Signed-off-by: Ciprian Regus <[email protected]>
> > ---
> > drivers/iio/adc/ltc2496.c | 1 +
> > drivers/iio/adc/ltc2497-core.c | 2 +-
> > drivers/iio/adc/ltc2497.c | 2 ++
> > drivers/iio/adc/ltc2497.h | 1 +
> > 4 files changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/iio/adc/ltc2496.c b/drivers/iio/adc/ltc2496.c
> > index 98338104c24a..86470f49e8ca 100644
> > --- a/drivers/iio/adc/ltc2496.c
> > +++ b/drivers/iio/adc/ltc2496.c
> > @@ -89,6 +89,7 @@ static void ltc2496_remove(struct spi_device *spi)
> >
> > static struct chip_info ltc2496_info = {
> > .resolution = 16,
> > + .name = "ltc2496"
> > };
> >
> > static const struct of_device_id ltc2496_of_match[] = {
> > diff --git a/drivers/iio/adc/ltc2497-core.c b/drivers/iio/adc/ltc2497-core.c
> > index b2752399402c..6dd9ab601904 100644
> > --- a/drivers/iio/adc/ltc2497-core.c
> > +++ b/drivers/iio/adc/ltc2497-core.c
> > @@ -169,7 +169,7 @@ int ltc2497core_probe(struct device *dev, struct
> iio_dev *indio_dev)
> > struct ltc2497core_driverdata *ddata = iio_priv(indio_dev);
> > int ret;
> >
> > - indio_dev->name = dev_name(dev);
> > + indio_dev->name = ddata->chip_info->name;
> > indio_dev->info = &ltc2497core_info;
> > indio_dev->modes = INDIO_DIRECT_MODE;
> > indio_dev->channels = ltc2497core_channel;
> > diff --git a/drivers/iio/adc/ltc2497.c b/drivers/iio/adc/ltc2497.c
> > index bb5e0d4301e2..a0aad71c8130 100644
> > --- a/drivers/iio/adc/ltc2497.c
> > +++ b/drivers/iio/adc/ltc2497.c
> > @@ -99,9 +99,11 @@ static int ltc2497_remove(struct i2c_client *client)
> > static struct chip_info ltc2497_info[] = {
> > [TYPE_LTC2497] = {
> > .resolution = 16,
> > + .name = "ltc2497"
> > },
> > [TYPE_LTC2499] = {
> > .resolution = 24,
> > + .name = "ltc2499"
> > }
> > };
> >
> > diff --git a/drivers/iio/adc/ltc2497.h b/drivers/iio/adc/ltc2497.h
> > index f4d939cfd48b..0e86e38248ee 100644
> > --- a/drivers/iio/adc/ltc2497.h
> > +++ b/drivers/iio/adc/ltc2497.h
> > @@ -12,6 +12,7 @@ enum chip_type {
> >
> > struct chip_info {
> > u32 resolution;
> > + char *name;
> > };
> >
> > struct ltc2497core_driverdata {
>

2022-08-29 17:36:13

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH 3/3] drivers: iio: adc: Rename the LTC249x iio device

On Mon, 29 Aug 2022 06:13:52 +0000
"Regus, Ciprian" <[email protected]> wrote:

> Hi Lars,
>
> Thanks for the review. I have one question before going further
> with this patch.
>
> > On 8/22/22 14:51, Ciprian Regus wrote:
> > > Set the iio device's name based on the chip used.
> >
> > While the change is correct it breaks the ABI. This needs a bit of a
> > better explanation what is being done, why, what are the potential
> > problems, why do we want to do it anyway.
>
> The reason for this change is to make it easier to identify the device
> (by having a generic name) when using an IIO client. The current name is
> based on the i2c_client's kobj name, which has the format
> "i2c_instance -i2c_address " (e.g. 1-0076). So, the renaming would allow
> for interacting with the device without knowing which bus it's connected
> to.
>
> Also, as far as I can see, the IIO ABI states that the device's name is
> "Typically a part number".
>
> For the reason given, would this change be considered an
> improvement, or is the ABI breaking too much of a drawback?
> (in which case I'll just drop this patch)

Hi Ciprian

There are a set of drivers that do it similarly to this (amongst other
things because I wasn't paying attention a few years back).

Generally we've considered them unfixable unfortunately because it's
common to use name to find the device - so userspace breakage is
very likely.

If we are introducing new device support thought here can't be a platform
already relying on the old naming. So weird though it seems, can you fix
this just for the newly supported models and leave the old ones 'broken'?
(with a big note on why!) Perhaps do that by leaving .name = NULL for the
older parts and doing a check on that to select behaviour.

Thanks,

Jonathan

>
> Thanks,
> Ciprian
> >
> > >
> > > Signed-off-by: Ciprian Regus <[email protected]>
> > > ---
> > > drivers/iio/adc/ltc2496.c | 1 +
> > > drivers/iio/adc/ltc2497-core.c | 2 +-
> > > drivers/iio/adc/ltc2497.c | 2 ++
> > > drivers/iio/adc/ltc2497.h | 1 +
> > > 4 files changed, 5 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/iio/adc/ltc2496.c b/drivers/iio/adc/ltc2496.c
> > > index 98338104c24a..86470f49e8ca 100644
> > > --- a/drivers/iio/adc/ltc2496.c
> > > +++ b/drivers/iio/adc/ltc2496.c
> > > @@ -89,6 +89,7 @@ static void ltc2496_remove(struct spi_device *spi)
> > >
> > > static struct chip_info ltc2496_info = {
> > > .resolution = 16,
> > > + .name = "ltc2496"
> > > };
> > >
> > > static const struct of_device_id ltc2496_of_match[] = {
> > > diff --git a/drivers/iio/adc/ltc2497-core.c b/drivers/iio/adc/ltc2497-core.c
> > > index b2752399402c..6dd9ab601904 100644
> > > --- a/drivers/iio/adc/ltc2497-core.c
> > > +++ b/drivers/iio/adc/ltc2497-core.c
> > > @@ -169,7 +169,7 @@ int ltc2497core_probe(struct device *dev, struct
> > iio_dev *indio_dev)
> > > struct ltc2497core_driverdata *ddata = iio_priv(indio_dev);
> > > int ret;
> > >
> > > - indio_dev->name = dev_name(dev);
> > > + indio_dev->name = ddata->chip_info->name;
> > > indio_dev->info = &ltc2497core_info;
> > > indio_dev->modes = INDIO_DIRECT_MODE;
> > > indio_dev->channels = ltc2497core_channel;
> > > diff --git a/drivers/iio/adc/ltc2497.c b/drivers/iio/adc/ltc2497.c
> > > index bb5e0d4301e2..a0aad71c8130 100644
> > > --- a/drivers/iio/adc/ltc2497.c
> > > +++ b/drivers/iio/adc/ltc2497.c
> > > @@ -99,9 +99,11 @@ static int ltc2497_remove(struct i2c_client *client)
> > > static struct chip_info ltc2497_info[] = {
> > > [TYPE_LTC2497] = {
> > > .resolution = 16,
> > > + .name = "ltc2497"
> > > },
> > > [TYPE_LTC2499] = {
> > > .resolution = 24,
> > > + .name = "ltc2499"
> > > }
> > > };
> > >
> > > diff --git a/drivers/iio/adc/ltc2497.h b/drivers/iio/adc/ltc2497.h
> > > index f4d939cfd48b..0e86e38248ee 100644
> > > --- a/drivers/iio/adc/ltc2497.h
> > > +++ b/drivers/iio/adc/ltc2497.h
> > > @@ -12,6 +12,7 @@ enum chip_type {
> > >
> > > struct chip_info {
> > > u32 resolution;
> > > + char *name;
> > > };
> > >
> > > struct ltc2497core_driverdata {
> >
>