Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers: iio: adc: ltc2497: Rename the LTC2499 iio device

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>

authored by

Ciprian Regus and committed by
Jonathan Cameron
1695c52a 2187cfeb

+13 -1
+1
drivers/iio/adc/ltc2496.c
··· 89 89 90 90 static const struct ltc2497_chip_info ltc2496_info = { 91 91 .resolution = 16, 92 + .name = NULL, 92 93 }; 93 94 94 95 static const struct of_device_id ltc2496_of_match[] = {
+9 -1
drivers/iio/adc/ltc2497-core.c
··· 169 169 struct ltc2497core_driverdata *ddata = iio_priv(indio_dev); 170 170 int ret; 171 171 172 - indio_dev->name = dev_name(dev); 172 + /* 173 + * Keep using dev_name() for the iio_dev's name on some of the parts, 174 + * since updating it would result in a ABI breakage. 175 + */ 176 + if (ddata->chip_info->name) 177 + indio_dev->name = ddata->chip_info->name; 178 + else 179 + indio_dev->name = dev_name(dev); 180 + 173 181 indio_dev->info = &ltc2497core_info; 174 182 indio_dev->modes = INDIO_DIRECT_MODE; 175 183 indio_dev->channels = ltc2497core_channel;
+2
drivers/iio/adc/ltc2497.c
··· 140 140 static const struct ltc2497_chip_info ltc2497_info[] = { 141 141 [TYPE_LTC2497] = { 142 142 .resolution = 16, 143 + .name = NULL, 143 144 }, 144 145 [TYPE_LTC2499] = { 145 146 .resolution = 24, 147 + .name = "ltc2499", 146 148 }, 147 149 }; 148 150
+1
drivers/iio/adc/ltc2497.h
··· 6 6 7 7 struct ltc2497_chip_info { 8 8 u32 resolution; 9 + const char *name; 9 10 }; 10 11 11 12 struct ltc2497core_driverdata {