[PATCH 00/11] ASoC: soc-dapm.c random cleanups
Hi Mark
These are random cleanup for soc-dpam.c/h. Basically, these are just cleanup, nothing changed.
Kuninori Morimoto (11): ASoC: soc-dapm.c: replace snd_soc_dapm_wcache to snd_soc_dapm_widget ASoC: soc-dapm.c: tidyup error handling on snd_soc_dapm_add_route() ASoC: soc-dapm.c: remove no meaning variable from snd_soc_dapm_add_path() ASoC: soc-dapm.c: ignore parameter NULL at snd_soc_dapm_free_widget() ASoC: soc-dapm.c: cleanup dapm_widget_set_power() ASoC: soc-dapm.c: merge dapm_power_one_widget() and dapm_widget_set_power() ASoC: soc-dapm.c: cleanup snd_soc_dapm_new_dai() ASoC: soc-dapm.c: numerical order for dapm_up_seq ASoC: soc-dapm.h: cleanup white space ASoC: soc-dapm.h: fixup comment for snd_soc_dapm_widget_for_each_path() ASoC: soc-dpcm.h: remove snd_soc_dpcm::hw_param
include/sound/soc-dapm.h | 188 +++++++++++++++---------------------- include/sound/soc-dpcm.h | 2 - sound/soc/codecs/hda.c | 6 +- sound/soc/intel/avs/pcm.c | 6 +- sound/soc/sh/rcar/core.c | 3 +- sound/soc/soc-dapm.c | 189 ++++++++++++++++---------------------- sound/soc/soc-pcm.c | 12 ++- 7 files changed, 170 insertions(+), 236 deletions(-)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current ASoC has snd_soc_dapm_wcache, but its member is only snd_soc_dapm_widget.
struct snd_soc_dapm_wcache { struct snd_soc_dapm_widget *widget; };
It is no meaning for now, and makes code unreadable. This patch replace snd_soc_dapm_wcache to snd_soc_dapm_widget directly.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc-dapm.h | 9 ++------- sound/soc/soc-dapm.c | 29 +++++++++-------------------- 2 files changed, 11 insertions(+), 27 deletions(-)
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index ebb8e7a7fc29..29d5700393c6 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -450,7 +450,6 @@ int snd_soc_dapm_del_routes(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); void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w); -void snd_soc_dapm_reset_cache(struct snd_soc_dapm_context *dapm);
/* dapm events */ void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, @@ -680,10 +679,6 @@ struct snd_soc_dapm_update { bool has_second_set; };
-struct snd_soc_dapm_wcache { - struct snd_soc_dapm_widget *widget; -}; - /* DAPM context */ struct snd_soc_dapm_context { enum snd_soc_bias_level bias_level; @@ -699,8 +694,8 @@ struct snd_soc_dapm_context { enum snd_soc_bias_level target_bias_level; struct list_head list;
- struct snd_soc_dapm_wcache path_sink_cache; - struct snd_soc_dapm_wcache path_source_cache; + struct snd_soc_dapm_widget *wcache_sink; + struct snd_soc_dapm_widget *wcache_source;
#ifdef CONFIG_DEBUG_FS struct dentry *debugfs_dapm; diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index d515e7a78ea8..1796863bff1b 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -652,10 +652,8 @@ static void soc_dapm_async_complete(struct snd_soc_dapm_context *dapm) }
static struct snd_soc_dapm_widget * -dapm_wcache_lookup(struct snd_soc_dapm_wcache *wcache, const char *name) +dapm_wcache_lookup(struct snd_soc_dapm_widget *w, const char *name) { - struct snd_soc_dapm_widget *w = wcache->widget; - if (w) { struct list_head *wlist = &w->dapm->card->widgets; const int depth = 2; @@ -673,12 +671,6 @@ dapm_wcache_lookup(struct snd_soc_dapm_wcache *wcache, const char *name) return NULL; }
-static inline void dapm_wcache_update(struct snd_soc_dapm_wcache *wcache, - struct snd_soc_dapm_widget *w) -{ - wcache->widget = w; -} - /** * snd_soc_dapm_force_bias_level() - Sets the DAPM bias level * @dapm: The DAPM context for which to set the level @@ -2516,12 +2508,6 @@ void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w) } EXPORT_SYMBOL_GPL(snd_soc_dapm_free_widget);
-void snd_soc_dapm_reset_cache(struct snd_soc_dapm_context *dapm) -{ - dapm->path_sink_cache.widget = NULL; - dapm->path_source_cache.widget = NULL; -} - /* free all dapm widgets and resources */ static void dapm_free_widgets(struct snd_soc_dapm_context *dapm) { @@ -2532,7 +2518,9 @@ static void dapm_free_widgets(struct snd_soc_dapm_context *dapm) continue; snd_soc_dapm_free_widget(w); } - snd_soc_dapm_reset_cache(dapm); + + dapm->wcache_sink = NULL; + dapm->wcache_source = NULL; }
static struct snd_soc_dapm_widget *dapm_find_widget( @@ -2961,8 +2949,8 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm, source = route->source; }
- wsource = dapm_wcache_lookup(&dapm->path_source_cache, source); - wsink = dapm_wcache_lookup(&dapm->path_sink_cache, sink); + wsource = dapm_wcache_lookup(dapm->wcache_source, source); + wsink = dapm_wcache_lookup(dapm->wcache_sink, sink);
if (wsink && wsource) goto skip_search; @@ -3018,8 +3006,9 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm, }
skip_search: - dapm_wcache_update(&dapm->path_sink_cache, wsink); - dapm_wcache_update(&dapm->path_source_cache, wsource); + /* update cache */ + dapm->wcache_sink = wsink; + dapm->wcache_source = wsource;
ret = snd_soc_dapm_add_path(dapm, wsource, wsink, route->control, route->connected);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current error handling on snd_soc_dapm_add_route() has some wastes. It indicates *own* error message *only* for sink or source, and return error directly at (A). OTOH, it has similar error message at (B) which indicates *both* sink/source.
And more, (A) is using dev_err(), (B) is using dev_warn(). (B) is caring prefix, but (A) is not.
(X) int snd_soc_dapm_add_route(...) { ... if (wsource == NULL) { (A) dev_err(...); return -ENODEV; } if (wsink == NULL) { (A) dev_err(...); return -ENODEV; }
...
ret = snd_soc_dapm_add_path(...); if (ret) (B) goto err;
return 0; err: (B) dev_warn(...); return ret; }
Above snd_soc_dapm_add_route() (= X) is called from snd_soc_dapm_add_routes() (= Y). (X) will indicate error message by itself, but (Y) will indicate own error message at (C). (C) is duplicated.
(Y) int snd_soc_dapm_add_routes(...) { ... for (...) { (X) int r = snd_soc_dapm_add_route(...); if (r < 0) { (C) dev_err(...); ret = r; } ... } ... }
This patch (1) merges these error message (= A,B) into one, (2) use dev_err(), (3) remove duplicate error message (= C) from snd_soc_dapm_add_routes().
By this patch, it will indicate error message like this.
- error message with prefix - not found widget will have "(*)" mark - it indicates [control] if exists.
ex) [if no sink with control]
ASoC: Failed to add route SOURCE -> [CTRL] -> SINK(*)
[if no source without control]
ASoC: Failed to add route SOURCE(*) -> SINK
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-dapm.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 1796863bff1b..b4f876dff994 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -2994,16 +2994,11 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm, if (!wsource) wsource = wtsource;
- if (wsource == NULL) { - dev_err(dapm->dev, "ASoC: no source widget found for %s\n", - route->source); - return -ENODEV; - } - if (wsink == NULL) { - dev_err(dapm->dev, "ASoC: no sink widget found for %s\n", - route->sink); - return -ENODEV; - } + ret = -ENODEV; + if (!wsource) + goto err; + if (!wsink) + goto err;
skip_search: /* update cache */ @@ -3012,13 +3007,14 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
ret = snd_soc_dapm_add_path(dapm, wsource, wsink, route->control, route->connected); - if (ret) - goto err; - - return 0; err: - dev_warn(dapm->dev, "ASoC: no dapm match for %s --> %s --> %s\n", - source, route->control, sink); + if (ret) + dev_err(dapm->dev, "ASoC: Failed to add route %s%s -%s%s%s> %s%s\n", + source, !wsource ? "(*)" : "", + !route->control ? "" : "> [", + !route->control ? "" : route->control, + !route->control ? "" : "] -", + sink, !wsink ? "(*)" : ""); return ret; }
@@ -3104,13 +3100,8 @@ int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm, mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); for (i = 0; i < num; i++) { 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, - route->control ? route->control : "direct", - route->sink); + if (r < 0) ret = r; - } route++; } mutex_unlock(&dapm->card->dapm_mutex);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
snd_soc_dapm_add_path() is using local variable "widgets[]", but it is same as path->node[]. This is no meaning and duplicate operation. This patch removes "widgets[]".
path->node[SND_SOC_DAPM_DIR_IN] = wsource; path->node[SND_SOC_DAPM_DIR_OUT] = wsink; widgets[SND_SOC_DAPM_DIR_IN] = wsource; widgets[SND_SOC_DAPM_DIR_OUT] = wsink;
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-dapm.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index b4f876dff994..f9c4fd11853c 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -2826,7 +2826,6 @@ static int snd_soc_dapm_add_path(struct snd_soc_dapm_context *dapm, int (*connected)(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink)) { - struct snd_soc_dapm_widget *widgets[2]; enum snd_soc_dapm_direction dir; struct snd_soc_dapm_path *path; int ret; @@ -2862,8 +2861,6 @@ static int snd_soc_dapm_add_path(struct snd_soc_dapm_context *dapm,
path->node[SND_SOC_DAPM_DIR_IN] = wsource; path->node[SND_SOC_DAPM_DIR_OUT] = wsink; - widgets[SND_SOC_DAPM_DIR_IN] = wsource; - widgets[SND_SOC_DAPM_DIR_OUT] = wsink;
path->connected = connected; INIT_LIST_HEAD(&path->list); @@ -2905,12 +2902,13 @@ static int snd_soc_dapm_add_path(struct snd_soc_dapm_context *dapm, }
list_add(&path->list, &dapm->card->paths); + snd_soc_dapm_for_each_direction(dir) - list_add(&path->list_node[dir], &widgets[dir]->edges[dir]); + list_add(&path->list_node[dir], &path->node[dir]->edges[dir]);
snd_soc_dapm_for_each_direction(dir) { - dapm_update_widget_flags(widgets[dir]); - dapm_mark_dirty(widgets[dir], "Route added"); + dapm_update_widget_flags(path->node[dir]); + dapm_mark_dirty(path->node[dir], "Route added"); }
if (dapm->card->instantiated && path->connect)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Currently snd_soc_dapm_free_widget() is assuming input parameter is non NULL. Thus, caller need to care about it. This patch care it at snd_soc_dapm_free_widget().
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/codecs/hda.c | 6 ++---- sound/soc/intel/avs/pcm.c | 6 ++---- sound/soc/soc-dapm.c | 3 +++ 3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/sound/soc/codecs/hda.c b/sound/soc/codecs/hda.c index 61e8e9be6b8d..a79916ff351f 100644 --- a/sound/soc/codecs/hda.c +++ b/sound/soc/codecs/hda.c @@ -130,10 +130,8 @@ static void hda_codec_unregister_dais(struct hda_codec *codec, if (strcmp(dai->driver->name, pcm->name)) continue;
- if (dai->playback_widget) - snd_soc_dapm_free_widget(dai->playback_widget); - if (dai->capture_widget) - snd_soc_dapm_free_widget(dai->capture_widget); + snd_soc_dapm_free_widget(dai->playback_widget); + snd_soc_dapm_free_widget(dai->capture_widget); snd_soc_unregister_dai(dai); break; } diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c index 8fe5917b1e26..8037b15cbdcf 100644 --- a/sound/soc/intel/avs/pcm.c +++ b/sound/soc/intel/avs/pcm.c @@ -1016,10 +1016,8 @@ static void avs_component_hda_unregister_dais(struct snd_soc_component *componen if (!strstr(dai->driver->name, name)) continue;
- if (dai->playback_widget) - snd_soc_dapm_free_widget(dai->playback_widget); - if (dai->capture_widget) - snd_soc_dapm_free_widget(dai->capture_widget); + snd_soc_dapm_free_widget(dai->playback_widget); + snd_soc_dapm_free_widget(dai->capture_widget); snd_soc_unregister_dai(dai); } } diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index f9c4fd11853c..5280a1aafb92 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -2489,6 +2489,9 @@ void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w) struct snd_soc_dapm_path *p, *next_p; enum snd_soc_dapm_direction dir;
+ if (!w) + return; + list_del(&w->list); list_del(&w->dirty); /*
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
This patch cleanup dapm_widget_set_power() comment, parenthesis, and 100 chars. It has no meaning, nothing will be changed.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-dapm.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 5280a1aafb92..d4281e776e44 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -1884,18 +1884,19 @@ static void dapm_widget_set_power(struct snd_soc_dapm_widget *w, bool power,
trace_snd_soc_dapm_widget_power(w, power);
- /* If we changed our power state perhaps our neigbours changed - * also. + /* + * If we changed our power state perhaps our neigbours + * changed also. */ snd_soc_dapm_widget_for_each_source_path(w, path) dapm_widget_set_peer_power(path->source, power, path->connect);
- /* Supplies can't affect their outputs, only their inputs */ - if (!w->is_supply) { + /* + * Supplies can't affect their outputs, only their inputs + */ + if (!w->is_supply) snd_soc_dapm_widget_for_each_sink_path(w, path) - dapm_widget_set_peer_power(path->sink, power, - path->connect); - } + dapm_widget_set_peer_power(path->sink, power, path->connect);
if (power) dapm_seq_insert(w, up_list, true);
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
dapm_widget_set_power() (= X) is called only from dapm_power_one_widget() (= Y), and total purpose of these functions are calling dapm_seq_insert() (= a) accordingly for each widget.
(X) static void dapm_widget_set_power(...) { ... if (power) (a) dapm_seq_insert(w, up_list, true); else (a) dapm_seq_insert(w, down_list, false); }
(Y) static void dapm_power_one_widget(...) { ..
switch (w->id) { case snd_soc_dapm_pre: (a) dapm_seq_insert(w, down_list, false); break; case snd_soc_dapm_post: (a) dapm_seq_insert(w, up_list, true); break;
default: power = dapm_widget_power_check(w);
(X) dapm_widget_set_power(w, power, up_list, down_list); break; } }
It should be more simple, but the code is unnecessarily complicated, and difficult to read/understand. This patch merge these into one.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-dapm.c | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index d4281e776e44..764830a51d2d 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -1873,11 +1873,24 @@ static void dapm_widget_set_peer_power(struct snd_soc_dapm_widget *peer, dapm_mark_dirty(peer, "peer state change"); }
-static void dapm_widget_set_power(struct snd_soc_dapm_widget *w, bool power, +static void dapm_power_one_widget(struct snd_soc_dapm_widget *w, struct list_head *up_list, struct list_head *down_list) { struct snd_soc_dapm_path *path; + int power; + + switch (w->id) { + case snd_soc_dapm_pre: + power = 0; + goto end; + case snd_soc_dapm_post: + power = 1; + goto end; + default: + } + + power = dapm_widget_power_check(w);
if (w->power == power) return; @@ -1897,35 +1910,13 @@ static void dapm_widget_set_power(struct snd_soc_dapm_widget *w, bool power, if (!w->is_supply) snd_soc_dapm_widget_for_each_sink_path(w, path) dapm_widget_set_peer_power(path->sink, power, path->connect); - +end: if (power) dapm_seq_insert(w, up_list, true); else dapm_seq_insert(w, down_list, false); }
-static void dapm_power_one_widget(struct snd_soc_dapm_widget *w, - struct list_head *up_list, - struct list_head *down_list) -{ - int power; - - switch (w->id) { - case snd_soc_dapm_pre: - dapm_seq_insert(w, down_list, false); - break; - case snd_soc_dapm_post: - dapm_seq_insert(w, up_list, true); - break; - - default: - power = dapm_widget_power_check(w); - - dapm_widget_set_power(w, power, up_list, down_list); - break; - } -} - static bool dapm_idle_bias_off(struct snd_soc_dapm_context *dapm) { if (dapm->idle_bias_off)
On 10/18/2022 1:37 AM, Kuninori Morimoto wrote:
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
dapm_widget_set_power() (= X) is called only from dapm_power_one_widget() (= Y), and total purpose of these functions are calling dapm_seq_insert() (= a) accordingly for each widget.
(X) static void dapm_widget_set_power(...) { ... if (power) (a) dapm_seq_insert(w, up_list, true); else (a) dapm_seq_insert(w, down_list, false); }
(Y) static void dapm_power_one_widget(...) { ..
switch (w->id) { case snd_soc_dapm_pre:
(a) dapm_seq_insert(w, down_list, false); break; case snd_soc_dapm_post: (a) dapm_seq_insert(w, up_list, true); break;
default: power = dapm_widget_power_check(w);
(X) dapm_widget_set_power(w, power, up_list, down_list); break; } }
It should be more simple, but the code is unnecessarily complicated, and difficult to read/understand. This patch merge these into one.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
sound/soc/soc-dapm.c | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index d4281e776e44..764830a51d2d 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -1873,11 +1873,24 @@ static void dapm_widget_set_peer_power(struct snd_soc_dapm_widget *peer, dapm_mark_dirty(peer, "peer state change"); }
-static void dapm_widget_set_power(struct snd_soc_dapm_widget *w, bool power, +static void dapm_power_one_widget(struct snd_soc_dapm_widget *w, struct list_head *up_list, struct list_head *down_list) { struct snd_soc_dapm_path *path;
- int power;
- switch (w->id) {
- case snd_soc_dapm_pre:
power = 0;
goto end;
- case snd_soc_dapm_post:
power = 1;
goto end;
- default:
- }
This introduces build error when applied:
sound/soc/soc-dapm.c: In function ‘dapm_power_one_widget’: sound/soc/soc-dapm.c:1890:2: error: label at end of compound statement 1890 | default: | ^~~~~~~
(May be because of CONFIG_WERROR, but still it would be a warning at least...)
power = dapm_widget_power_check(w);
if (w->power == power) return;
@@ -1897,35 +1910,13 @@ static void dapm_widget_set_power(struct snd_soc_dapm_widget *w, bool power, if (!w->is_supply) snd_soc_dapm_widget_for_each_sink_path(w, path) dapm_widget_set_peer_power(path->sink, power, path->connect);
+end: if (power) dapm_seq_insert(w, up_list, true); else dapm_seq_insert(w, down_list, false); }
-static void dapm_power_one_widget(struct snd_soc_dapm_widget *w,
struct list_head *up_list,
struct list_head *down_list)
-{
- int power;
- switch (w->id) {
- case snd_soc_dapm_pre:
dapm_seq_insert(w, down_list, false);
break;
- case snd_soc_dapm_post:
dapm_seq_insert(w, up_list, true);
break;
- default:
power = dapm_widget_power_check(w);
dapm_widget_set_power(w, power, up_list, down_list);
break;
- }
-}
- static bool dapm_idle_bias_off(struct snd_soc_dapm_context *dapm) { if (dapm->idle_bias_off)
On Tue, Oct 18, 2022 at 12:47:24PM +0200, Amadeusz Sławiński wrote:
On 10/18/2022 1:37 AM, Kuninori Morimoto wrote:
- default:
- }
This introduces build error when applied:
sound/soc/soc-dapm.c: In function ‘dapm_power_one_widget’: sound/soc/soc-dapm.c:1890:2: error: label at end of compound statement 1890 | default: | ^~~~~~~
(May be because of CONFIG_WERROR, but still it would be a warning at least...)
Probably also depends on toolchain. In any case a break; is needed there.
Hi Amadeusz, Mark
- default:
- }
This introduces build error when applied:
sound/soc/soc-dapm.c: In function ‘dapm_power_one_widget’: sound/soc/soc-dapm.c:1890:2: error: label at end of compound statement 1890 | default: | ^~~~~~~
(May be because of CONFIG_WERROR, but still it would be a warning at least...)
Probably also depends on toolchain. In any case a break; is needed there.
Thank you for pointing it. I didn't get such error/warning... will send v2 patch, soon.
Thank you for your help !!
Best regards --- Kuninori Morimoto
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
snd_soc_dapm_new_dai() setups local variable "template" at (X) and (Y), which is used at (Z). But these are difficult to read.
static struct snd_soc_dapm_widget * snd_soc_dapm_new_dai() { ...
^ template.reg = ... | template.id = ... (X) template.name = ... | template.event = ... | template.event_flags = ... v template.kcontrol_news = ...
if (rtd->dai_link->num_params > 1) { ... ^ template.num_kcontrols = ... (Y) template.kcontrol_news = ... v ... }
... (Z) w = snd_soc_dapm_new_control_unlocked(..., &template);
}
And this function has error message, but not for all cases. This patch (1) setups "template" in one place, and indicate error message for all cases. This patch cleanup the code, but nothing changed for meaning.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-dapm.c | 56 ++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 28 deletions(-)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 764830a51d2d..92140a78573d 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -4130,56 +4130,53 @@ snd_soc_dapm_new_dai(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); struct snd_soc_dapm_widget template; struct snd_soc_dapm_widget *w; + const struct snd_kcontrol_new *kcontrol_news; + int num_kcontrols; const char **w_param_text; unsigned long private_value = 0; char *link_name; - int ret; + int ret = -ENOMEM;
link_name = devm_kasprintf(card->dev, GFP_KERNEL, "%s-%s", rtd->dai_link->name, id); if (!link_name) - return ERR_PTR(-ENOMEM); - - memset(&template, 0, sizeof(template)); - template.reg = SND_SOC_NOPM; - template.id = snd_soc_dapm_dai_link; - template.name = link_name; - template.event = snd_soc_dai_link_event; - template.event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | - SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD; - template.kcontrol_news = NULL; + goto name_fail;
/* allocate memory for control, only in case of multiple configs */ + w_param_text = NULL; + kcontrol_news = NULL; + num_kcontrols = 0; if (rtd->dai_link->num_params > 1) { w_param_text = devm_kcalloc(card->dev, rtd->dai_link->num_params, sizeof(char *), GFP_KERNEL); - if (!w_param_text) { - ret = -ENOMEM; + if (!w_param_text) goto param_fail; - }
- template.num_kcontrols = 1; - template.kcontrol_news = - snd_soc_dapm_alloc_kcontrol(card, - link_name, - rtd->dai_link->params, - rtd->dai_link->num_params, - w_param_text, &private_value); - if (!template.kcontrol_news) { - ret = -ENOMEM; + num_kcontrols = 1; + kcontrol_news = snd_soc_dapm_alloc_kcontrol(card, link_name, + rtd->dai_link->params, + rtd->dai_link->num_params, + w_param_text, &private_value); + if (!kcontrol_news) goto param_fail; - } - } else { - w_param_text = NULL; } + + memset(&template, 0, sizeof(template)); + template.reg = SND_SOC_NOPM; + template.id = snd_soc_dapm_dai_link; + template.name = link_name; + template.event = snd_soc_dai_link_event; + template.event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD; + template.kcontrol_news = kcontrol_news; + template.num_kcontrols = num_kcontrols; + dev_dbg(card->dev, "ASoC: adding %s widget\n", link_name);
w = snd_soc_dapm_new_control_unlocked(&card->dapm, &template); if (IS_ERR(w)) { ret = PTR_ERR(w); - dev_err(rtd->dev, "ASoC: Failed to create %s widget: %d\n", - link_name, ret); goto outfree_kcontrol_news; }
@@ -4193,6 +4190,9 @@ snd_soc_dapm_new_dai(struct snd_soc_card *card, rtd->dai_link->num_params, w_param_text); param_fail: devm_kfree(card->dev, link_name); +name_fail: + dev_err(rtd->dev, "ASoC: Failed to create %s-%s widget: %d\n", + rtd->dai_link->name, id, ret); return ERR_PTR(ret); }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
dapm_up_seq is arranged in numerical order, but _dai_link is out of order. This patch tidyup it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-dapm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 92140a78573d..e1657eb78fdc 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -71,9 +71,9 @@ static int dapm_up_seq[] = { [snd_soc_dapm_pinctrl] = 2, [snd_soc_dapm_clock_supply] = 2, [snd_soc_dapm_supply] = 3, + [snd_soc_dapm_dai_link] = 3, [snd_soc_dapm_micbias] = 4, [snd_soc_dapm_vmid] = 4, - [snd_soc_dapm_dai_link] = 3, [snd_soc_dapm_dai_in] = 5, [snd_soc_dapm_dai_out] = 5, [snd_soc_dapm_aif_in] = 5,
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
soc-dapm.h defines many things, but it is using randam white space and tag. This patch do nothing, but cleanup its white space. This patch cleanup also 100 char in 1 line.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc-dapm.h | 173 ++++++++++++++++----------------------- 1 file changed, 71 insertions(+), 102 deletions(-)
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 29d5700393c6..44597e63344d 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -341,31 +341,27 @@ struct soc_enum; #define SND_SOC_DAPM_STREAM_STOP 0x2 #define SND_SOC_DAPM_STREAM_SUSPEND 0x4 #define SND_SOC_DAPM_STREAM_RESUME 0x8 -#define SND_SOC_DAPM_STREAM_PAUSE_PUSH 0x10 +#define SND_SOC_DAPM_STREAM_PAUSE_PUSH 0x10 #define SND_SOC_DAPM_STREAM_PAUSE_RELEASE 0x20
/* dapm event types */ -#define SND_SOC_DAPM_PRE_PMU 0x1 /* before widget power up */ -#define SND_SOC_DAPM_POST_PMU 0x2 /* after widget power up */ -#define SND_SOC_DAPM_PRE_PMD 0x4 /* before widget power down */ -#define SND_SOC_DAPM_POST_PMD 0x8 /* after widget power down */ -#define SND_SOC_DAPM_PRE_REG 0x10 /* before audio path setup */ -#define SND_SOC_DAPM_POST_REG 0x20 /* after audio path setup */ -#define SND_SOC_DAPM_WILL_PMU 0x40 /* called at start of sequence */ -#define SND_SOC_DAPM_WILL_PMD 0x80 /* called at start of sequence */ -#define SND_SOC_DAPM_PRE_POST_PMD \ - (SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD) -#define SND_SOC_DAPM_PRE_POST_PMU \ - (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU) +#define SND_SOC_DAPM_PRE_PMU 0x1 /* before widget power up */ +#define SND_SOC_DAPM_POST_PMU 0x2 /* after widget power up */ +#define SND_SOC_DAPM_PRE_PMD 0x4 /* before widget power down */ +#define SND_SOC_DAPM_POST_PMD 0x8 /* after widget power down */ +#define SND_SOC_DAPM_PRE_REG 0x10 /* before audio path setup */ +#define SND_SOC_DAPM_POST_REG 0x20 /* after audio path setup */ +#define SND_SOC_DAPM_WILL_PMU 0x40 /* called at start of sequence */ +#define SND_SOC_DAPM_WILL_PMD 0x80 /* called at start of sequence */ +#define SND_SOC_DAPM_PRE_POST_PMD (SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD) +#define SND_SOC_DAPM_PRE_POST_PMU (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU)
/* convenience event type detection */ -#define SND_SOC_DAPM_EVENT_ON(e) \ - (e & (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU)) -#define SND_SOC_DAPM_EVENT_OFF(e) \ - (e & (SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD)) +#define SND_SOC_DAPM_EVENT_ON(e) (e & (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU)) +#define SND_SOC_DAPM_EVENT_OFF(e) (e & (SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD))
/* regulator widget flags */ -#define SND_SOC_DAPM_REGULATOR_BYPASS 0x1 /* bypass when disabled */ +#define SND_SOC_DAPM_REGULATOR_BYPASS 0x1 /* bypass when disabled */
struct snd_soc_dapm_widget; enum snd_soc_dapm_type; @@ -396,18 +392,13 @@ enum snd_soc_bias_level { SND_SOC_BIAS_ON = 3, };
-int dapm_regulator_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event); -int dapm_clock_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event); -int dapm_pinctrl_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event); +int dapm_regulator_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event); +int dapm_clock_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event); +int dapm_pinctrl_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event);
/* dapm controls */ -int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol); -int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol); +int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); +int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, @@ -419,30 +410,24 @@ int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol, int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *uncontrol); 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 *snd_soc_dapm_new_control( - struct snd_soc_dapm_context *dapm, + const struct snd_soc_dapm_widget *widget, int num); +struct snd_soc_dapm_widget *snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, const struct snd_soc_dapm_widget *widget); -struct snd_soc_dapm_widget *snd_soc_dapm_new_control_unlocked( - struct snd_soc_dapm_context *dapm, +struct snd_soc_dapm_widget *snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm, const struct snd_soc_dapm_widget *widget); -int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm, - struct snd_soc_dai *dai); +int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm, struct snd_soc_dai *dai); void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w); int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card); void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card);
int snd_soc_dapm_update_dai(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai); + struct snd_pcm_hw_params *params, struct snd_soc_dai *dai);
/* dapm path setup */ int snd_soc_dapm_new_widgets(struct snd_soc_card *card); void snd_soc_dapm_free(struct snd_soc_dapm_context *dapm); void snd_soc_dapm_init(struct snd_soc_dapm_context *dapm, - struct snd_soc_card *card, - struct snd_soc_component *component); + struct snd_soc_card *card, struct snd_soc_component *component); int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm, const struct snd_soc_dapm_route *route, int num); int snd_soc_dapm_del_routes(struct snd_soc_dapm_context *dapm, @@ -452,46 +437,34 @@ int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context *dapm, void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w);
/* dapm events */ -void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, - int event); +void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, int event); void snd_soc_dapm_stream_stop(struct snd_soc_pcm_runtime *rtd, int stream); void snd_soc_dapm_shutdown(struct snd_soc_card *card);
/* external DAPM widget events */ int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm, - struct snd_kcontrol *kcontrol, int connect, - struct snd_soc_dapm_update *update); + struct snd_kcontrol *kcontrol, int connect, struct snd_soc_dapm_update *update); int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_context *dapm, struct snd_kcontrol *kcontrol, int mux, struct soc_enum *e, struct snd_soc_dapm_update *update);
/* dapm sys fs - used by the core */ extern struct attribute *soc_dapm_dev_attrs[]; -void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, - struct dentry *parent); +void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, struct dentry *parent);
/* dapm audio pin control and status */ -int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, - const char *pin); -int snd_soc_dapm_enable_pin_unlocked(struct snd_soc_dapm_context *dapm, - const char *pin); -int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm, - const char *pin); -int snd_soc_dapm_disable_pin_unlocked(struct snd_soc_dapm_context *dapm, - const char *pin); +int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin); +int snd_soc_dapm_enable_pin_unlocked(struct snd_soc_dapm_context *dapm, const char *pin); +int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm, const char *pin); +int snd_soc_dapm_disable_pin_unlocked(struct snd_soc_dapm_context *dapm, const char *pin); int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin); -int snd_soc_dapm_nc_pin_unlocked(struct snd_soc_dapm_context *dapm, - const char *pin); -int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm, - const char *pin); +int snd_soc_dapm_nc_pin_unlocked(struct snd_soc_dapm_context *dapm, const char *pin); +int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm, const char *pin); int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm); int snd_soc_dapm_sync_unlocked(struct snd_soc_dapm_context *dapm); -int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm, - const char *pin); -int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context *dapm, - const char *pin); -int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm, - const char *pin); +int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin); +int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context *dapm, const char *pin); +int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm, const char *pin); unsigned int dapm_kcontrol_get_value(const struct snd_kcontrol *kcontrol);
/* Mostly internal - should not normally be used */ @@ -500,40 +473,35 @@ void dapm_mark_endpoints_dirty(struct snd_soc_card *card); /* dapm path query */ int snd_soc_dapm_dai_get_connected_widgets(struct snd_soc_dai *dai, int stream, struct snd_soc_dapm_widget_list **list, - bool (*custom_stop_condition)(struct snd_soc_dapm_widget *, - enum snd_soc_dapm_direction)); + bool (*custom_stop_condition)(struct snd_soc_dapm_widget *, enum snd_soc_dapm_direction)); void snd_soc_dapm_dai_free_widgets(struct snd_soc_dapm_widget_list **list);
-struct snd_soc_dapm_context *snd_soc_dapm_kcontrol_dapm( - struct snd_kcontrol *kcontrol); +struct snd_soc_dapm_context *snd_soc_dapm_kcontrol_dapm(struct snd_kcontrol *kcontrol); +struct snd_soc_dapm_widget *snd_soc_dapm_kcontrol_widget(struct snd_kcontrol *kcontrol);
-struct snd_soc_dapm_widget *snd_soc_dapm_kcontrol_widget( - struct snd_kcontrol *kcontrol); - -int snd_soc_dapm_force_bias_level(struct snd_soc_dapm_context *dapm, - enum snd_soc_bias_level level); +int snd_soc_dapm_force_bias_level(struct snd_soc_dapm_context *dapm, enum snd_soc_bias_level level);
/* dapm widget types */ enum snd_soc_dapm_type { snd_soc_dapm_input = 0, /* input pin */ snd_soc_dapm_output, /* output pin */ - snd_soc_dapm_mux, /* selects 1 analog signal from many inputs */ - snd_soc_dapm_demux, /* connects the input to one of multiple outputs */ - snd_soc_dapm_mixer, /* mixes several analog signals together */ - snd_soc_dapm_mixer_named_ctl, /* mixer with named controls */ - snd_soc_dapm_pga, /* programmable gain/attenuation (volume) */ - snd_soc_dapm_out_drv, /* output driver */ - snd_soc_dapm_adc, /* analog to digital converter */ - snd_soc_dapm_dac, /* digital to analog converter */ + snd_soc_dapm_mux, /* selects 1 analog signal from many inputs */ + snd_soc_dapm_demux, /* connects the input to one of multiple outputs */ + snd_soc_dapm_mixer, /* mixes several analog signals together */ + snd_soc_dapm_mixer_named_ctl, /* mixer with named controls */ + snd_soc_dapm_pga, /* programmable gain/attenuation (volume) */ + snd_soc_dapm_out_drv, /* output driver */ + snd_soc_dapm_adc, /* analog to digital converter */ + snd_soc_dapm_dac, /* digital to analog converter */ snd_soc_dapm_micbias, /* microphone bias (power) - DEPRECATED: use snd_soc_dapm_supply */ - snd_soc_dapm_mic, /* microphone */ - snd_soc_dapm_hp, /* headphones */ - snd_soc_dapm_spk, /* speaker */ - snd_soc_dapm_line, /* line input/output */ + snd_soc_dapm_mic, /* microphone */ + snd_soc_dapm_hp, /* headphones */ + snd_soc_dapm_spk, /* speaker */ + snd_soc_dapm_line, /* line input/output */ snd_soc_dapm_switch, /* analog switch */ - snd_soc_dapm_vmid, /* codec bias/vmid - to minimise pops */ - snd_soc_dapm_pre, /* machine specific pre widget - exec first */ - snd_soc_dapm_post, /* machine specific post widget - exec last */ + snd_soc_dapm_vmid, /* codec bias/vmid - to minimise pops */ + snd_soc_dapm_pre, /* machine specific pre widget - exec first */ + snd_soc_dapm_post, /* machine specific post widget - exec last */ snd_soc_dapm_supply, /* power/clock supply */ snd_soc_dapm_pinctrl, /* pinctrl */ snd_soc_dapm_regulator_supply, /* external regulator */ @@ -599,9 +567,9 @@ struct snd_soc_dapm_path { };
/* status */ - u32 connect:1; /* source and sink widgets are connected */ - u32 walking:1; /* path is in the process of being walked */ - u32 weak:1; /* path ignored for power management */ + u32 connect:1; /* source and sink widgets are connected */ + u32 walking:1; /* path is in the process of being walked */ + u32 weak:1; /* path ignored for power management */ u32 is_supply:1; /* At least one of the connected widgets is a supply */
int (*connected)(struct snd_soc_dapm_widget *source, @@ -615,8 +583,8 @@ struct snd_soc_dapm_path { /* dapm widget */ struct snd_soc_dapm_widget { enum snd_soc_dapm_type id; - const char *name; /* widget name */ - const char *sname; /* stream name */ + const char *name; /* widget name */ + const char *sname; /* stream name */ struct list_head list; struct snd_soc_dapm_context *dapm;
@@ -635,7 +603,7 @@ struct snd_soc_dapm_widget { unsigned char connected:1; /* connected codec pin */ unsigned char new:1; /* cnew complete */ unsigned char force:1; /* force state */ - unsigned char ignore_suspend:1; /* kept enabled over suspend */ + unsigned char ignore_suspend:1; /* kept enabled over suspend */ unsigned char new_power:1; /* power from this run */ unsigned char power_checked:1; /* power checked this run */ unsigned char is_supply:1; /* Widget is a supply type widget */ @@ -682,13 +650,14 @@ struct snd_soc_dapm_update { /* DAPM context */ struct snd_soc_dapm_context { enum snd_soc_bias_level bias_level; - unsigned int idle_bias_off:1; /* Use BIAS_OFF instead of STANDBY */ - /* Go to BIAS_OFF in suspend if the DAPM context is idle */ - unsigned int suspend_bias_off:1;
- struct device *dev; /* from parent - for debug */ - struct snd_soc_component *component; /* parent component */ - struct snd_soc_card *card; /* parent card */ + /* bit field */ + unsigned int idle_bias_off:1; /* Use BIAS_OFF instead of STANDBY */ + unsigned int suspend_bias_off:1; /* Use BIAS_OFF in suspend if the DAPM is idle */ + + struct device *dev; /* from parent - for debug */ + struct snd_soc_component *component; /* parent component */ + struct snd_soc_card *card; /* parent card */
/* used during DAPM updates */ enum snd_soc_bias_level target_bias_level; @@ -762,8 +731,8 @@ enum snd_soc_dapm_direction {
#define SND_SOC_DAPM_DIR_TO_EP(x) BIT(x)
-#define SND_SOC_DAPM_EP_SOURCE SND_SOC_DAPM_DIR_TO_EP(SND_SOC_DAPM_DIR_IN) -#define SND_SOC_DAPM_EP_SINK SND_SOC_DAPM_DIR_TO_EP(SND_SOC_DAPM_DIR_OUT) +#define SND_SOC_DAPM_EP_SOURCE SND_SOC_DAPM_DIR_TO_EP(SND_SOC_DAPM_DIR_IN) +#define SND_SOC_DAPM_EP_SINK SND_SOC_DAPM_DIR_TO_EP(SND_SOC_DAPM_DIR_OUT)
/** * snd_soc_dapm_widget_for_each_sink_path - Iterates over all paths in the
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
The comment of snd_soc_dapm_widget_for_each_path() (= X) has "_sink_" (= s), but this is typo. With "_sink_" is already exist at (A). This patch fixup it.
/** (s) * snd_soc_dapm_widget_for_each_sink_path - ... * **** */ (X) #define snd_soc_dapm_widget_for_each_path(w, dir, p)
/** (s) * snd_soc_dapm_widget_for_each_sink_path_safe - ... * **** */ (X) #define snd_soc_dapm_widget_for_each_path_safe(w, dir, p, next_p)
(A) #define snd_soc_dapm_widget_for_each_sink_path(w, p) ****
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc-dapm.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 44597e63344d..77495e5988c1 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -735,7 +735,7 @@ enum snd_soc_dapm_direction { #define SND_SOC_DAPM_EP_SINK SND_SOC_DAPM_DIR_TO_EP(SND_SOC_DAPM_DIR_OUT)
/** - * snd_soc_dapm_widget_for_each_sink_path - Iterates over all paths in the + * snd_soc_dapm_widget_for_each_path - Iterates over all paths in the * specified direction of a widget * @w: The widget * @dir: Whether to iterate over the paths where the specified widget is the @@ -746,7 +746,7 @@ enum snd_soc_dapm_direction { list_for_each_entry(p, &w->edges[dir], list_node[dir])
/** - * snd_soc_dapm_widget_for_each_sink_path_safe - Iterates over all paths in the + * snd_soc_dapm_widget_for_each_path_safe - Iterates over all paths in the * specified direction of a widget * @w: The widget * @dir: Whether to iterate over the paths where the specified widget is the @@ -754,7 +754,7 @@ enum snd_soc_dapm_direction { * @p: The path iterator variable * @next_p: Temporary storage for the next path * - * This function works like snd_soc_dapm_widget_for_each_sink_path, expect that + * This function works like snd_soc_dapm_widget_for_each_path, expect that * it is safe to remove the current path from the list while iterating */ #define snd_soc_dapm_widget_for_each_path_safe(w, dir, p, next_p) \
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Current soc-pcm.c is coping fe hw_param to dpcm->hw_param (A), fixup it (B), and copy it to be (C).
int dpcm_be_dai_hw_params(...) { ... for_each_dpcm_be(fe, stream, dpcm) { ... /* copy params for each dpcm */ (A) memcpy(&dpcm->hw_params, &fe->dpcm[stream].hw_params, ...) ;
/* perform any hw_params fixups */ (B) ret = snd_soc_link_be_hw_params_fixup(be, &dpcm->hw_params); ...
/* copy the fixed-up hw params for BE dai */ (C) memcpy(&be->dpcm[stream].hw_params, &dpcm->hw_params, ...); ... } ... }
But here, (1) it is coping hw_params without caring stream (Playback/Capture), (2) we can get same value from be. We don't need to have dpcm->hw_params. This patch removes it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- include/sound/soc-dpcm.h | 2 -- sound/soc/sh/rcar/core.c | 3 ++- sound/soc/soc-pcm.c | 12 +++++++----- 3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/include/sound/soc-dpcm.h b/include/sound/soc-dpcm.h index 5b689c663290..2864aed72998 100644 --- a/include/sound/soc-dpcm.h +++ b/include/sound/soc-dpcm.h @@ -78,8 +78,6 @@ struct snd_soc_dpcm { struct list_head list_be; struct list_head list_fe;
- /* hw params for this link - may be different for each link */ - struct snd_pcm_hw_params hw_params; #ifdef CONFIG_DEBUG_FS struct dentry *debugfs_state; #endif diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 7e380d71b0f8..6cebaef77f84 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1518,7 +1518,8 @@ static int rsnd_hw_params(struct snd_soc_component *component, int stream = substream->stream;
for_each_dpcm_be(fe, stream, dpcm) { - struct snd_pcm_hw_params *be_params = &dpcm->hw_params; + struct snd_soc_pcm_runtime *be = dpcm->be; + struct snd_pcm_hw_params *be_params = &be->dpcm[stream].hw_params;
if (params_channels(hw_params) != params_channels(be_params)) io->converted_chan = params_channels(be_params); diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 2ce9a8188378..57d748ee291e 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -155,7 +155,7 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe,
for_each_dpcm_be(fe, stream, dpcm) { struct snd_soc_pcm_runtime *be = dpcm->be; - params = &dpcm->hw_params; + params = &be->dpcm[stream].hw_params;
offset += scnprintf(buf + offset, size - offset, "- %s\n", be->dai_link->name); @@ -1980,6 +1980,8 @@ int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream) int ret;
for_each_dpcm_be(fe, stream, dpcm) { + struct snd_pcm_hw_params hw_params; + be = dpcm->be; be_substream = snd_soc_dpcm_get_substream(be, stream);
@@ -1988,16 +1990,16 @@ int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream) continue;
/* copy params for each dpcm */ - memcpy(&dpcm->hw_params, &fe->dpcm[stream].hw_params, + memcpy(&hw_params, &fe->dpcm[stream].hw_params, sizeof(struct snd_pcm_hw_params));
/* perform any hw_params fixups */ - ret = snd_soc_link_be_hw_params_fixup(be, &dpcm->hw_params); + ret = snd_soc_link_be_hw_params_fixup(be, &hw_params); if (ret < 0) goto unwind;
/* copy the fixed-up hw params for BE dai */ - memcpy(&be->dpcm[stream].hw_params, &dpcm->hw_params, + memcpy(&be->dpcm[stream].hw_params, &hw_params, sizeof(struct snd_pcm_hw_params));
/* only allow hw_params() if no connected FEs are running */ @@ -2012,7 +2014,7 @@ int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream) dev_dbg(be->dev, "ASoC: hw_params BE %s\n", be->dai_link->name);
- ret = __soc_pcm_hw_params(be, be_substream, &dpcm->hw_params); + ret = __soc_pcm_hw_params(be, be_substream, &hw_params); if (ret < 0) goto unwind;
On Mon, 17 Oct 2022 23:36:04 +0000, Kuninori Morimoto wrote:
These are random cleanup for soc-dpam.c/h. Basically, these are just cleanup, nothing changed.
Kuninori Morimoto (11): ASoC: soc-dapm.c: replace snd_soc_dapm_wcache to snd_soc_dapm_widget ASoC: soc-dapm.c: tidyup error handling on snd_soc_dapm_add_route() ASoC: soc-dapm.c: remove no meaning variable from snd_soc_dapm_add_path() ASoC: soc-dapm.c: ignore parameter NULL at snd_soc_dapm_free_widget() ASoC: soc-dapm.c: cleanup dapm_widget_set_power() ASoC: soc-dapm.c: merge dapm_power_one_widget() and dapm_widget_set_power() ASoC: soc-dapm.c: cleanup snd_soc_dapm_new_dai() ASoC: soc-dapm.c: numerical order for dapm_up_seq ASoC: soc-dapm.h: cleanup white space ASoC: soc-dapm.h: fixup comment for snd_soc_dapm_widget_for_each_path() ASoC: soc-dpcm.h: remove snd_soc_dpcm::hw_param
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/11] ASoC: soc-dapm.c: replace snd_soc_dapm_wcache to snd_soc_dapm_widget commit: 03e13efbb2113412ae7879258a82bdae86fc72e2 [02/11] ASoC: soc-dapm.c: tidyup error handling on snd_soc_dapm_add_route() commit: b913e9f4b313469dac7ae3083356baee3db4454f [03/11] ASoC: soc-dapm.c: remove no meaning variable from snd_soc_dapm_add_path() commit: c1329a0f3bde6a655b9e6ce54b1ce47f46fa49f2 [04/11] ASoC: soc-dapm.c: ignore parameter NULL at snd_soc_dapm_free_widget() commit: 1c9096f32ad23f5867e752f238fd25e4fec55ecd [05/11] ASoC: soc-dapm.c: cleanup dapm_widget_set_power() commit: 0135ae74b4f16fd08c9bad3b965234961d377fa7
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
participants (3)
-
Amadeusz Sławiński
-
Kuninori Morimoto
-
Mark Brown