drivers: iio: adc: ltc2497: Rename the LTC2499 iio device
authorCiprian Regus <ciprian.regus@analog.com>
Fri, 16 Sep 2022 14:09:22 +0000 (17:09 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 21 Sep 2022 17:42:54 +0000 (18:42 +0100)
Set the iio device's name based on the chip used for the
LTC2499 only. The most common way for IIO clients to interact
with a device is to address it based on it's name. By using
the dev_name() function, the name will be set based on a
i2c_client's kobj name, which has the format i2c_instance-i2c_address
(1-0076 for example). This is not ideal, since it makes a
requirement for userspace to have knowledge about the hardware
connections of the device.

The name field is set to NULL for the LTC2497 and LTC2496, so
that the old name can kept as it is, since changing it will
result in an ABI breakage.

Signed-off-by: Ciprian Regus <ciprian.regus@analog.com>
Link: https://lore.kernel.org/r/20220916140922.2506248-6-ciprian.regus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/ltc2496.c
drivers/iio/adc/ltc2497-core.c
drivers/iio/adc/ltc2497.c
drivers/iio/adc/ltc2497.h

index bf89d5ae19af137f43f91d8c8aec6a4187b85e5c..2593fa4322ebd59d02ff98cb275800b2cb929804 100644 (file)
@@ -89,6 +89,7 @@ static void ltc2496_remove(struct spi_device *spi)
 
 static const struct ltc2497_chip_info ltc2496_info = {
        .resolution = 16,
+       .name = NULL,
 };
 
 static const struct of_device_id ltc2496_of_match[] = {
index b2752399402cd1bedd4e27409b892bc840329b09..f52d37af4d1f19d61afd85124ecffbb8ca62c60a 100644 (file)
@@ -169,7 +169,15 @@ 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);
+       /*
+        * Keep using dev_name() for the iio_dev's name on some of the parts,
+        * since updating it would result in a ABI breakage.
+        */
+       if (ddata->chip_info->name)
+               indio_dev->name = ddata->chip_info->name;
+       else
+               indio_dev->name = dev_name(dev);
+
        indio_dev->info = &ltc2497core_info;
        indio_dev->modes = INDIO_DIRECT_MODE;
        indio_dev->channels = ltc2497core_channel;
index bd6a6507171194a9ca109509d1c061b9c1cf6467..4206f17e284c6bf66822881328b8d10133a20df9 100644 (file)
@@ -140,9 +140,11 @@ static int ltc2497_remove(struct i2c_client *client)
 static const struct ltc2497_chip_info ltc2497_info[] = {
        [TYPE_LTC2497] = {
                .resolution = 16,
+               .name = NULL,
        },
        [TYPE_LTC2499] = {
                .resolution = 24,
+               .name = "ltc2499",
        },
 };
 
index 71957fc7e1ba99a3ec413a5ccc375b68a7bf64e5..e023de0d88c46ac4701927e412d1306c035db8a4 100644 (file)
@@ -6,6 +6,7 @@
 
 struct ltc2497_chip_info {
        u32 resolution;
+       const char *name;
 };
 
 struct ltc2497core_driverdata {