On Sun, Aug 02, 2015 at 12:18:26PM +0200, Lars-Peter Clausen wrote:
On 07/29/2015 03:14 PM, Mark Brown wrote:
#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.
It's the unsafe version that's in the header though? I can tell why they're separate, I'd just rather keep them together even so - drivers shouldn't really be iterating over widgets at all.
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.
It does save me wondering if we've missed any other array elements which was my first thought here.