From patchwork Wed Sep 14 08:49:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 76150 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp1764294qgf; Wed, 14 Sep 2016 01:50:41 -0700 (PDT) X-Received: by 10.66.81.201 with SMTP id c9mr2526853pay.14.1473843041467; Wed, 14 Sep 2016 01:50:41 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h2si3745016paz.74.2016.09.14.01.50.41; Wed, 14 Sep 2016 01:50:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760712AbcINIuZ (ORCPT + 27 others); Wed, 14 Sep 2016 04:50:25 -0400 Received: from mail-pf0-f176.google.com ([209.85.192.176]:34503 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755898AbcINIuS (ORCPT ); Wed, 14 Sep 2016 04:50:18 -0400 Received: by mail-pf0-f176.google.com with SMTP id p64so3665381pfb.1 for ; Wed, 14 Sep 2016 01:50:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=crd0WVzkKCxJy//Muyq85k28Pkoyteo/VbgLEmYw+IQ=; b=WWiwEsXIslxR+/2imMo6taA3iY/4Lh4c7AmmEh9mnhZUnzm9ISui/gMPWs4P3Re765 +5l52Tfh6L8RTQLfiCXdBjAyU6LaP6GKKdbKQkzov/8OEjqZjuaKztfZO0rAKTPMViZc iacPKwo192aCI01scwDIkG2s6+yl595BhZ9ss= 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:in-reply-to :references:in-reply-to:references; bh=crd0WVzkKCxJy//Muyq85k28Pkoyteo/VbgLEmYw+IQ=; b=O9k51BGWx5rit9AcR5VxGrqvCtycGbLz9TAb2/rPoU8X1CRjVygh+AbBwRIl0HiWos 6bvffZqImNffFX3zSXdl/e8l7ZeNJoKpWQBIEWj4SZyy+pE0a13fcX6oYK1GJq0ASSiN fadX3PQa4tHmqYDEXKBza45NsZ6l0T3OZtFQDynZ5ZOsOUOJR2yTuytpWJIhJruOi2yM F/PJbQlynpXhqptdOCUTGqlW+r2C47Bv6PbQpdPCw5sawTWsdMt7feMmOw+ThmwUHqai 0FRqJa39Lc19Lm0mFijqyx3sBYuUhJtAwAj7J2twlwoCCx0+Z0YJqNatGZV8d9fZ+MZC Zvgg== X-Gm-Message-State: AE9vXwNzY4tYBCcbmVTedyVYcogDRM4uK1TD2szaGGG54zromophkT7dRPaSKglUDPUFdRr2 X-Received: by 10.98.78.138 with SMTP id c132mr2439579pfb.67.1473843017767; Wed, 14 Sep 2016 01:50:17 -0700 (PDT) Received: from localhost ([171.61.121.167]) by smtp.gmail.com with ESMTPSA id ve9sm3729436pac.12.2016.09.14.01.50.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Sep 2016 01:50:17 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar , Ingo Molnar , Peter Zijlstra Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, rostedt@goodmis.org, mike@android.com, toddpoynor@google.com, kandoiruchi@google.com, juri.lelli@arm.com, steve.muckle@linaro.org, vincent.guittot@linaro.org, john.stultz@linaro.org, amit.pundir@linaro.org Subject: [PATCH V2 1/2] cpufreq: Move gov_attr_* macros to cpufreq.h Date: Wed, 14 Sep 2016 14:19:40 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org These macros can be reused by governors which don't use the common governor code present in cpufreq_governor.c and should be moved to the relevant header. Now that they are getting moved to the right header file, reuse them in schedutil governor as well (that required rename of show/store routines). Also create gov_attr_wo() macro for write-only sysfs files, this will be used by Interactive governor in a later patch. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq_governor.h | 8 -------- include/linux/cpufreq.h | 12 ++++++++++++ kernel/sched/cpufreq_schedutil.c | 8 ++++---- 3 files changed, 16 insertions(+), 12 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h index ef1037e9c92b..3196ed9c1c0a 100644 --- a/drivers/cpufreq/cpufreq_governor.h +++ b/drivers/cpufreq/cpufreq_governor.h @@ -70,14 +70,6 @@ static ssize_t show_##file_name \ return sprintf(buf, "%u\n", dbs_data->file_name); \ } -#define gov_attr_ro(_name) \ -static struct governor_attr _name = \ -__ATTR(_name, 0444, show_##_name, NULL) - -#define gov_attr_rw(_name) \ -static struct governor_attr _name = \ -__ATTR(_name, 0644, show_##_name, store_##_name) - /* Common to all CPUs of a policy */ struct policy_dbs_info { struct cpufreq_policy *policy; diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 631ba33bbe9f..b65b1d795007 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -539,6 +539,18 @@ struct gov_attr_set { int usage_count; }; +#define gov_attr_ro(_name) \ +static struct governor_attr _name = \ +__ATTR(_name, 0444, show_##_name, NULL) + +#define gov_attr_wo(_name) \ +static struct governor_attr _name = \ +__ATTR(_name, 0200, NULL, store_##_name) + +#define gov_attr_rw(_name) \ +static struct governor_attr _name = \ +__ATTR(_name, 0644, show_##_name, store_##_name) + /* sysfs ops for cpufreq governors */ extern const struct sysfs_ops governor_sysfs_ops; diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 69e06898997d..c67c751944a9 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -321,15 +321,15 @@ static inline struct sugov_tunables *to_sugov_tunables(struct gov_attr_set *attr return container_of(attr_set, struct sugov_tunables, attr_set); } -static ssize_t rate_limit_us_show(struct gov_attr_set *attr_set, char *buf) +static ssize_t show_rate_limit_us(struct gov_attr_set *attr_set, char *buf) { struct sugov_tunables *tunables = to_sugov_tunables(attr_set); return sprintf(buf, "%u\n", tunables->rate_limit_us); } -static ssize_t rate_limit_us_store(struct gov_attr_set *attr_set, const char *buf, - size_t count) +static ssize_t store_rate_limit_us(struct gov_attr_set *attr_set, + const char *buf, size_t count) { struct sugov_tunables *tunables = to_sugov_tunables(attr_set); struct sugov_policy *sg_policy; @@ -346,7 +346,7 @@ static ssize_t rate_limit_us_store(struct gov_attr_set *attr_set, const char *bu return count; } -static struct governor_attr rate_limit_us = __ATTR_RW(rate_limit_us); +gov_attr_rw(rate_limit_us); static struct attribute *sugov_attributes[] = { &rate_limit_us.attr,