On 07/29/2015 03:14 PM, Mark Brown wrote: [...]
+/**
- snd_soc_dapm_widget_for_each_sink_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
incoming or outgoing widgets
- @p: The path iterator variable
- */
+#define snd_soc_dapm_widget_for_each_path(w, dir, p) \
- list_for_each_entry(p, &w->edges[dir], list_node[dir])
This is a macro not a static inline? The other macros that use this are macros but that's more outdated code than anything I think, might be worth fixing that while we're at it.
Sorry, I don't quite understand what you mean. snd_soc_dapm_widget_for_each_path() is a iterator so it can't be a function.
#define DAPM_UPDATE_STAT(widget, val) widget->dapm->card->dapm_stats.val++;
+#define dapm_widget_for_each_path_safe(w, dir, p, next_p) \
- list_for_each_entry_safe(p, next_p, &w->edges[dir], list_node[dir])
It's a bit odd not to have this in the header next to the unsafe version.
You'd only need the unsafe variant if the paths are modified while being traversed. I'd rather not encourage drivers to do this by hand. So this macro is internal to the DAPM core.
+#define SND_SOC_DAPM_DIR_REVERSE(x) ((x == SND_SOC_DAPM_DIR_IN) ? \
- SND_SOC_DAPM_DIR_OUT : SND_SOC_DAPM_DIR_IN)
+#define dapm_for_each_direction(dir) \
- for ((dir) = SND_SOC_DAPM_DIR_IN; (dir) <= SND_SOC_DAPM_DIR_OUT; \
(dir)++)
Eew.
list_for_each_entry(w, &card->widgets, list) {
w->inputs = -1;
w->outputs = -1;
w->endpoints[SND_SOC_DAPM_DIR_IN] = -1;
w->endpoints[SND_SOC_DAPM_DIR_OUT] = -1;
Loop over the endpoints array in some of the users like this perhaps?
It's not really worth it if you only have a single line inside the loop. Doesn't make the code shorter nor more legible.