Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1338955

[PATCH] cpufreq: simplify for_each_suitable_policy() macro

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Eric Biggers <ebiggers3@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] cpufreq: simplify for_each_suitable_policy() macro
Date Sun, 21 Feb 2016 20:00:01 +0100
Message-ID <r4HoB-1OF-3@gated-at.bofh.it> (permalink)
X-Original-To rjw@rjwysocki.net
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=TeQh0wLuhqzYcJUCSyZydel8GSZzSY4ifcZz6j3PhOg=; b=VwHCnwit6Br1cbfrjMCKKCjb2eyHvFOZw6cvTtJ0mQvtP0x1qfva1XxCYqQsZcs0Z6 zPeyIs+AULAGvyyJSvz0ZRafs61N7AJbZHtLD2MlmhHxFC25piZUR3HRKXD3zVrfswIN g+eAXCgbKzM+ETAVlNZRjXRWBVv7cpzFWyot2Bo15Wm7fgSqlUaqkUCp0/vtDFL2VWVW GIEzfGpyZLF75GmdL4SxIEmA+Wr+2TLSJxpTnkIoiZN5uN6KVp2viWuotfz4raDoqV+a RL/GX725ISW1kAGYJs0WmkfEVpsvpDfIoFAO6TwPWlA4tfdolD/JuN8TdVkeJn/InSy0 EYGg==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TeQh0wLuhqzYcJUCSyZydel8GSZzSY4ifcZz6j3PhOg=; b=IeyW24b1v44oZ7sinZh5kiiIxCPwNTBx3lm4g/dmC42vBAdHfYj0zCdSVA2Mrk+MOg /GK4516hNH39u1xgrPtx2bVB9TG0KKhkL+N1mvoBOCqtIRdZDsQjSZZCoZQbbxpsoFhU SIxTBmRdCcChR+h7kNjU4Ds5g1wrVeQ3emoMK7JCnM0ZHDUlOteRAnG9hXI/SoynifTC u9M0xy7eiHtyWLOJhn11rQewpprjyKX0kLvK0FXsDKq3B3lEGjjsIQv5tWAZ50aIbhTX U1ZtV6PwwPE8mYLjo/44WSXiBjcV7GGriy51h748k7mMnTe45FxovAI0sjOZIF6japte jtFA==
X-Gm-Message-State AG10YOSbGuh23A+jW9I1d07fHoRZ2JhEQbcnZP4/NZUj8tZAw2j9ftu9lqFBHmzk257SgA==
X-Received by 10.51.17.39 with SMTP id gb7mr7606087igd.4.1456080809815; Sun, 21 Feb 2016 10:53:29 -0800 (PST)
X-Mailer git-send-email 2.7.1
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 63
Organization linux.* mail to news gateway
X-Original-Cc viresh.kumar@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Biggers <ebiggers3@gmail.com>
X-Original-Date Sun, 21 Feb 2016 12:53:12 -0600
X-Original-Message-ID <1456080792-22770-1-git-send-email-ebiggers3@gmail.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1338955

Show key headers only | View raw


Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
---
 drivers/cpufreq/cpufreq.c | 44 +++-----------------------------------------
 1 file changed, 3 insertions(+), 41 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index e979ec7..3aa7b2b 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -38,48 +38,10 @@ static inline bool policy_is_inactive(struct cpufreq_policy *policy)
 	return cpumask_empty(policy->cpus);
 }
 
-static bool suitable_policy(struct cpufreq_policy *policy, bool active)
-{
-	return active == !policy_is_inactive(policy);
-}
-
-/* Finds Next Acive/Inactive policy */
-static struct cpufreq_policy *next_policy(struct cpufreq_policy *policy,
-					  bool active)
-{
-	do {
-		/* No more policies in the list */
-		if (list_is_last(&policy->policy_list, &cpufreq_policy_list))
-			return NULL;
-
-		policy = list_next_entry(policy, policy_list);
-	} while (!suitable_policy(policy, active));
-
-	return policy;
-}
-
-static struct cpufreq_policy *first_policy(bool active)
-{
-	struct cpufreq_policy *policy;
-
-	/* No policies in the list */
-	if (list_empty(&cpufreq_policy_list))
-		return NULL;
-
-	policy = list_first_entry(&cpufreq_policy_list, typeof(*policy),
-				  policy_list);
-
-	if (!suitable_policy(policy, active))
-		policy = next_policy(policy, active);
-
-	return policy;
-}
-
 /* Macros to iterate over CPU policies */
-#define for_each_suitable_policy(__policy, __active)	\
-	for (__policy = first_policy(__active);		\
-	     __policy;					\
-	     __policy = next_policy(__policy, __active))
+#define for_each_suitable_policy(__policy, __active)			 \
+	list_for_each_entry(__policy, &cpufreq_policy_list, policy_list) \
+		if ((__active) == !policy_is_inactive(__policy))
 
 #define for_each_active_policy(__policy)		\
 	for_each_suitable_policy(__policy, true)
-- 
2.7.1

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] cpufreq: simplify for_each_suitable_policy() macro Eric Biggers <ebiggers3@gmail.com> - 2016-02-21 20:00 +0100
  Re: [PATCH] cpufreq: simplify for_each_suitable_policy() macro Viresh Kumar <viresh.kumar@linaro.org> - 2016-02-22 06:40 +0100
    Re: [PATCH] cpufreq: simplify for_each_suitable_policy() macro "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2016-02-22 14:20 +0100

csiph-web