From: Thierry Reding <[email protected]> Move the clocksource lookup code into a separate function. This will allow subsequent patches to reuse this code.
Signed-off-by: Thierry Reding <[email protected]> --- kernel/time/clocksource.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index 3bcc19ceb073..467b36d2f9f8 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c @@ -453,6 +453,18 @@ static inline void clocksource_watchdog_unlock(unsigned long *flags) { } #endif /* CONFIG_CLOCKSOURCE_WATCHDOG */ +static struct clocksource *clocksource_lookup(const char *name) +{ + struct clocksource *cs; + + list_for_each_entry(cs, &clocksource_list, list) { + if (strcmp(cs->name, name) == 0) + return cs; + } + + return NULL; +} + static bool clocksource_is_suspend(struct clocksource *cs) { return cs == suspend_clocksource; @@ -1110,14 +1122,14 @@ static ssize_t unbind_clocksource_store(struct device *dev, if (ret < 0) return ret; - ret = -ENODEV; mutex_lock(&clocksource_mutex); - list_for_each_entry(cs, &clocksource_list, list) { - if (strcmp(cs->name, name)) - continue; + + cs = clocksource_lookup(name); + if (cs) ret = clocksource_unbind(cs); - break; - } + else + ret = -ENODEV; + mutex_unlock(&clocksource_mutex); return ret ? ret : count; -- 2.21.0

