From patchwork Tue Jan 27 08:36:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 43818 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3E2A42409D for ; Tue, 27 Jan 2015 08:37:01 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id l4sf6829693lbv.1 for ; Tue, 27 Jan 2015 00:37:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=e6ZmkcfY4ZVYUdUD0bof0+uGknTHk6PXLwEFssH0oyU=; b=hHp40/HUh+TiGPzwJQYD5jPZu3YbWRZBAUOq6APVnX15anbxQk9xdZq+qw74yN/FGf XQh62Ppwa0jV/x5roVGWNNUiYT/08ejQTPrXdawqCxsC0wRM0+h8Q7cS+1Wo1n0bAqTx ibcJtDDdSJZ2mrfG7nPTvKMaTWUXpuRMT58KDV8w+GZYatrpJouGZWNSM2SE3OlUZl8y cjela0Vtqoq5Dv9MIzUtxkobPh9kPqnUemuro8G9p0SejBipybHe1kE5vJlzW4OZOrOt 6L/WGZdiSx4AlHCRW1hSoQ8QAL0DijEWxSt086XU8RCEKv7h3AVkbIPN6IaKGZfBJkb5 XzPQ== X-Gm-Message-State: ALoCoQmpPB2Lezqyju57KAeDfErKQE/tdxtdragqO3bBe+MEhOkGN7wCksQ2Q3qFgtcZ3d/dic9Y X-Received: by 10.180.84.7 with SMTP id u7mr224703wiy.0.1422347820039; Tue, 27 Jan 2015 00:37:00 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.206.11 with SMTP id lk11ls5216lac.8.gmail; Tue, 27 Jan 2015 00:36:59 -0800 (PST) X-Received: by 10.112.126.98 with SMTP id mx2mr140504lbb.84.1422347819805; Tue, 27 Jan 2015 00:36:59 -0800 (PST) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id a4si538023lbb.73.2015.01.27.00.36.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 27 Jan 2015 00:36:59 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by mail-la0-f54.google.com with SMTP id hv19so11916503lab.13 for ; Tue, 27 Jan 2015 00:36:59 -0800 (PST) X-Received: by 10.112.44.230 with SMTP id h6mr123047lbm.98.1422347819675; Tue, 27 Jan 2015 00:36:59 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp1025422lbj; Tue, 27 Jan 2015 00:36:58 -0800 (PST) X-Received: by 10.68.232.104 with SMTP id tn8mr27472pbc.31.1422347817112; Tue, 27 Jan 2015 00:36:57 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id vr2si685254pbc.134.2015.01.27.00.36.55; Tue, 27 Jan 2015 00:36:57 -0800 (PST) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757832AbbA0Igx (ORCPT + 11 others); Tue, 27 Jan 2015 03:36:53 -0500 Received: from mail-pa0-f42.google.com ([209.85.220.42]:36817 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757810AbbA0Igt (ORCPT ); Tue, 27 Jan 2015 03:36:49 -0500 Received: by mail-pa0-f42.google.com with SMTP id bj1so17200061pad.1 for ; Tue, 27 Jan 2015 00:36:48 -0800 (PST) X-Received: by 10.66.162.41 with SMTP id xx9mr235362pab.68.1422347808874; Tue, 27 Jan 2015 00:36:48 -0800 (PST) Received: from localhost ([122.178.198.250]) by mx.google.com with ESMTPSA id r14sm118981pdi.67.2015.01.27.00.36.47 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 27 Jan 2015 00:36:48 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, sboyd@codeaurora.org, prarit@redhat.com, skannan@codeaurora.org, Viresh Kumar Subject: [PATCH 02/18] cpufreq: Create for_each_policy() Date: Tue, 27 Jan 2015 14:06:08 +0530 Message-Id: X-Mailer: git-send-email 2.3.0.rc0.44.ga94655d In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , To make code more readable and less error prone, lets create a helper macro for iterating over all active policies. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 72990ba59fad..9dfefb8ece6d 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -31,6 +31,12 @@ #include #include +/* Macros to iterate over lists */ +/* Iterate over online CPUs policies */ +static LIST_HEAD(cpufreq_policy_list); +#define for_each_policy(__policy) \ + list_for_each_entry(__policy, &cpufreq_policy_list, policy_list) + /** * The "cpufreq driver" - the arch- or hardware-dependent low * level driver of CPUFreq support, and its spinlock. This lock @@ -41,7 +47,6 @@ static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data); static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data_fallback); static DEFINE_RWLOCK(cpufreq_driver_lock); DEFINE_MUTEX(cpufreq_governor_lock); -static LIST_HEAD(cpufreq_policy_list); /* This one keeps track of the previously set governor of a removed CPU */ static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor); @@ -1113,7 +1118,7 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) /* Check if this cpu was hot-unplugged earlier and has siblings */ read_lock_irqsave(&cpufreq_driver_lock, flags); - list_for_each_entry(policy, &cpufreq_policy_list, policy_list) { + for_each_policy(policy) { if (cpumask_test_cpu(cpu, policy->related_cpus)) { read_unlock_irqrestore(&cpufreq_driver_lock, flags); ret = cpufreq_add_policy_cpu(policy, cpu, dev); @@ -1647,7 +1652,7 @@ void cpufreq_suspend(void) pr_debug("%s: Suspending Governors\n", __func__); - list_for_each_entry(policy, &cpufreq_policy_list, policy_list) { + for_each_policy(policy) { if (__cpufreq_governor(policy, CPUFREQ_GOV_STOP)) pr_err("%s: Failed to stop governor for policy: %p\n", __func__, policy); @@ -1681,7 +1686,7 @@ void cpufreq_resume(void) pr_debug("%s: Resuming Governors\n", __func__); - list_for_each_entry(policy, &cpufreq_policy_list, policy_list) { + for_each_policy(policy) { if (cpufreq_driver->resume && cpufreq_driver->resume(policy)) pr_err("%s: Failed to resume driver: %p\n", __func__, policy); @@ -2324,7 +2329,7 @@ static int cpufreq_boost_set_sw(int state) struct cpufreq_policy *policy; int ret = -EINVAL; - list_for_each_entry(policy, &cpufreq_policy_list, policy_list) { + for_each_policy(policy) { freq_table = cpufreq_frequency_get_table(policy->cpu); if (freq_table) { ret = cpufreq_frequency_table_cpuinfo(policy,