From 2d1c9eacee1a4fcc442329e212d4ed46814d6aaa Mon Sep 17 00:00:00 2001 From: Anjelique Melendez Date: Thu, 10 Feb 2022 13:34:43 -0800 Subject: [PATCH] iio: adc: qcom-spmi-adc5-gen3: Fix SID config when reading ADC channel Currently, when reading an ADC channel the SID is always configured to 0. This is causing incorrect readings for ADC and ADC TM channels. Fix this. Change-Id: If6332c6ec83f04ce4294df27e5bdb784cc5d23be Signed-off-by: Anjelique Melendez --- drivers/iio/adc/qcom-spmi-adc5-gen3.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/qcom-spmi-adc5-gen3.c b/drivers/iio/adc/qcom-spmi-adc5-gen3.c index d28ca099f9aa..9916c01c48ad 100644 --- a/drivers/iio/adc/qcom-spmi-adc5-gen3.c +++ b/drivers/iio/adc/qcom-spmi-adc5-gen3.c @@ -55,7 +55,7 @@ static LIST_HEAD(adc_tm_device_list); #define ADC5_GEN3_CONV_ERR_CLR_REQ BIT(0) #define ADC5_GEN3_SID 0x4f -#define ADC5_GEN3_SID_MASK 0xf +#define ADC5_GEN3_SID_MASK GENMASK(3, 0) #define ADC5_GEN3_PERPH_CH 0x50 #define ADC5_GEN3_CHAN_CONV_REQ BIT(7) @@ -357,8 +357,7 @@ static int adc5_gen3_configure(struct adc5_chip *adc, return ret; /* Write SID */ - buf[0] &= (u8) ~ADC5_GEN3_SID_MASK; - buf[0] &= prop->sid; + buf[0] = prop->sid & ADC5_GEN3_SID_MASK; /* * Use channel 0 by default for immediate conversion and @@ -821,8 +820,7 @@ static int adc_tm5_gen3_configure(struct adc5_channel_prop *prop) return ret; /* Write SID */ - buf[0] &= (u8) ~ADC5_GEN3_SID_MASK; - buf[0] &= prop->sid; + buf[0] = prop->sid & ADC5_GEN3_SID_MASK; /* * Select TM channel and indicate there is an actual