From: Trevor Wu <trevor.wu@mediatek.com>
To: <broonie@kernel.org>, <lgirdwood@gmail.com>, <tiwai@suse.com>,
<perex@perex.cz>, <matthias.bgg@gmail.com>
Cc: <trevor.wu@mediatek.com>, <alsa-devel@alsa-project.org>,
<linux-mediatek@lists.infradead.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <error27@gmail.com>
Subject: [PATCH] ASoC: mediatek: mt8188: remove etdm dead code
Date: Thu, 2 Feb 2023 18:37:04 +0800 [thread overview]
Message-ID: <20230202103704.15626-1-trevor.wu@mediatek.com> (raw)
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: Trevor Wu <trevor.wu@mediatek.com>
---
sound/soc/mediatek/mt8188/mt8188-dai-etdm.c | 33 ++++++---------------
1 file changed, 9 insertions(+), 24 deletions(-)
diff --git a/sound/soc/mediatek/mt8188/mt8188-dai-etdm.c b/sound/soc/mediatek/mt8188/mt8188-dai-etdm.c
index 0b79c1cc293b..071841903c62 100644
--- a/sound/soc/mediatek/mt8188/mt8188-dai-etdm.c
+++ b/sound/soc/mediatek/mt8188/mt8188-dai-etdm.c
@@ -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",
- of_afe_etdms[i].name);
- if (ret < 0) {
- dev_err(afe->dev, "%s snprintf err=%d\n",
- __func__, ret);
- return;
- }
+ snprintf(prop, sizeof(prop), "mediatek,%s-multi-pin-mode",
+ of_afe_etdms[i].name);
+
etdm_data->data_mode = of_property_read_bool(of_node, prop);
- ret = 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;
- }
+ snprintf(prop, sizeof(prop), "mediatek,%s-cowork-source",
+ of_afe_etdms[i].name);
+
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",
- of_afe_etdms[i].name);
- if (ret < 0) {
- dev_err(afe->dev, "%s snprintf err=%d\n",
- __func__, ret);
- return;
- }
+ snprintf(prop, sizeof(prop), "mediatek,%s-chn-disabled",
+ of_afe_etdms[i].name);
+
ret = of_property_read_variable_u8_array(of_node, prop,
disable_chn,
1, max_chn);
--
2.18.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2023-02-02 10:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 10:37 Trevor Wu [this message]
2023-02-02 12:17 ` [PATCH] ASoC: mediatek: mt8188: remove etdm dead code Dan Carpenter
2023-02-03 14:56 ` Mark Brown
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=20230202103704.15626-1-trevor.wu@mediatek.com \
--to=trevor.wu@mediatek.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=error27@gmail.com \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox