From: Kyle Hsieh Date: Wed, 25 Mar 2026 02:24:21 +0000 (+0800) Subject: iio: adc: ltc2309: explicitly assign hex values to channel enums X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=999ca38066302347c94fda49db7a33ce87def5b6;p=thirdparty%2Fkernel%2Fstable.git 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 Signed-off-by: Jonathan Cameron --- 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) { \