Commit af7b5657 authored by Mark Brown's avatar Mark Brown

ASoC: soc-dapm.c random cleanups

Merge series from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

These are random cleanup for soc-dpam.c/h.
Basically, these are just cleanup, nothing changed.
parents fd65e099 0135ae74
...@@ -450,7 +450,6 @@ int snd_soc_dapm_del_routes(struct snd_soc_dapm_context *dapm, ...@@ -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, int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context *dapm,
const struct snd_soc_dapm_route *route, int num); 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_free_widget(struct snd_soc_dapm_widget *w);
void snd_soc_dapm_reset_cache(struct snd_soc_dapm_context *dapm);
/* dapm events */ /* dapm events */
void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream,
...@@ -680,10 +679,6 @@ struct snd_soc_dapm_update { ...@@ -680,10 +679,6 @@ struct snd_soc_dapm_update {
bool has_second_set; bool has_second_set;
}; };
struct snd_soc_dapm_wcache {
struct snd_soc_dapm_widget *widget;
};
/* DAPM context */ /* DAPM context */
struct snd_soc_dapm_context { struct snd_soc_dapm_context {
enum snd_soc_bias_level bias_level; enum snd_soc_bias_level bias_level;
...@@ -699,8 +694,8 @@ struct snd_soc_dapm_context { ...@@ -699,8 +694,8 @@ struct snd_soc_dapm_context {
enum snd_soc_bias_level target_bias_level; enum snd_soc_bias_level target_bias_level;
struct list_head list; struct list_head list;
struct snd_soc_dapm_wcache path_sink_cache; struct snd_soc_dapm_widget *wcache_sink;
struct snd_soc_dapm_wcache path_source_cache; struct snd_soc_dapm_widget *wcache_source;
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
struct dentry *debugfs_dapm; struct dentry *debugfs_dapm;
......
...@@ -130,10 +130,8 @@ static void hda_codec_unregister_dais(struct hda_codec *codec, ...@@ -130,10 +130,8 @@ static void hda_codec_unregister_dais(struct hda_codec *codec,
if (strcmp(dai->driver->name, pcm->name)) if (strcmp(dai->driver->name, pcm->name))
continue; continue;
if (dai->playback_widget) snd_soc_dapm_free_widget(dai->playback_widget);
snd_soc_dapm_free_widget(dai->playback_widget); snd_soc_dapm_free_widget(dai->capture_widget);
if (dai->capture_widget)
snd_soc_dapm_free_widget(dai->capture_widget);
snd_soc_unregister_dai(dai); snd_soc_unregister_dai(dai);
break; break;
} }
......
...@@ -1016,10 +1016,8 @@ static void avs_component_hda_unregister_dais(struct snd_soc_component *componen ...@@ -1016,10 +1016,8 @@ static void avs_component_hda_unregister_dais(struct snd_soc_component *componen
if (!strstr(dai->driver->name, name)) if (!strstr(dai->driver->name, name))
continue; continue;
if (dai->playback_widget) snd_soc_dapm_free_widget(dai->playback_widget);
snd_soc_dapm_free_widget(dai->playback_widget); snd_soc_dapm_free_widget(dai->capture_widget);
if (dai->capture_widget)
snd_soc_dapm_free_widget(dai->capture_widget);
snd_soc_unregister_dai(dai); snd_soc_unregister_dai(dai);
} }
} }
......
...@@ -652,10 +652,8 @@ static void soc_dapm_async_complete(struct snd_soc_dapm_context *dapm) ...@@ -652,10 +652,8 @@ static void soc_dapm_async_complete(struct snd_soc_dapm_context *dapm)
} }
static struct snd_soc_dapm_widget * 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) { if (w) {
struct list_head *wlist = &w->dapm->card->widgets; struct list_head *wlist = &w->dapm->card->widgets;
const int depth = 2; const int depth = 2;
...@@ -673,12 +671,6 @@ dapm_wcache_lookup(struct snd_soc_dapm_wcache *wcache, const char *name) ...@@ -673,12 +671,6 @@ dapm_wcache_lookup(struct snd_soc_dapm_wcache *wcache, const char *name)
return NULL; 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 * snd_soc_dapm_force_bias_level() - Sets the DAPM bias level
* @dapm: The DAPM context for which to set the level * @dapm: The DAPM context for which to set the level
...@@ -1892,18 +1884,19 @@ static void dapm_widget_set_power(struct snd_soc_dapm_widget *w, bool power, ...@@ -1892,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); 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) snd_soc_dapm_widget_for_each_source_path(w, path)
dapm_widget_set_peer_power(path->source, power, path->connect); 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) snd_soc_dapm_widget_for_each_sink_path(w, path)
dapm_widget_set_peer_power(path->sink, power, dapm_widget_set_peer_power(path->sink, power, path->connect);
path->connect);
}
if (power) if (power)
dapm_seq_insert(w, up_list, true); dapm_seq_insert(w, up_list, true);
...@@ -2497,6 +2490,9 @@ void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w) ...@@ -2497,6 +2490,9 @@ void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w)
struct snd_soc_dapm_path *p, *next_p; struct snd_soc_dapm_path *p, *next_p;
enum snd_soc_dapm_direction dir; enum snd_soc_dapm_direction dir;
if (!w)
return;
list_del(&w->list); list_del(&w->list);
list_del(&w->dirty); list_del(&w->dirty);
/* /*
...@@ -2516,12 +2512,6 @@ void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w) ...@@ -2516,12 +2512,6 @@ void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w)
} }
EXPORT_SYMBOL_GPL(snd_soc_dapm_free_widget); 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 */ /* free all dapm widgets and resources */
static void dapm_free_widgets(struct snd_soc_dapm_context *dapm) static void dapm_free_widgets(struct snd_soc_dapm_context *dapm)
{ {
...@@ -2532,7 +2522,9 @@ static void dapm_free_widgets(struct snd_soc_dapm_context *dapm) ...@@ -2532,7 +2522,9 @@ static void dapm_free_widgets(struct snd_soc_dapm_context *dapm)
continue; continue;
snd_soc_dapm_free_widget(w); 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( static struct snd_soc_dapm_widget *dapm_find_widget(
...@@ -2838,7 +2830,6 @@ static int snd_soc_dapm_add_path(struct snd_soc_dapm_context *dapm, ...@@ -2838,7 +2830,6 @@ static int snd_soc_dapm_add_path(struct snd_soc_dapm_context *dapm,
int (*connected)(struct snd_soc_dapm_widget *source, int (*connected)(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink)) struct snd_soc_dapm_widget *sink))
{ {
struct snd_soc_dapm_widget *widgets[2];
enum snd_soc_dapm_direction dir; enum snd_soc_dapm_direction dir;
struct snd_soc_dapm_path *path; struct snd_soc_dapm_path *path;
int ret; int ret;
...@@ -2874,8 +2865,6 @@ static int snd_soc_dapm_add_path(struct snd_soc_dapm_context *dapm, ...@@ -2874,8 +2865,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_IN] = wsource;
path->node[SND_SOC_DAPM_DIR_OUT] = wsink; 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; path->connected = connected;
INIT_LIST_HEAD(&path->list); INIT_LIST_HEAD(&path->list);
...@@ -2917,12 +2906,13 @@ static int snd_soc_dapm_add_path(struct snd_soc_dapm_context *dapm, ...@@ -2917,12 +2906,13 @@ static int snd_soc_dapm_add_path(struct snd_soc_dapm_context *dapm,
} }
list_add(&path->list, &dapm->card->paths); list_add(&path->list, &dapm->card->paths);
snd_soc_dapm_for_each_direction(dir) 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) { snd_soc_dapm_for_each_direction(dir) {
dapm_update_widget_flags(widgets[dir]); dapm_update_widget_flags(path->node[dir]);
dapm_mark_dirty(widgets[dir], "Route added"); dapm_mark_dirty(path->node[dir], "Route added");
} }
if (dapm->card->instantiated && path->connect) if (dapm->card->instantiated && path->connect)
...@@ -2961,8 +2951,8 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm, ...@@ -2961,8 +2951,8 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
source = route->source; source = route->source;
} }
wsource = dapm_wcache_lookup(&dapm->path_source_cache, source); wsource = dapm_wcache_lookup(dapm->wcache_source, source);
wsink = dapm_wcache_lookup(&dapm->path_sink_cache, sink); wsink = dapm_wcache_lookup(dapm->wcache_sink, sink);
if (wsink && wsource) if (wsink && wsource)
goto skip_search; goto skip_search;
...@@ -3006,30 +2996,27 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm, ...@@ -3006,30 +2996,27 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
if (!wsource) if (!wsource)
wsource = wtsource; wsource = wtsource;
if (wsource == NULL) { ret = -ENODEV;
dev_err(dapm->dev, "ASoC: no source widget found for %s\n", if (!wsource)
route->source); goto err;
return -ENODEV; if (!wsink)
} goto err;
if (wsink == NULL) {
dev_err(dapm->dev, "ASoC: no sink widget found for %s\n",
route->sink);
return -ENODEV;
}
skip_search: skip_search:
dapm_wcache_update(&dapm->path_sink_cache, wsink); /* update cache */
dapm_wcache_update(&dapm->path_source_cache, wsource); dapm->wcache_sink = wsink;
dapm->wcache_source = wsource;
ret = snd_soc_dapm_add_path(dapm, wsource, wsink, route->control, ret = snd_soc_dapm_add_path(dapm, wsource, wsink, route->control,
route->connected); route->connected);
if (ret)
goto err;
return 0;
err: err:
dev_warn(dapm->dev, "ASoC: no dapm match for %s --> %s --> %s\n", if (ret)
source, route->control, sink); 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; return ret;
} }
...@@ -3115,13 +3102,8 @@ int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm, ...@@ -3115,13 +3102,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); mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
int r = snd_soc_dapm_add_route(dapm, route); int r = snd_soc_dapm_add_route(dapm, route);
if (r < 0) { 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);
ret = r; ret = r;
}
route++; route++;
} }
mutex_unlock(&dapm->card->dapm_mutex); mutex_unlock(&dapm->card->dapm_mutex);
......
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