Skip to content

Commit b833b41

Browse files
morimotobroonie
authored andcommitted
ASoC: soc-core: tidyup snd_soc_lookup_component_nolocked()
snd_soc_lookup_component_nolocked() is very complex today. Let's tidyup the code. Signed-off-by: Kuninori Morimoto <[email protected]> Message-ID: <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 168873c commit b833b41

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

sound/soc/soc-core.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -369,21 +369,25 @@ struct snd_soc_component
369369
*snd_soc_lookup_component_nolocked(struct device *dev, const char *driver_name)
370370
{
371371
struct snd_soc_component *component;
372-
struct snd_soc_component *found_component;
373372

374-
found_component = NULL;
375373
for_each_component(component) {
376-
if ((dev == component->dev) &&
377-
(!driver_name ||
378-
(component->driver->name &&
379-
((component->driver->name == driver_name) ||
380-
(strcmp(component->driver->name, driver_name) == 0))))) {
381-
found_component = component;
382-
break;
383-
}
374+
if (dev != component->dev)
375+
continue;
376+
377+
if (!driver_name)
378+
return component;
379+
380+
if (!component->driver->name)
381+
continue;
382+
383+
if (component->driver->name == driver_name)
384+
return component;
385+
386+
if (strcmp(component->driver->name, driver_name) == 0)
387+
return component;
384388
}
385389

386-
return found_component;
390+
return NULL;
387391
}
388392
EXPORT_SYMBOL_GPL(snd_soc_lookup_component_nolocked);
389393

0 commit comments

Comments
 (0)