From patchwork Tue Jan 27 08:36:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 43819 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CBD302409D for ; Tue, 27 Jan 2015 08:37:04 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id u10sf6822510lbd.3 for ; Tue, 27 Jan 2015 00:37:03 -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=k2NixjBIA43pv4eJX4m3gUzMWfC1m/Fslw+0IHbRD7o=; b=hDYA5iRjcMhxhI82MzBxA5m9pcaAE47hF6yIrF4injJiLjHs20EYEQXOZluHm09Vvk Gcd+Syf20K891VhIOyZ4ZqwTB13ixOfOo9SJeep3xwMim8ZzPnXppgOOF1ZsxYi4Y3yO CGS4w3/rnHt3FMFF+wEqmPZJr6c/M2f3u2E7rMKIqVTQX3LF8j2iQ+hH4M81dB88TEmN gmpgMLiGq1wE6KFRZus++DgxwUTuU+tjr94chAa+VnmK5Z1PyzUFf8hgOELr8BmmfH95 VAYCkUDbExRQqk7sPuKkhiNI7RtkOqrLcEq/ClY4CZH0VAJUS25GRCphw2wyRZfIV3/k P6ZA== X-Gm-Message-State: ALoCoQnYk7U0Qg0fhY3hzuJzbZAv4J7AH65wpuff+gFlKS76N7tV/O0y/sV7qGzp0Lme9iF8RH0Q X-Received: by 10.112.137.70 with SMTP id qg6mr33183lbb.14.1422347823465; Tue, 27 Jan 2015 00:37:03 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.232 with SMTP id t8ls1395laj.100.gmail; Tue, 27 Jan 2015 00:37:03 -0800 (PST) X-Received: by 10.152.45.4 with SMTP id i4mr149618lam.74.1422347823190; Tue, 27 Jan 2015 00:37:03 -0800 (PST) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id x4si567117lbm.37.2015.01.27.00.37.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 27 Jan 2015 00:37:03 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id s18so12045424lam.5 for ; Tue, 27 Jan 2015 00:37:02 -0800 (PST) X-Received: by 10.152.197.5 with SMTP id iq5mr213602lac.6.1422347822758; Tue, 27 Jan 2015 00:37:02 -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 h5csp1025438lbj; Tue, 27 Jan 2015 00:37:01 -0800 (PST) X-Received: by 10.68.68.145 with SMTP id w17mr214699pbt.82.1422347818313; Tue, 27 Jan 2015 00:36:58 -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.57; Tue, 27 Jan 2015 00:36:58 -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 S1757822AbbA0Igz (ORCPT + 11 others); Tue, 27 Jan 2015 03:36:55 -0500 Received: from mail-pa0-f54.google.com ([209.85.220.54]:37347 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757828AbbA0Igx (ORCPT ); Tue, 27 Jan 2015 03:36:53 -0500 Received: by mail-pa0-f54.google.com with SMTP id eu11so17159751pac.13 for ; Tue, 27 Jan 2015 00:36:52 -0800 (PST) X-Received: by 10.68.232.33 with SMTP id tl1mr41455029pbc.65.1422347812435; Tue, 27 Jan 2015 00:36:52 -0800 (PST) Received: from localhost ([122.178.198.250]) by mx.google.com with ESMTPSA id 9sm824677pdg.38.2015.01.27.00.36.51 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 27 Jan 2015 00:36:51 -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 03/18] cpufreq: Create for_each_governor() Date: Tue, 27 Jan 2015 14:06:09 +0530 Message-Id: <8abc55e0c15c5abed4944018195480374ea96b3c.1422346933.git.viresh.kumar@linaro.org> 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.46 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 available governors. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 9dfefb8ece6d..cf8ce523074f 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -37,6 +37,11 @@ static LIST_HEAD(cpufreq_policy_list); #define for_each_policy(__policy) \ list_for_each_entry(__policy, &cpufreq_policy_list, policy_list) +/* Iterate over governors */ +static LIST_HEAD(cpufreq_governor_list); +#define for_each_governor(__governor) \ + list_for_each_entry(__governor, &cpufreq_governor_list, governor_list) + /** * The "cpufreq driver" - the arch- or hardware-dependent low * level driver of CPUFreq support, and its spinlock. This lock @@ -99,7 +104,6 @@ void disable_cpufreq(void) { off = 1; } -static LIST_HEAD(cpufreq_governor_list); static DEFINE_MUTEX(cpufreq_governor_mutex); bool have_governor_per_policy(void) @@ -434,7 +438,7 @@ static struct cpufreq_governor *find_governor(const char *str_governor) { struct cpufreq_governor *t; - list_for_each_entry(t, &cpufreq_governor_list, governor_list) + for_each_governor(t) if (!strncasecmp(str_governor, t->name, CPUFREQ_NAME_LEN)) return t; @@ -636,7 +640,7 @@ static ssize_t show_scaling_available_governors(struct cpufreq_policy *policy, goto out; } - list_for_each_entry(t, &cpufreq_governor_list, governor_list) { + for_each_governor(t) { if (i >= (ssize_t) ((PAGE_SIZE / sizeof(char)) - (CPUFREQ_NAME_LEN + 2))) goto out;