summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Hsieh <kylehsieh1995@gmail.com>2026-03-25 10:24:21 +0800
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2026-03-25 19:48:45 +0000
commit999ca38066302347c94fda49db7a33ce87def5b6 (patch)
tree3d40cfe2d312a6c396384dd4739a2aa8e1e8d82f
parent732df35bbb94c06099cf8c64076233347b278516 (diff)
iio: adc: ltc2309: explicitly assign hex values to channel enums
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>
-rw-r--r--drivers/iio/adc/ltc2309.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/drivers/iio/adc/ltc2309.c b/drivers/iio/adc/ltc2309.c
index 5f0d947d0615..3f27ffc66668 100644
--- a/drivers/iio/adc/ltc2309.c
+++ b/drivers/iio/adc/ltc2309.c
@@ -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) { \