We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 7d20839 + f219687 commit a0d7e98Copy full SHA for a0d7e98
1 file changed
drivers/iio/adc/pac1934.c
@@ -787,6 +787,15 @@ static int pac1934_read_raw(struct iio_dev *indio_dev,
787
s64 curr_energy;
788
int ret, channel = chan->channel - 1;
789
790
+ /*
791
+ * For AVG the index should be between 5 to 8.
792
+ * To calculate PAC1934_CH_VOLTAGE_AVERAGE,
793
+ * respectively PAC1934_CH_CURRENT real index, we need
794
+ * to remove the added offset (PAC1934_MAX_NUM_CHANNELS).
795
+ */
796
+ if (channel >= PAC1934_MAX_NUM_CHANNELS)
797
+ channel = channel - PAC1934_MAX_NUM_CHANNELS;
798
+
799
ret = pac1934_retrieve_data(info, PAC1934_MIN_UPDATE_WAIT_TIME_US);
800
if (ret < 0)
801
return ret;
0 commit comments