* [bug report] ASoC: codecs: wcd938x: add capture dapm widgets
@ 2021-06-18 6:25 Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2021-06-18 6:25 UTC (permalink / raw
To: srinivas.kandagatla; +Cc: alsa-devel
Hello Srinivas Kandagatla,
The patch d5add08fcbce: "ASoC: codecs: wcd938x: add capture dapm
widgets" from Jun 9, 2021, leads to the following static checker
warning:
sound/soc/codecs/wcd938x.c:2092 wcd938x_tx_swr_ctrl()
error: uninitialized symbol 'rate'.
sound/soc/codecs/wcd938x.c
2064 switch (event) {
2065 case SND_SOC_DAPM_PRE_PMU:
2066 if (strnstr(w->name, "ADC", sizeof("ADC"))) {
Use strncmp() here instead of strnstr().
The sizeof() will include the NUL terminator so it's size 4 and you
wanted 3. The off by one means that strnstr() will do two memcmp()s.
The equivalent of:
if (memcmp(w->name, "ADC", 3) == 0)
return w->name;
if (memcmp(w->name + 1, "ADC", 3) == 0)
return w->name + 1;
return NULL;
2067 int i = 0, mode = 0;
2068
2069 if (test_bit(WCD_ADC1, &wcd938x->status_mask))
2070 mode |= tx_mode_bit[wcd938x->tx_mode[WCD_ADC1]];
2071 if (test_bit(WCD_ADC2, &wcd938x->status_mask))
2072 mode |= tx_mode_bit[wcd938x->tx_mode[WCD_ADC2]];
2073 if (test_bit(WCD_ADC3, &wcd938x->status_mask))
2074 mode |= tx_mode_bit[wcd938x->tx_mode[WCD_ADC3]];
2075 if (test_bit(WCD_ADC4, &wcd938x->status_mask))
2076 mode |= tx_mode_bit[wcd938x->tx_mode[WCD_ADC4]];
2077
2078 if (mode != 0) {
2079 for (i = 0; i < ADC_MODE_ULP2; i++) {
2080 if (mode & (1 << i)) {
2081 i++;
2082 break;
2083 }
2084 }
2085 }
2086 rate = wcd938x_get_clk_rate(i);
2087 wcd938x_set_swr_clk_rate(component, rate, bank);
2088 }
2089
2090 if (strnstr(w->name, "ADC", sizeof("ADC")))
2091 /* Copy clk settings to active bank */
2092 wcd938x_set_swr_clk_rate(component, rate, !bank);
This a false positive, but you could silence it by combining it with the
previous if block.
2093 break;
2094 case SND_SOC_DAPM_POST_PMD:
2095 if (strnstr(w->name, "ADC", sizeof("ADC"))) {
2096 rate = wcd938x_get_clk_rate(ADC_MODE_INVALID);
2097 wcd938x_set_swr_clk_rate(component, rate, !bank);
2098 wcd938x_set_swr_clk_rate(component, rate, bank);
2099 }
2100 break;
2101 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* [bug report] ASoC: codecs: wcd938x: add capture dapm widgets
@ 2021-06-18 9:17 Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2021-06-18 9:17 UTC (permalink / raw
To: srinivas.kandagatla; +Cc: alsa-devel
Hello Srinivas Kandagatla,
The patch d5add08fcbce: "ASoC: codecs: wcd938x: add capture dapm
widgets" from Jun 9, 2021, leads to the following static checker
warning:
sound/soc/codecs/wcd938x.c:2189 wcd938x_tx_channel_config()
error: uninitialized symbol 'reg'.
sound/soc/codecs/wcd938x.c
2165 static void wcd938x_tx_channel_config(struct snd_soc_component *component,
2166 int channel, int mode)
2167 {
2168 int reg, mask;
2169
2170 switch (channel) {
2171 case 0:
2172 reg = WCD938X_ANA_TX_CH2;
2173 mask = WCD938X_HPF1_INIT_MASK;
2174 break;
2175 case 1:
2176 reg = WCD938X_ANA_TX_CH2;
2177 mask = WCD938X_HPF2_INIT_MASK;
2178 break;
2179 case 2:
2180 reg = WCD938X_ANA_TX_CH4;
2181 mask = WCD938X_HPF3_INIT_MASK;
2182 break;
2183 case 3:
2184 reg = WCD938X_ANA_TX_CH4;
2185 mask = WCD938X_HPF4_INIT_MASK;
2186 break;
We could add a default case?
default:
return;
2187 }
2188
2189 snd_soc_component_write_field(component, reg, mask, mode);
2190 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-18 9:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-18 9:17 [bug report] ASoC: codecs: wcd938x: add capture dapm widgets Dan Carpenter
-- strict thread matches above, loose matches on Subject: below --
2021-06-18 6:25 Dan Carpenter
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.