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

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Kyle Hsieh and committed by
Jonathan Cameron
999ca380 732df35b

+16 -16
+16 -16
drivers/iio/adc/ltc2309.c
··· 42 42 43 43 /* Order matches expected channel address, See datasheet Table 1. */ 44 44 enum ltc2309_channels { 45 - LTC2309_CH0_CH1 = 0, 46 - LTC2309_CH2_CH3, 47 - LTC2309_CH4_CH5, 48 - LTC2309_CH6_CH7, 49 - LTC2309_CH1_CH0, 50 - LTC2309_CH3_CH2, 51 - LTC2309_CH5_CH4, 52 - LTC2309_CH7_CH6, 53 - LTC2309_CH0, 54 - LTC2309_CH2, 55 - LTC2309_CH4, 56 - LTC2309_CH6, 57 - LTC2309_CH1, 58 - LTC2309_CH3, 59 - LTC2309_CH5, 60 - LTC2309_CH7, 45 + LTC2309_CH0_CH1 = 0x0, 46 + LTC2309_CH2_CH3 = 0x1, 47 + LTC2309_CH4_CH5 = 0x2, 48 + LTC2309_CH6_CH7 = 0x3, 49 + LTC2309_CH1_CH0 = 0x4, 50 + LTC2309_CH3_CH2 = 0x5, 51 + LTC2309_CH5_CH4 = 0x6, 52 + LTC2309_CH7_CH6 = 0x7, 53 + LTC2309_CH0 = 0x8, 54 + LTC2309_CH2 = 0x9, 55 + LTC2309_CH4 = 0xa, 56 + LTC2309_CH6 = 0xb, 57 + LTC2309_CH1 = 0xc, 58 + LTC2309_CH3 = 0xd, 59 + LTC2309_CH5 = 0xe, 60 + LTC2309_CH7 = 0xf, 61 61 }; 62 62 63 63 #define LTC2309_CHAN(_chan, _addr) { \