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>
/* 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) { \