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: Add battery channel definition for ADC

Defines a constant for the battery sensing channel, typically the last
channel of the ADC. Clarifies channel usage and improves code
readability.

Signed-off-by: Billy Tsai <billy_tsai@aspeedtech.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Billy Tsai and committed by
Jonathan Cameron
a28069be e163b094

+4 -2
+4 -2
drivers/iio/adc/aspeed_adc.c
··· 75 75 76 76 #define ASPEED_ADC_INIT_POLLING_TIME 500 77 77 #define ASPEED_ADC_INIT_TIMEOUT 500000 78 + /* Battery sensing is typically on the last channel */ 79 + #define ASPEED_ADC_BATTERY_CHANNEL 7 78 80 /* 79 81 * When the sampling rate is too high, the ADC may not have enough charging 80 82 * time, resulting in a low voltage value. Thus, the default uses a slow ··· 287 285 288 286 switch (mask) { 289 287 case IIO_CHAN_INFO_RAW: 290 - if (data->battery_sensing && chan->channel == 7) { 288 + if (data->battery_sensing && chan->channel == ASPEED_ADC_BATTERY_CHANNEL) { 291 289 adc_engine_control_reg_val = 292 290 readl(data->base + ASPEED_REG_ENGINE_CONTROL); 293 291 writel(adc_engine_control_reg_val | ··· 311 309 return IIO_VAL_INT; 312 310 313 311 case IIO_CHAN_INFO_OFFSET: 314 - if (data->battery_sensing && chan->channel == 7) 312 + if (data->battery_sensing && chan->channel == ASPEED_ADC_BATTERY_CHANNEL) 315 313 *val = (data->cv * data->battery_mode_gain.mult) / 316 314 data->battery_mode_gain.div; 317 315 else