Commit 0ae9e4f2 authored by Christian Gromm's avatar Christian Gromm Committed by Greg Kroah-Hartman

staging: most: cdev: simplify list iteration

This patch uses a less confusing list traversing structure to
either return an item of the list that meets the prerequisites
or NULL otherwise.
Signed-off-by: default avatarChristian Gromm <christian.gromm@microchip.com>
Link: https://lore.kernel.org/r/1592815695-19305-7-git-send-email-christian.gromm@microchip.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 78aee651
......@@ -66,19 +66,16 @@ static struct comp_channel *get_channel(struct most_interface *iface, int id)
{
struct comp_channel *c, *tmp;
unsigned long flags;
int found_channel = 0;
spin_lock_irqsave(&ch_list_lock, flags);
list_for_each_entry_safe(c, tmp, &channel_list, list) {
if ((c->iface == iface) && (c->channel_id == id)) {
found_channel = 1;
break;
spin_unlock_irqrestore(&ch_list_lock, flags);
return c;
}
}
spin_unlock_irqrestore(&ch_list_lock, flags);
if (!found_channel)
return NULL;
return c;
}
static void stop_channel(struct comp_channel *c)
......
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