[bug report] ASoC: cpcap: new codec
Dan Carpenter
dan.carpenter at oracle.com
Fri Jan 22 09:35:22 CET 2021
Hello Sebastian Reichel,
The patch f6cdf2d3445d: "ASoC: cpcap: new codec" from Feb 23, 2018,
leads to the following static checker warning:
sound/soc/codecs/cpcap.c:1276 cpcap_voice_hw_params()
warn: 'CPCAP_BIT_MIC1_RX_TIMESLOT0' is a shifter (not for '|=').
sound/soc/codecs/cpcap.c:1279 cpcap_voice_hw_params()
warn: 'CPCAP_BIT_MIC2_TIMESLOT0' is a shifter (not for '|=').
sound/soc/codecs/cpcap.c
1253 static int cpcap_voice_hw_params(struct snd_pcm_substream *substream,
1254 struct snd_pcm_hw_params *params,
1255 struct snd_soc_dai *dai)
1256 {
1257 struct snd_soc_component *component = dai->component;
1258 struct device *dev = component->dev;
1259 struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component);
1260 static const u16 reg_cdi = CPCAP_REG_CDI;
1261 int rate = params_rate(params);
1262 int channels = params_channels(params);
1263 int direction = substream->stream;
1264 u16 val, mask;
1265 int err;
1266
1267 dev_dbg(dev, "Voice setup HW params: rate=%d, direction=%d, chan=%d",
1268 rate, direction, channels);
1269
1270 err = cpcap_set_samprate(cpcap, CPCAP_DAI_VOICE, rate);
1271 if (err)
1272 return err;
1273
1274 if (direction == SNDRV_PCM_STREAM_CAPTURE) {
1275 mask = 0x0000;
1276 mask |= CPCAP_BIT_MIC1_RX_TIMESLOT0;
^^^^^^^^^^^^^^^^^^^^^^^^^^^
This should probably be BIT(CPCAP_BIT_MIC1_RX_TIMESLOT0).
1277 mask |= CPCAP_BIT_MIC1_RX_TIMESLOT1;
1278 mask |= CPCAP_BIT_MIC1_RX_TIMESLOT2;
1279 mask |= CPCAP_BIT_MIC2_TIMESLOT0;
^^^^^^^^^^^^^^^^^^^^^^^^
Same for all the others as well I guess.
1280 mask |= CPCAP_BIT_MIC2_TIMESLOT1;
1281 mask |= CPCAP_BIT_MIC2_TIMESLOT2;
1282 val = 0x0000;
1283 if (channels >= 2)
1284 val = BIT(CPCAP_BIT_MIC1_RX_TIMESLOT0);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Here it's BIT(CPCAP_BIT_MIC1_RX_TIMESLOT0).
1285 err = regmap_update_bits(cpcap->regmap, reg_cdi, mask, val);
1286 if (err)
1287 return err;
1288 }
1289
1290 return 0;
1291 }
regards,
dan carpenter
More information about the Alsa-devel
mailing list