mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: John Stultz <john.stultz@linaro.org>,
	Thomas Gleixner <tglx@linutronix.de>
Cc: Stephen Boyd <sboyd@kernel.org>, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] clocksource: Extract clocksource lookup code
Date: Fri, 14 Jun 2019 12:45:09 +0200	[thread overview]
Message-ID: <20190614104510.19360-1-thierry.reding@gmail.com> (raw)

From: Thierry Reding <treding@nvidia.com>

Move the clocksource lookup code into a separate function. This will
allow subsequent patches to reuse this code.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 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


             reply	other threads:[~2019-06-14 10:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-14 10:45 Thierry Reding [this message]
2019-06-14 10:45 ` [PATCH 2/2] clocksource: Add suspend clocksource sysfs attribute Thierry Reding

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190614104510.19360-1-thierry.reding@gmail.com \
    --to=thierry.reding@gmail.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sboyd@kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome