Commit 66b9e94c authored by Trevor Wu's avatar Trevor Wu Committed by Mark Brown

ASoC: mediatek: mt8188: remove etdm dead code

Some Smatch static checker warning like below was found.

sound/soc/mediatek/mt8188/mt8188-dai-etdm.c:2487
mt8188_dai_etdm_parse_of()
warn: 'ret' returned from snprintf() might be larger than 48

    2479         for (i = 0; i < MT8188_AFE_IO_ETDM_NUM; i++) {
    2480                 dai_id = ETDM_TO_DAI_ID(i);
    2481                 etdm_data = afe_priv->dai_priv[dai_id];
    2482
    2483                 ret = snprintf(prop, sizeof(prop),
    2484                                "mediatek,%s-multi-pin-mode",
    2485                                of_afe_etdms[i].name);
    2486                 if (ret < 0) {
--> 2487                         dev_err(afe->dev, "%s snprintf
err=%d\n",
    2488

In linux kernel, snprintf() never returns negatives. On the other hand,
the format string like "mediatek,%s-multi-pin-mode" must be smaller
than sizeof(prop)=48.

After discussing in the mail thread[1], I remove the dead code to fix
the Smatch warnings.

[1]: https://lore.kernel.org/all/Y9EdBg641tJDDrt%2F@kili/Signed-off-by: default avatarTrevor Wu <trevor.wu@mediatek.com>
Link: https://lore.kernel.org/r/20230202103704.15626-1-trevor.wu@mediatek.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 218674a4
......@@ -2480,24 +2480,14 @@ static void mt8188_dai_etdm_parse_of(struct mtk_base_afe *afe)
dai_id = ETDM_TO_DAI_ID(i);
etdm_data = afe_priv->dai_priv[dai_id];
ret = snprintf(prop, sizeof(prop),
"mediatek,%s-multi-pin-mode",
snprintf(prop, sizeof(prop), "mediatek,%s-multi-pin-mode",
of_afe_etdms[i].name);
if (ret < 0) {
dev_err(afe->dev, "%s snprintf err=%d\n",
__func__, ret);
return;
}
etdm_data->data_mode = of_property_read_bool(of_node, prop);
ret = snprintf(prop, sizeof(prop),
"mediatek,%s-cowork-source",
snprintf(prop, sizeof(prop), "mediatek,%s-cowork-source",
of_afe_etdms[i].name);
if (ret < 0) {
dev_err(afe->dev, "%s snprintf err=%d\n",
__func__, ret);
return;
}
ret = of_property_read_u32(of_node, prop, &sel);
if (ret == 0) {
if (sel >= MT8188_AFE_IO_ETDM_NUM) {
......@@ -2516,14 +2506,9 @@ static void mt8188_dai_etdm_parse_of(struct mtk_base_afe *afe)
/* etdm in only */
for (i = 0; i < 2; i++) {
ret = snprintf(prop, sizeof(prop),
"mediatek,%s-chn-disabled",
snprintf(prop, sizeof(prop), "mediatek,%s-chn-disabled",
of_afe_etdms[i].name);
if (ret < 0) {
dev_err(afe->dev, "%s snprintf err=%d\n",
__func__, ret);
return;
}
ret = of_property_read_variable_u8_array(of_node, prop,
disable_chn,
1, max_chn);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment