]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: adc: ltc2309: explicitly assign hex values to channel enums
authorKyle Hsieh <kylehsieh1995@gmail.com>
Wed, 25 Mar 2026 02:24:21 +0000 (10:24 +0800)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 25 Mar 2026 19:48:45 +0000 (19:48 +0000)
The current ltc2309_channels enum relies on implicit sequential
assignment. While this works for the 8-channel LTC2309, it is
not intuitive and makes it difficult to support other chips in
the same family that might have different bit mappings.

Explicitly assign hex values to the enum members based on the
channel selection bits defined in the datasheet. This improves
code readability and provides a consistent pattern for future
chip support.

Signed-off-by: Kyle Hsieh <kylehsieh1995@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/ltc2309.c

index 5f0d947d06157e70281747e96d1b9149696bfef9..3f27ffc666687303d650164595b3e5eeb102f638 100644 (file)
@@ -42,22 +42,22 @@ struct ltc2309 {
 
 /* Order matches expected channel address, See datasheet Table 1. */
 enum ltc2309_channels {
-       LTC2309_CH0_CH1 = 0,
-       LTC2309_CH2_CH3,
-       LTC2309_CH4_CH5,
-       LTC2309_CH6_CH7,
-       LTC2309_CH1_CH0,
-       LTC2309_CH3_CH2,
-       LTC2309_CH5_CH4,
-       LTC2309_CH7_CH6,
-       LTC2309_CH0,
-       LTC2309_CH2,
-       LTC2309_CH4,
-       LTC2309_CH6,
-       LTC2309_CH1,
-       LTC2309_CH3,
-       LTC2309_CH5,
-       LTC2309_CH7,
+       LTC2309_CH0_CH1 = 0x0,
+       LTC2309_CH2_CH3 = 0x1,
+       LTC2309_CH4_CH5 = 0x2,
+       LTC2309_CH6_CH7 = 0x3,
+       LTC2309_CH1_CH0 = 0x4,
+       LTC2309_CH3_CH2 = 0x5,
+       LTC2309_CH5_CH4 = 0x6,
+       LTC2309_CH7_CH6 = 0x7,
+       LTC2309_CH0     = 0x8,
+       LTC2309_CH2     = 0x9,
+       LTC2309_CH4     = 0xa,
+       LTC2309_CH6     = 0xb,
+       LTC2309_CH1     = 0xc,
+       LTC2309_CH3     = 0xd,
+       LTC2309_CH5     = 0xe,
+       LTC2309_CH7     = 0xf,
 };
 
 #define LTC2309_CHAN(_chan, _addr) {                           \