From: kernel test robot <lkp@intel.com>
To: Gene Chen <gene.chen.richtek@gmail.com>,
jic23@kernel.org, matthias.bgg@gmail.com
Cc: kbuild-all@lists.01.org, knaack.h@gmx.de, lars@metafoo.de,
pmeerw@pmeerw.net, linux-iio@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
gene_chen@richtek.com
Subject: Re: [PATCH v3 1/2] iio: adc: mt6360: Add ADC driver for MT6360
Date: Thu, 27 Aug 2020 20:16:55 +0800 [thread overview]
Message-ID: <202008272024.JFC8esYm%lkp@intel.com> (raw)
In-Reply-To: <1598259985-12517-2-git-send-email-gene.chen.richtek@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 5178 bytes --]
Hi Gene,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on iio/togreg]
[also build test WARNING on v5.9-rc2 next-20200827]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Gene-Chen/iio-adc-mt6360-Add-ADC-driver-for-MT6360/20200824-170948
base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
config: i386-randconfig-s031-20200827 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.2-191-g10164920-dirty
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> drivers/iio/adc/mt6360-adc.c:125:20: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned short [assigned] [usertype] adc_enable @@ got restricted __be16 [usertype] @@
>> drivers/iio/adc/mt6360-adc.c:125:20: sparse: expected unsigned short [assigned] [usertype] adc_enable
>> drivers/iio/adc/mt6360-adc.c:125:20: sparse: got restricted __be16 [usertype]
>> drivers/iio/adc/mt6360-adc.c:179:20: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned short [addressable] [assigned] [usertype] adc_enable @@ got restricted __be16 [usertype] @@
>> drivers/iio/adc/mt6360-adc.c:179:20: sparse: expected unsigned short [addressable] [assigned] [usertype] adc_enable
drivers/iio/adc/mt6360-adc.c:179:20: sparse: got restricted __be16 [usertype]
# https://github.com/0day-ci/linux/commit/0e757f71bbdf50d4dad3b79e5f30c7f2386ae082
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Gene-Chen/iio-adc-mt6360-Add-ADC-driver-for-MT6360/20200824-170948
git checkout 0e757f71bbdf50d4dad3b79e5f30c7f2386ae082
vim +125 drivers/iio/adc/mt6360-adc.c
106
107 static int mt6360_adc_read_processed(struct mt6360_adc_data *mad, int channel, int *val)
108 {
109 u16 adc_enable;
110 u8 rpt[3];
111 ktime_t start_t, predict_end_t;
112 long timeout;
113 int value, ret;
114
115 mutex_lock(&mad->adc_lock);
116
117 /* select preferred channel that we want */
118 ret = regmap_update_bits(mad->regmap, MT6360_REG_PMUADCRPT1, MT6360_PREFERCH_MASK,
119 channel << MT6360_PREFERCH_SHFT);
120 if (ret)
121 goto out_adc;
122
123 /* enable adc channel we want and adc_en */
124 adc_enable = MT6360_ADCEN_MASK | BIT(channel);
> 125 adc_enable = cpu_to_be16(adc_enable);
126 ret = regmap_raw_write(mad->regmap, MT6360_REG_PMUADCCFG, (void *)&adc_enable, sizeof(u16));
127 if (ret)
128 goto out_adc;
129
130 start_t = ktime_get();
131 predict_end_t = ktime_add_ms(mad->last_off_timestamps[channel], 50);
132
133 if (ktime_after(start_t, predict_end_t))
134 predict_end_t = ktime_add_ms(start_t, 25);
135 else
136 predict_end_t = ktime_add_ms(start_t, 75);
137
138 enable_irq(mad->irq);
139 adc_retry:
140 reinit_completion(&mad->adc_complete);
141
142 /* wait for conversion to complete */
143 timeout = wait_for_completion_timeout(&mad->adc_complete, msecs_to_jiffies(200));
144 if (timeout == 0) {
145 ret = -ETIMEDOUT;
146 goto out_adc_conv;
147 } else if (timeout < 0) {
148 ret = -EINTR;
149 goto out_adc_conv;
150 }
151
152 ret = regmap_raw_read(mad->regmap, MT6360_REG_PMUADCRPT1, rpt, sizeof(rpt));
153 if (ret)
154 goto out_adc_conv;
155
156 /* check the current reported channel */
157 if ((rpt[0] & MT6360_RPTCH_MASK) != channel) {
158 dev_dbg(mad->dev, "not wanted channel report [%02x]\n", rpt[0]);
159 goto adc_retry;
160 }
161
162 if (!ktime_after(ktime_get(), predict_end_t)) {
163 dev_dbg(mad->dev, "time is not after one adc_conv_t\n");
164 goto adc_retry;
165 }
166
167 value = (rpt[1] << 8) | rpt[2];
168
169 ret = mt6360_adc_convert_processed_val(mad, channel, &value);
170 if (ret)
171 goto out_adc_conv;
172
173 *val = value;
174 ret = IIO_VAL_INT;
175
176 out_adc_conv:
177 disable_irq(mad->irq);
178 adc_enable = MT6360_ADCEN_MASK;
> 179 adc_enable = cpu_to_be16(adc_enable);
180 regmap_raw_write(mad->regmap, MT6360_REG_PMUADCCFG, (void *)&adc_enable, sizeof(u16));
181 mad->last_off_timestamps[channel] = ktime_get();
182 /* set prefer channel to 0xf */
183 regmap_update_bits(mad->regmap, MT6360_REG_PMUADCRPT1, MT6360_PREFERCH_MASK,
184 0xF << MT6360_PREFERCH_SHFT);
185 out_adc:
186 mutex_unlock(&mad->adc_lock);
187
188 return ret;
189 }
190
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 34835 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: kernel test robot <lkp@intel.com>
To: Gene Chen <gene.chen.richtek@gmail.com>,
jic23@kernel.org, matthias.bgg@gmail.com
Cc: gene_chen@richtek.com, lars@metafoo.de, kbuild-all@lists.01.org,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mediatek@lists.infradead.org, pmeerw@pmeerw.net,
knaack.h@gmx.de, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3 1/2] iio: adc: mt6360: Add ADC driver for MT6360
Date: Thu, 27 Aug 2020 20:16:55 +0800 [thread overview]
Message-ID: <202008272024.JFC8esYm%lkp@intel.com> (raw)
In-Reply-To: <1598259985-12517-2-git-send-email-gene.chen.richtek@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 5178 bytes --]
Hi Gene,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on iio/togreg]
[also build test WARNING on v5.9-rc2 next-20200827]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Gene-Chen/iio-adc-mt6360-Add-ADC-driver-for-MT6360/20200824-170948
base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
config: i386-randconfig-s031-20200827 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.2-191-g10164920-dirty
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> drivers/iio/adc/mt6360-adc.c:125:20: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned short [assigned] [usertype] adc_enable @@ got restricted __be16 [usertype] @@
>> drivers/iio/adc/mt6360-adc.c:125:20: sparse: expected unsigned short [assigned] [usertype] adc_enable
>> drivers/iio/adc/mt6360-adc.c:125:20: sparse: got restricted __be16 [usertype]
>> drivers/iio/adc/mt6360-adc.c:179:20: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned short [addressable] [assigned] [usertype] adc_enable @@ got restricted __be16 [usertype] @@
>> drivers/iio/adc/mt6360-adc.c:179:20: sparse: expected unsigned short [addressable] [assigned] [usertype] adc_enable
drivers/iio/adc/mt6360-adc.c:179:20: sparse: got restricted __be16 [usertype]
# https://github.com/0day-ci/linux/commit/0e757f71bbdf50d4dad3b79e5f30c7f2386ae082
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Gene-Chen/iio-adc-mt6360-Add-ADC-driver-for-MT6360/20200824-170948
git checkout 0e757f71bbdf50d4dad3b79e5f30c7f2386ae082
vim +125 drivers/iio/adc/mt6360-adc.c
106
107 static int mt6360_adc_read_processed(struct mt6360_adc_data *mad, int channel, int *val)
108 {
109 u16 adc_enable;
110 u8 rpt[3];
111 ktime_t start_t, predict_end_t;
112 long timeout;
113 int value, ret;
114
115 mutex_lock(&mad->adc_lock);
116
117 /* select preferred channel that we want */
118 ret = regmap_update_bits(mad->regmap, MT6360_REG_PMUADCRPT1, MT6360_PREFERCH_MASK,
119 channel << MT6360_PREFERCH_SHFT);
120 if (ret)
121 goto out_adc;
122
123 /* enable adc channel we want and adc_en */
124 adc_enable = MT6360_ADCEN_MASK | BIT(channel);
> 125 adc_enable = cpu_to_be16(adc_enable);
126 ret = regmap_raw_write(mad->regmap, MT6360_REG_PMUADCCFG, (void *)&adc_enable, sizeof(u16));
127 if (ret)
128 goto out_adc;
129
130 start_t = ktime_get();
131 predict_end_t = ktime_add_ms(mad->last_off_timestamps[channel], 50);
132
133 if (ktime_after(start_t, predict_end_t))
134 predict_end_t = ktime_add_ms(start_t, 25);
135 else
136 predict_end_t = ktime_add_ms(start_t, 75);
137
138 enable_irq(mad->irq);
139 adc_retry:
140 reinit_completion(&mad->adc_complete);
141
142 /* wait for conversion to complete */
143 timeout = wait_for_completion_timeout(&mad->adc_complete, msecs_to_jiffies(200));
144 if (timeout == 0) {
145 ret = -ETIMEDOUT;
146 goto out_adc_conv;
147 } else if (timeout < 0) {
148 ret = -EINTR;
149 goto out_adc_conv;
150 }
151
152 ret = regmap_raw_read(mad->regmap, MT6360_REG_PMUADCRPT1, rpt, sizeof(rpt));
153 if (ret)
154 goto out_adc_conv;
155
156 /* check the current reported channel */
157 if ((rpt[0] & MT6360_RPTCH_MASK) != channel) {
158 dev_dbg(mad->dev, "not wanted channel report [%02x]\n", rpt[0]);
159 goto adc_retry;
160 }
161
162 if (!ktime_after(ktime_get(), predict_end_t)) {
163 dev_dbg(mad->dev, "time is not after one adc_conv_t\n");
164 goto adc_retry;
165 }
166
167 value = (rpt[1] << 8) | rpt[2];
168
169 ret = mt6360_adc_convert_processed_val(mad, channel, &value);
170 if (ret)
171 goto out_adc_conv;
172
173 *val = value;
174 ret = IIO_VAL_INT;
175
176 out_adc_conv:
177 disable_irq(mad->irq);
178 adc_enable = MT6360_ADCEN_MASK;
> 179 adc_enable = cpu_to_be16(adc_enable);
180 regmap_raw_write(mad->regmap, MT6360_REG_PMUADCCFG, (void *)&adc_enable, sizeof(u16));
181 mad->last_off_timestamps[channel] = ktime_get();
182 /* set prefer channel to 0xf */
183 regmap_update_bits(mad->regmap, MT6360_REG_PMUADCRPT1, MT6360_PREFERCH_MASK,
184 0xF << MT6360_PREFERCH_SHFT);
185 out_adc:
186 mutex_unlock(&mad->adc_lock);
187
188 return ret;
189 }
190
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 34835 bytes --]
[-- Attachment #3: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
WARNING: multiple messages have this Message-ID (diff)
From: kernel test robot <lkp@intel.com>
To: Gene Chen <gene.chen.richtek@gmail.com>,
jic23@kernel.org, matthias.bgg@gmail.com
Cc: gene_chen@richtek.com, lars@metafoo.de, kbuild-all@lists.01.org,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mediatek@lists.infradead.org, pmeerw@pmeerw.net,
knaack.h@gmx.de, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3 1/2] iio: adc: mt6360: Add ADC driver for MT6360
Date: Thu, 27 Aug 2020 20:16:55 +0800 [thread overview]
Message-ID: <202008272024.JFC8esYm%lkp@intel.com> (raw)
In-Reply-To: <1598259985-12517-2-git-send-email-gene.chen.richtek@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 5178 bytes --]
Hi Gene,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on iio/togreg]
[also build test WARNING on v5.9-rc2 next-20200827]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Gene-Chen/iio-adc-mt6360-Add-ADC-driver-for-MT6360/20200824-170948
base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
config: i386-randconfig-s031-20200827 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.2-191-g10164920-dirty
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> drivers/iio/adc/mt6360-adc.c:125:20: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned short [assigned] [usertype] adc_enable @@ got restricted __be16 [usertype] @@
>> drivers/iio/adc/mt6360-adc.c:125:20: sparse: expected unsigned short [assigned] [usertype] adc_enable
>> drivers/iio/adc/mt6360-adc.c:125:20: sparse: got restricted __be16 [usertype]
>> drivers/iio/adc/mt6360-adc.c:179:20: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned short [addressable] [assigned] [usertype] adc_enable @@ got restricted __be16 [usertype] @@
>> drivers/iio/adc/mt6360-adc.c:179:20: sparse: expected unsigned short [addressable] [assigned] [usertype] adc_enable
drivers/iio/adc/mt6360-adc.c:179:20: sparse: got restricted __be16 [usertype]
# https://github.com/0day-ci/linux/commit/0e757f71bbdf50d4dad3b79e5f30c7f2386ae082
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Gene-Chen/iio-adc-mt6360-Add-ADC-driver-for-MT6360/20200824-170948
git checkout 0e757f71bbdf50d4dad3b79e5f30c7f2386ae082
vim +125 drivers/iio/adc/mt6360-adc.c
106
107 static int mt6360_adc_read_processed(struct mt6360_adc_data *mad, int channel, int *val)
108 {
109 u16 adc_enable;
110 u8 rpt[3];
111 ktime_t start_t, predict_end_t;
112 long timeout;
113 int value, ret;
114
115 mutex_lock(&mad->adc_lock);
116
117 /* select preferred channel that we want */
118 ret = regmap_update_bits(mad->regmap, MT6360_REG_PMUADCRPT1, MT6360_PREFERCH_MASK,
119 channel << MT6360_PREFERCH_SHFT);
120 if (ret)
121 goto out_adc;
122
123 /* enable adc channel we want and adc_en */
124 adc_enable = MT6360_ADCEN_MASK | BIT(channel);
> 125 adc_enable = cpu_to_be16(adc_enable);
126 ret = regmap_raw_write(mad->regmap, MT6360_REG_PMUADCCFG, (void *)&adc_enable, sizeof(u16));
127 if (ret)
128 goto out_adc;
129
130 start_t = ktime_get();
131 predict_end_t = ktime_add_ms(mad->last_off_timestamps[channel], 50);
132
133 if (ktime_after(start_t, predict_end_t))
134 predict_end_t = ktime_add_ms(start_t, 25);
135 else
136 predict_end_t = ktime_add_ms(start_t, 75);
137
138 enable_irq(mad->irq);
139 adc_retry:
140 reinit_completion(&mad->adc_complete);
141
142 /* wait for conversion to complete */
143 timeout = wait_for_completion_timeout(&mad->adc_complete, msecs_to_jiffies(200));
144 if (timeout == 0) {
145 ret = -ETIMEDOUT;
146 goto out_adc_conv;
147 } else if (timeout < 0) {
148 ret = -EINTR;
149 goto out_adc_conv;
150 }
151
152 ret = regmap_raw_read(mad->regmap, MT6360_REG_PMUADCRPT1, rpt, sizeof(rpt));
153 if (ret)
154 goto out_adc_conv;
155
156 /* check the current reported channel */
157 if ((rpt[0] & MT6360_RPTCH_MASK) != channel) {
158 dev_dbg(mad->dev, "not wanted channel report [%02x]\n", rpt[0]);
159 goto adc_retry;
160 }
161
162 if (!ktime_after(ktime_get(), predict_end_t)) {
163 dev_dbg(mad->dev, "time is not after one adc_conv_t\n");
164 goto adc_retry;
165 }
166
167 value = (rpt[1] << 8) | rpt[2];
168
169 ret = mt6360_adc_convert_processed_val(mad, channel, &value);
170 if (ret)
171 goto out_adc_conv;
172
173 *val = value;
174 ret = IIO_VAL_INT;
175
176 out_adc_conv:
177 disable_irq(mad->irq);
178 adc_enable = MT6360_ADCEN_MASK;
> 179 adc_enable = cpu_to_be16(adc_enable);
180 regmap_raw_write(mad->regmap, MT6360_REG_PMUADCCFG, (void *)&adc_enable, sizeof(u16));
181 mad->last_off_timestamps[channel] = ktime_get();
182 /* set prefer channel to 0xf */
183 regmap_update_bits(mad->regmap, MT6360_REG_PMUADCRPT1, MT6360_PREFERCH_MASK,
184 0xF << MT6360_PREFERCH_SHFT);
185 out_adc:
186 mutex_unlock(&mad->adc_lock);
187
188 return ret;
189 }
190
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 34835 bytes --]
[-- Attachment #3: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: kernel test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: Re: [PATCH v3 1/2] iio: adc: mt6360: Add ADC driver for MT6360
Date: Thu, 27 Aug 2020 20:16:55 +0800 [thread overview]
Message-ID: <202008272024.JFC8esYm%lkp@intel.com> (raw)
In-Reply-To: <1598259985-12517-2-git-send-email-gene.chen.richtek@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 5308 bytes --]
Hi Gene,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on iio/togreg]
[also build test WARNING on v5.9-rc2 next-20200827]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Gene-Chen/iio-adc-mt6360-Add-ADC-driver-for-MT6360/20200824-170948
base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
config: i386-randconfig-s031-20200827 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.2-191-g10164920-dirty
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> drivers/iio/adc/mt6360-adc.c:125:20: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned short [assigned] [usertype] adc_enable @@ got restricted __be16 [usertype] @@
>> drivers/iio/adc/mt6360-adc.c:125:20: sparse: expected unsigned short [assigned] [usertype] adc_enable
>> drivers/iio/adc/mt6360-adc.c:125:20: sparse: got restricted __be16 [usertype]
>> drivers/iio/adc/mt6360-adc.c:179:20: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned short [addressable] [assigned] [usertype] adc_enable @@ got restricted __be16 [usertype] @@
>> drivers/iio/adc/mt6360-adc.c:179:20: sparse: expected unsigned short [addressable] [assigned] [usertype] adc_enable
drivers/iio/adc/mt6360-adc.c:179:20: sparse: got restricted __be16 [usertype]
# https://github.com/0day-ci/linux/commit/0e757f71bbdf50d4dad3b79e5f30c7f2386ae082
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Gene-Chen/iio-adc-mt6360-Add-ADC-driver-for-MT6360/20200824-170948
git checkout 0e757f71bbdf50d4dad3b79e5f30c7f2386ae082
vim +125 drivers/iio/adc/mt6360-adc.c
106
107 static int mt6360_adc_read_processed(struct mt6360_adc_data *mad, int channel, int *val)
108 {
109 u16 adc_enable;
110 u8 rpt[3];
111 ktime_t start_t, predict_end_t;
112 long timeout;
113 int value, ret;
114
115 mutex_lock(&mad->adc_lock);
116
117 /* select preferred channel that we want */
118 ret = regmap_update_bits(mad->regmap, MT6360_REG_PMUADCRPT1, MT6360_PREFERCH_MASK,
119 channel << MT6360_PREFERCH_SHFT);
120 if (ret)
121 goto out_adc;
122
123 /* enable adc channel we want and adc_en */
124 adc_enable = MT6360_ADCEN_MASK | BIT(channel);
> 125 adc_enable = cpu_to_be16(adc_enable);
126 ret = regmap_raw_write(mad->regmap, MT6360_REG_PMUADCCFG, (void *)&adc_enable, sizeof(u16));
127 if (ret)
128 goto out_adc;
129
130 start_t = ktime_get();
131 predict_end_t = ktime_add_ms(mad->last_off_timestamps[channel], 50);
132
133 if (ktime_after(start_t, predict_end_t))
134 predict_end_t = ktime_add_ms(start_t, 25);
135 else
136 predict_end_t = ktime_add_ms(start_t, 75);
137
138 enable_irq(mad->irq);
139 adc_retry:
140 reinit_completion(&mad->adc_complete);
141
142 /* wait for conversion to complete */
143 timeout = wait_for_completion_timeout(&mad->adc_complete, msecs_to_jiffies(200));
144 if (timeout == 0) {
145 ret = -ETIMEDOUT;
146 goto out_adc_conv;
147 } else if (timeout < 0) {
148 ret = -EINTR;
149 goto out_adc_conv;
150 }
151
152 ret = regmap_raw_read(mad->regmap, MT6360_REG_PMUADCRPT1, rpt, sizeof(rpt));
153 if (ret)
154 goto out_adc_conv;
155
156 /* check the current reported channel */
157 if ((rpt[0] & MT6360_RPTCH_MASK) != channel) {
158 dev_dbg(mad->dev, "not wanted channel report [%02x]\n", rpt[0]);
159 goto adc_retry;
160 }
161
162 if (!ktime_after(ktime_get(), predict_end_t)) {
163 dev_dbg(mad->dev, "time is not after one adc_conv_t\n");
164 goto adc_retry;
165 }
166
167 value = (rpt[1] << 8) | rpt[2];
168
169 ret = mt6360_adc_convert_processed_val(mad, channel, &value);
170 if (ret)
171 goto out_adc_conv;
172
173 *val = value;
174 ret = IIO_VAL_INT;
175
176 out_adc_conv:
177 disable_irq(mad->irq);
178 adc_enable = MT6360_ADCEN_MASK;
> 179 adc_enable = cpu_to_be16(adc_enable);
180 regmap_raw_write(mad->regmap, MT6360_REG_PMUADCCFG, (void *)&adc_enable, sizeof(u16));
181 mad->last_off_timestamps[channel] = ktime_get();
182 /* set prefer channel to 0xf */
183 regmap_update_bits(mad->regmap, MT6360_REG_PMUADCRPT1, MT6360_PREFERCH_MASK,
184 0xF << MT6360_PREFERCH_SHFT);
185 out_adc:
186 mutex_unlock(&mad->adc_lock);
187
188 return ret;
189 }
190
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 34835 bytes --]
next prev parent reply other threads:[~2020-08-27 12:56 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-24 9:06 [PATCH v3 0/2] iio: adc: mt6360: Add ADC driver for MT6360 Gene Chen
2020-08-24 9:06 ` Gene Chen
2020-08-24 9:06 ` Gene Chen
2020-08-24 9:06 ` [PATCH v3 1/2] " Gene Chen
2020-08-24 9:06 ` Gene Chen
2020-08-24 9:06 ` Gene Chen
2020-08-27 12:16 ` kernel test robot [this message]
2020-08-27 12:16 ` kernel test robot
2020-08-27 12:16 ` kernel test robot
2020-08-27 12:16 ` kernel test robot
2020-08-29 17:11 ` Jonathan Cameron
2020-08-29 17:11 ` Jonathan Cameron
2020-08-29 17:11 ` Jonathan Cameron
2020-09-08 6:17 ` Gene Chen
2020-09-08 6:17 ` Gene Chen
2020-09-08 6:17 ` Gene Chen
2020-09-08 7:43 ` Andy Shevchenko
2020-09-08 7:43 ` Andy Shevchenko
2020-09-08 7:43 ` Andy Shevchenko
2020-09-08 9:07 ` Jonathan Cameron
2020-09-08 9:07 ` Jonathan Cameron
2020-09-08 9:07 ` Jonathan Cameron
2020-09-08 11:08 ` Gene Chen
2020-09-08 11:08 ` Gene Chen
2020-09-08 11:08 ` Gene Chen
2020-09-08 12:58 ` Jonathan Cameron
2020-09-08 12:58 ` Jonathan Cameron
2020-09-08 12:58 ` Jonathan Cameron
2020-09-08 23:39 ` Gene Chen
2020-09-08 23:39 ` Gene Chen
2020-09-08 23:39 ` Gene Chen
2020-09-09 9:34 ` Jonathan Cameron
2020-09-09 9:34 ` Jonathan Cameron
2020-09-09 9:34 ` Jonathan Cameron
2020-09-10 0:14 ` Gene Chen
2020-09-10 0:14 ` Gene Chen
2020-09-10 0:14 ` Gene Chen
2020-08-30 17:39 ` Andy Shevchenko
2020-08-30 17:39 ` Andy Shevchenko
2020-08-30 17:39 ` Andy Shevchenko
2020-08-24 9:06 ` [PATCH v3 2/2] Documentation: ABI: testing: mt6360: Add ADC sysfs guideline Gene Chen
2020-08-24 9:06 ` Gene Chen
2020-08-24 9:06 ` Gene Chen
2020-08-29 17:15 ` Jonathan Cameron
2020-08-29 17:15 ` Jonathan Cameron
2020-08-29 17:15 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202008272024.JFC8esYm%lkp@intel.com \
--to=lkp@intel.com \
--cc=gene.chen.richtek@gmail.com \
--cc=gene_chen@richtek.com \
--cc=jic23@kernel.org \
--cc=kbuild-all@lists.01.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=pmeerw@pmeerw.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.