sound/soc/codecs/tas2780.c:160:14: sparse: sparse: restricted snd_pcm_format_t degrades to integer

From: kernel test robot
Date: Thu Aug 11 2022 - 05:48:44 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: ffcf9c5700e49c0aee42dcba9a12ba21338e8136
commit: eae9f9ce181be4f47dcba1ee93185b71cac3f312 ASoC: add tas2780 driver
date: 5 weeks ago
config: m68k-randconfig-s043-20220810 (https://download.01.org/0day-ci/archive/20220811/202208111707.1sHwh5hK-lkp@xxxxxxxxx/config)
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=eae9f9ce181be4f47dcba1ee93185b71cac3f312
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout eae9f9ce181be4f47dcba1ee93185b71cac3f312
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=m68k SHELL=/bin/bash sound/soc/codecs/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@xxxxxxxxx>

sparse warnings: (new ones prefixed by >>)
>> sound/soc/codecs/tas2780.c:160:14: sparse: sparse: restricted snd_pcm_format_t degrades to integer
sound/soc/codecs/tas2780.c:167:14: sparse: sparse: restricted snd_pcm_format_t degrades to integer
sound/soc/codecs/tas2780.c:174:14: sparse: sparse: restricted snd_pcm_format_t degrades to integer
>> sound/soc/codecs/tas2780.c:288:58: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected int bitwidth @@ got restricted snd_pcm_format_t @@
sound/soc/codecs/tas2780.c:288:58: sparse: expected int bitwidth
sound/soc/codecs/tas2780.c:288:58: sparse: got restricted snd_pcm_format_t

vim +160 sound/soc/codecs/tas2780.c

150
151 static int tas2780_set_bitwidth(struct tas2780_priv *tas2780, int bitwidth)
152 {
153 struct snd_soc_component *component = tas2780->component;
154 int sense_en;
155 int val;
156 int ret;
157 int slot_size;
158
159 switch (bitwidth) {
> 160 case SNDRV_PCM_FORMAT_S16_LE:
161 ret = snd_soc_component_update_bits(component,
162 TAS2780_TDM_CFG2,
163 TAS2780_TDM_CFG2_RXW_MASK,
164 TAS2780_TDM_CFG2_RXW_16BITS);
165 slot_size = TAS2780_TDM_CFG2_RXS_16BITS;
166 break;
167 case SNDRV_PCM_FORMAT_S24_LE:
168 ret = snd_soc_component_update_bits(component,
169 TAS2780_TDM_CFG2,
170 TAS2780_TDM_CFG2_RXW_MASK,
171 TAS2780_TDM_CFG2_RXW_24BITS);
172 slot_size = TAS2780_TDM_CFG2_RXS_24BITS;
173 break;
174 case SNDRV_PCM_FORMAT_S32_LE:
175 ret = snd_soc_component_update_bits(component,
176 TAS2780_TDM_CFG2,
177 TAS2780_TDM_CFG2_RXW_MASK,
178 TAS2780_TDM_CFG2_RXW_32BITS);
179 slot_size = TAS2780_TDM_CFG2_RXS_32BITS;
180 break;
181
182 default:
183 ret = -EINVAL;
184 }
185
186 if (ret < 0) {
187 dev_err(tas2780->dev, "%s:errCode:0x%x set bitwidth error\n",
188 __func__, ret);
189 goto err;
190 }
191
192 ret = snd_soc_component_update_bits(component, TAS2780_TDM_CFG2,
193 TAS2780_TDM_CFG2_RXS_MASK, slot_size);
194 if (ret < 0) {
195 dev_err(tas2780->dev,
196 "%s:errCode:0x%x set RX slot size error\n",
197 __func__, ret);
198 goto err;
199 }
200
201 val = snd_soc_component_read(tas2780->component, TAS2780_PWR_CTRL);
202 if (val < 0) {
203 dev_err(tas2780->dev, "%s:errCode:0x%x read PWR_CTRL error\n",
204 __func__, val);
205 ret = val;
206 goto err;
207 }
208
209 if (val & (1 << TAS2780_VSENSE_POWER_EN))
210 sense_en = 0;
211 else
212 sense_en = TAS2780_TDM_CFG5_VSNS_ENABLE;
213
214 ret = snd_soc_component_update_bits(tas2780->component,
215 TAS2780_TDM_CFG5, TAS2780_TDM_CFG5_VSNS_ENABLE, sense_en);
216 if (ret < 0) {
217 dev_err(tas2780->dev, "%s:errCode:0x%x enable vSNS error\n",
218 __func__, ret);
219 goto err;
220 }
221
222 if (val & (1 << TAS2780_ISENSE_POWER_EN))
223 sense_en = 0;
224 else
225 sense_en = TAS2780_TDM_CFG6_ISNS_ENABLE;
226
227 ret = snd_soc_component_update_bits(tas2780->component,
228 TAS2780_TDM_CFG6, TAS2780_TDM_CFG6_ISNS_ENABLE, sense_en);
229 if (ret < 0) {
230 dev_err(tas2780->dev, "%s:errCode:0x%x enable iSNS error\n",
231 __func__, ret);
232 goto err;
233 }
234 ret = 0;
235 err:
236 return ret;
237 }
238
239 static int tas2780_set_samplerate(
240 struct tas2780_priv *tas2780, int samplerate)
241 {
242 struct snd_soc_component *component = tas2780->component;
243 int ramp_rate_val;
244 int ret;
245
246 switch (samplerate) {
247 case 48000:
248 ramp_rate_val = TAS2780_TDM_CFG0_SMP_48KHZ |
249 TAS2780_TDM_CFG0_44_1_48KHZ;
250 break;
251 case 44100:
252 ramp_rate_val = TAS2780_TDM_CFG0_SMP_44_1KHZ |
253 TAS2780_TDM_CFG0_44_1_48KHZ;
254 break;
255 case 96000:
256 ramp_rate_val = TAS2780_TDM_CFG0_SMP_48KHZ |
257 TAS2780_TDM_CFG0_88_2_96KHZ;
258 break;
259 case 88200:
260 ramp_rate_val = TAS2780_TDM_CFG0_SMP_44_1KHZ |
261 TAS2780_TDM_CFG0_88_2_96KHZ;
262 break;
263 default:
264 return -EINVAL;
265 }
266 ret = snd_soc_component_update_bits(component, TAS2780_TDM_CFG0,
267 TAS2780_TDM_CFG0_SMP_MASK | TAS2780_TDM_CFG0_MASK,
268 ramp_rate_val);
269 if (ret < 0) {
270 dev_err(tas2780->dev,
271 "%s:errCode:0x%x Failed to set ramp_rate_val\n",
272 __func__, ret);
273 goto err;
274 }
275 ret = 0;
276 err:
277 return ret;
278 }
279
280 static int tas2780_hw_params(struct snd_pcm_substream *substream,
281 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
282 {
283 struct snd_soc_component *component = dai->component;
284 struct tas2780_priv *tas2780 =
285 snd_soc_component_get_drvdata(component);
286 int ret;
287
> 288 ret = tas2780_set_bitwidth(tas2780, params_format(params));
289 if (ret < 0)
290 return ret;
291
292 return tas2780_set_samplerate(tas2780, params_rate(params));
293 }
294

--
0-DAY CI Kernel Test Service
https://01.org/lkp