From 7453d6d45d5587d3d4d4fdaec746db74ac5f7429 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 5 Aug 2021 10:10:55 +0900 Subject: [PATCH 01/12] ASoC: soc-dapm: cleanup cppcheck warning at dapm_wcache_lookup() This patch cleanups below cppcheck warning. sound/soc/soc-dapm.c:653:20: style: The scope of the variable 'wlist' can be reduced. [variableScope] struct list_head *wlist; ^ sound/soc/soc-dapm.c:655:6: style: The scope of the variable 'i' can be reduced. [variableScope] int i = 0; ^ Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87y29gu25d.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 91bf939d5233..92193e9e1084 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -650,12 +650,11 @@ static struct snd_soc_dapm_widget * dapm_wcache_lookup(struct snd_soc_dapm_wcache *wcache, const char *name) { struct snd_soc_dapm_widget *w = wcache->widget; - struct list_head *wlist; - const int depth = 2; - int i = 0; if (w) { - wlist = &w->dapm->card->widgets; + struct list_head *wlist = &w->dapm->card->widgets; + const int depth = 2; + int i = 0; list_for_each_entry_from(w, wlist, list) { if (!strcmp(name, w->name)) From af6b57ab7fdd88e1b251376ee92fd335abd2241e Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 5 Aug 2021 10:11:00 +0900 Subject: [PATCH 02/12] ASoC: soc-dapm: cleanup cppcheck warning at dapm_connect_mux() This patch cleanups below cppcheck warning. sound/soc/soc-dapm.c:751:15: style: The scope of the variable 'val' can be reduced. [variableScope] unsigned int val, item; ^ Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87wnp0u257.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 92193e9e1084..1c0457715008 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -747,10 +747,11 @@ static int dapm_connect_mux(struct snd_soc_dapm_context *dapm, { const struct snd_kcontrol_new *kcontrol = &w->kcontrol_news[0]; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; - unsigned int val, item; + unsigned int item; int i; if (e->reg != SND_SOC_NOPM) { + unsigned int val; val = soc_dapm_read(dapm, e->reg); val = (val >> e->shift_l) & e->mask; item = snd_soc_enum_val_to_item(e, val); From 29155bba18182daf46e0c4c784a2344d44ef082a Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 5 Aug 2021 10:11:05 +0900 Subject: [PATCH 03/12] ASoC: soc-dapm: cleanup cppcheck warning at dapm_set_mixer_path_status() This patch cleanups below cppcheck warning, and its related code. unsigned int val; ^ sound/soc/soc-dapm.c:789:15: style: The scope of the variable 'val' can be reduced. [variableScope] Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87v94ku252.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 1c0457715008..0ccc59287513 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -782,14 +782,14 @@ static void dapm_set_mixer_path_status(struct snd_soc_dapm_path *p, int i, struct soc_mixer_control *mc = (struct soc_mixer_control *) p->sink->kcontrol_news[i].private_value; unsigned int reg = mc->reg; - unsigned int shift = mc->shift; - unsigned int max = mc->max; - unsigned int mask = (1 << fls(max)) - 1; unsigned int invert = mc->invert; - unsigned int val; if (reg != SND_SOC_NOPM) { - val = soc_dapm_read(p->sink->dapm, reg); + unsigned int shift = mc->shift; + unsigned int max = mc->max; + unsigned int mask = (1 << fls(max)) - 1; + unsigned int val = soc_dapm_read(p->sink->dapm, reg); + /* * The nth_path argument allows this function to know * which path of a kcontrol it is setting the initial From a16cfb1bee80e3a3f7cab59a58580258b6d1efcf Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 5 Aug 2021 10:11:10 +0900 Subject: [PATCH 04/12] ASoC: soc-dapm: cleanup cppcheck warning at dapm_new_pga() This patch cleanups below cppcheck warning. sound/soc/soc-dapm.c:1063:9: style: The scope of the variable 'ret' can be reduced. [variableScope] int i, ret; ^ Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87tuk4u24x.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 0ccc59287513..50f49a545596 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -1060,10 +1060,10 @@ static int dapm_new_mux(struct snd_soc_dapm_widget *w) /* create new dapm volume control */ static int dapm_new_pga(struct snd_soc_dapm_widget *w) { - int i, ret; + int i; for (i = 0; i < w->num_kcontrols; i++) { - ret = dapm_create_or_share_kcontrol(w, i); + int ret = dapm_create_or_share_kcontrol(w, i); if (ret < 0) return ret; } From 5c52e48fb1c2ae68b997d81a781ce0104dbbb91a Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 5 Aug 2021 10:11:15 +0900 Subject: [PATCH 05/12] ASoC: soc-dapm: cleanup cppcheck warning at dapm_new_dai_link() This patch cleanups below cppcheck warning, and its related code. sound/soc/soc-dapm.c:1077:9: style: The scope of the variable 'ret' can be reduced. [variableScope] int i, ret; ^ Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87sfzou24s.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 50f49a545596..cce6c9122397 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -1074,10 +1074,7 @@ static int dapm_new_pga(struct snd_soc_dapm_widget *w) /* create new dapm dai link control */ static int dapm_new_dai_link(struct snd_soc_dapm_widget *w) { - int i, ret; - struct snd_kcontrol *kcontrol; - struct snd_soc_dapm_context *dapm = w->dapm; - struct snd_card *card = dapm->card->snd_card; + int i; struct snd_soc_pcm_runtime *rtd = w->priv; /* create control for links with > 1 config */ @@ -1086,9 +1083,12 @@ static int dapm_new_dai_link(struct snd_soc_dapm_widget *w) /* add kcontrol */ for (i = 0; i < w->num_kcontrols; i++) { - kcontrol = snd_soc_cnew(&w->kcontrol_news[i], w, - w->name, NULL); - ret = snd_ctl_add(card, kcontrol); + struct snd_soc_dapm_context *dapm = w->dapm; + struct snd_card *card = dapm->card->snd_card; + struct snd_kcontrol *kcontrol = snd_soc_cnew(&w->kcontrol_news[i], + w, w->name, NULL); + int ret = snd_ctl_add(card, kcontrol); + if (ret < 0) { dev_err(dapm->dev, "ASoC: failed to add widget %s dapm kcontrol %s: %d\n", From 65f7316d18f2b447931eef00c04253859bdbe142 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 5 Aug 2021 10:11:20 +0900 Subject: [PATCH 06/12] ASoC: soc-dapm: cleanup cppcheck warning at dapm_seq_check_event() This patch cleanups below cppcheck warning. sound/soc/soc-dapm.c:1531:13: style: The scope of the variable 'ret' can be reduced. [variableScope] int power, ret; ^ Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87r1f8u24n.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index cce6c9122397..7cb832ddf4af 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -1528,7 +1528,7 @@ static void dapm_seq_check_event(struct snd_soc_card *card, struct snd_soc_dapm_widget *w, int event) { const char *ev_name; - int power, ret; + int power; switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -1564,6 +1564,8 @@ static void dapm_seq_check_event(struct snd_soc_card *card, return; if (w->event && (w->event_flags & event)) { + int ret; + pop_dbg(w->dapm->dev, card->pop_time, "pop test : %s %s\n", w->name, ev_name); soc_dapm_async_complete(w->dapm); From a71657947d74fbc9e0184079f9e1941d70ccb52c Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 5 Aug 2021 10:11:24 +0900 Subject: [PATCH 07/12] ASoC: soc-dapm: cleanup cppcheck warning at dapm_seq_run() This patch cleanups below cppcheck warning. sound/soc/soc-dapm.c:1648:6: style: The scope of the variable 'ret' can be reduced. [variableScope] int ret, i; ^ Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87pmusu24j.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 7cb832ddf4af..bd3b443019fb 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -1647,7 +1647,7 @@ static void dapm_seq_run(struct snd_soc_card *card, int cur_subseq = -1; int cur_reg = SND_SOC_NOPM; struct snd_soc_dapm_context *cur_dapm = NULL; - int ret, i; + int i; int *sort; if (power_up) @@ -1656,7 +1656,7 @@ static void dapm_seq_run(struct snd_soc_card *card, sort = dapm_down_seq; list_for_each_entry_safe(w, n, list, power_list) { - ret = 0; + int ret = 0; /* Do we need to apply any queued changes? */ if (sort[w->id] != cur_sort || w->reg != cur_reg || From fd5ad2346148373890b4e7e7e0b1d7b208772a68 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 5 Aug 2021 10:11:28 +0900 Subject: [PATCH 08/12] ASoC: soc-dapm: cleanup cppcheck warning at snd_soc_dapm_del_route() This patch cleanups below cppcheck warning. sound/soc/soc-dapm.c:3007:30: style: The scope of the variable 'wsource' can be reduced. [variableScope] struct snd_soc_dapm_widget *wsource, *wsink; ^ sound/soc/soc-dapm.c:3007:40: style: The scope of the variable 'wsink' can be reduced. [variableScope] struct snd_soc_dapm_widget *wsource, *wsink; ^ Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87o8acu24f.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index bd3b443019fb..c7fb142f3462 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3006,7 +3006,6 @@ err: static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm, const struct snd_soc_dapm_route *route) { - struct snd_soc_dapm_widget *wsource, *wsink; struct snd_soc_dapm_path *path, *p; const char *sink; const char *source; @@ -3044,8 +3043,8 @@ static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm, } if (path) { - wsource = path->source; - wsink = path->sink; + struct snd_soc_dapm_widget *wsource = path->source; + struct snd_soc_dapm_widget *wsink = path->sink; dapm_mark_dirty(wsource, "Route removed"); dapm_mark_dirty(wsink, "Route removed"); From fcb3f196f808f2d53d3a8f0a728ffd61f9d44e11 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 5 Aug 2021 10:11:33 +0900 Subject: [PATCH 09/12] ASoC: soc-dapm: cleanup cppcheck warning at snd_soc_dapm_add_routes() This patch cleanups below cppcheck warning. sound/soc/soc-dapm.c:3082:9: style: The scope of the variable 'r' can be reduced. [variableScope] int i, r, ret = 0; ^ Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87mtpwu24b.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index c7fb142f3462..9dd50b4899e3 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3080,11 +3080,11 @@ static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm, int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm, const struct snd_soc_dapm_route *route, int num) { - int i, r, ret = 0; + int i, ret = 0; mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); for (i = 0; i < num; i++) { - r = snd_soc_dapm_add_route(dapm, route); + int r = snd_soc_dapm_add_route(dapm, route); if (r < 0) { dev_err(dapm->dev, "ASoC: Failed to add route %s -> %s -> %s\n", route->source, From fd136fdbf4a66add171eb0cedf40f430bda9c139 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 5 Aug 2021 10:11:37 +0900 Subject: [PATCH 10/12] ASoC: soc-dapm: cleanup cppcheck warning at snd_soc_dapm_weak_routes() This patch cleanups below cppcheck warning. sound/soc/soc-dapm.c:3190:9: style: The scope of the variable 'err' can be reduced. [variableScope] int i, err; ^ Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87lf5gu246.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 9dd50b4899e3..6e7fc8979f89 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3188,12 +3188,12 @@ static int snd_soc_dapm_weak_route(struct snd_soc_dapm_context *dapm, int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context *dapm, const struct snd_soc_dapm_route *route, int num) { - int i, err; + int i; int ret = 0; mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT); for (i = 0; i < num; i++) { - err = snd_soc_dapm_weak_route(dapm, route); + int err = snd_soc_dapm_weak_route(dapm, route); if (err) ret = err; route++; From 3dc72e4251d7ccd90517433b84f133d4a18179c3 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 5 Aug 2021 10:11:41 +0900 Subject: [PATCH 11/12] ASoC: soc-dapm: cleanup cppcheck warning at snd_soc_dapm_new_controls() This patch cleanups below cppcheck warning. sound/soc/soc-dapm.c:3786:30: style: The scope of the variable 'w' can be reduced. [variableScope] struct snd_soc_dapm_widget *w; ^ Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87k0l0u242.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 6e7fc8979f89..7fc1659eead4 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3784,13 +3784,12 @@ int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm, const struct snd_soc_dapm_widget *widget, int num) { - struct snd_soc_dapm_widget *w; int i; int ret = 0; mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT); for (i = 0; i < num; i++) { - w = snd_soc_dapm_new_control_unlocked(dapm, widget); + struct snd_soc_dapm_widget *w = snd_soc_dapm_new_control_unlocked(dapm, widget); if (IS_ERR(w)) { ret = PTR_ERR(w); break; From f2ff5fbe343d08e880fb1d10dbbdc335a3ceca4b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 5 Aug 2021 10:11:44 +0900 Subject: [PATCH 12/12] ASoC: soc-dapm: cleanup cppcheck warning at soc_dapm_dai_stream_event() This patch cleanups below cppcheck warning. sound/soc/soc-dapm.c:4368:15: style: The scope of the variable 'ep' can be reduced. [variableScope] unsigned int ep; ^ Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87im0ku23z.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 7fc1659eead4..7b67f1e19ae9 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -4365,11 +4365,12 @@ static void soc_dapm_dai_stream_event(struct snd_soc_dai *dai, int stream, int event) { struct snd_soc_dapm_widget *w; - unsigned int ep; w = snd_soc_dai_get_widget(dai, stream); if (w) { + unsigned int ep; + dapm_mark_dirty(w, "stream event"); if (w->id == snd_soc_dapm_dai_in) {