cpufreq: governor: Create generic macro for common tunables
authorViresh Kumar <viresh.kumar@linaro.org>
Tue, 9 Feb 2016 03:31:31 +0000 (09:01 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 9 Mar 2016 13:40:57 +0000 (14:40 +0100)
Some tunables are present in governor-specific structures, whereas one
(min_sampling_rate) is located directly in struct dbs_data.

There is a special macro for creating its sysfs attribute and the
show/store callbacks, but since more tunables are going to be moved
to struct dbs_data, a new generic macro for such cases will be useful,
so add it and use it for min_sampling_rate.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Juri Lelli <juri.lelli@arm.com>
Tested-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
[ rjw: Subject & changelog ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq_conservative.c
drivers/cpufreq/cpufreq_governor.h
drivers/cpufreq/cpufreq_ondemand.c

index 1a899bb7d1a4de828dcd7cd59a4077a750a019ab..a69eb7eae7ecb9dac61cdc5b67f7b9f164e17c9b 100644 (file)
@@ -245,7 +245,7 @@ show_store_one(cs, up_threshold);
 show_store_one(cs, down_threshold);
 show_store_one(cs, ignore_nice_load);
 show_store_one(cs, freq_step);
-declare_show_sampling_rate_min(cs);
+show_one_common(cs, min_sampling_rate);
 
 gov_sys_pol_attr_rw(sampling_rate);
 gov_sys_pol_attr_rw(sampling_down_factor);
@@ -253,10 +253,10 @@ gov_sys_pol_attr_rw(up_threshold);
 gov_sys_pol_attr_rw(down_threshold);
 gov_sys_pol_attr_rw(ignore_nice_load);
 gov_sys_pol_attr_rw(freq_step);
-gov_sys_pol_attr_ro(sampling_rate_min);
+gov_sys_pol_attr_ro(min_sampling_rate);
 
 static struct attribute *dbs_attributes_gov_sys[] = {
-       &sampling_rate_min_gov_sys.attr,
+       &min_sampling_rate_gov_sys.attr,
        &sampling_rate_gov_sys.attr,
        &sampling_down_factor_gov_sys.attr,
        &up_threshold_gov_sys.attr,
@@ -272,7 +272,7 @@ static struct attribute_group cs_attr_group_gov_sys = {
 };
 
 static struct attribute *dbs_attributes_gov_pol[] = {
-       &sampling_rate_min_gov_pol.attr,
+       &min_sampling_rate_gov_pol.attr,
        &sampling_rate_gov_pol.attr,
        &sampling_down_factor_gov_pol.attr,
        &up_threshold_gov_pol.attr,
index 37537220e48cc7421399db34b5b09e66f13cdf7b..cdf7536ac5fbe902a03d381eac660edca22acfe3 100644 (file)
@@ -110,6 +110,26 @@ static ssize_t store_##file_name##_gov_pol                         \
 show_one(_gov, file_name);                                             \
 store_one(_gov, file_name)
 
+#define show_one_common(_gov, file_name)                               \
+static ssize_t show_##file_name##_gov_sys                              \
+(struct kobject *kobj, struct attribute *attr, char *buf)              \
+{                                                                      \
+       struct dbs_data *dbs_data = _gov##_dbs_gov.gdbs_data;           \
+       return sprintf(buf, "%u\n", dbs_data->file_name);               \
+}                                                                      \
+                                                                       \
+static ssize_t show_##file_name##_gov_pol                              \
+(struct cpufreq_policy *policy, char *buf)                             \
+{                                                                      \
+       struct policy_dbs_info *policy_dbs = policy->governor_data;     \
+       struct dbs_data *dbs_data = policy_dbs->dbs_data;               \
+       return sprintf(buf, "%u\n", dbs_data->file_name);               \
+}
+
+#define show_store_one_common(_gov, file_name)                         \
+show_one_common(_gov, file_name);                                      \
+store_one(_gov, file_name)
+
 /* create helper routines */
 #define define_get_cpu_dbs_routines(_dbs_info)                         \
 static struct cpu_dbs_info *get_cpu_cdbs(int cpu)                      \
@@ -264,22 +284,6 @@ static inline int delay_for_sampling_rate(unsigned int sampling_rate)
        return delay;
 }
 
-#define declare_show_sampling_rate_min(_gov)                           \
-static ssize_t show_sampling_rate_min_gov_sys                          \
-(struct kobject *kobj, struct attribute *attr, char *buf)              \
-{                                                                      \
-       struct dbs_data *dbs_data = _gov##_dbs_gov.gdbs_data;           \
-       return sprintf(buf, "%u\n", dbs_data->min_sampling_rate);       \
-}                                                                      \
-                                                                       \
-static ssize_t show_sampling_rate_min_gov_pol                          \
-(struct cpufreq_policy *policy, char *buf)                             \
-{                                                                      \
-       struct policy_dbs_info *policy_dbs = policy->governor_data;     \
-       struct dbs_data *dbs_data = policy_dbs->dbs_data;               \
-       return sprintf(buf, "%u\n", dbs_data->min_sampling_rate);       \
-}
-
 extern struct mutex dbs_data_mutex;
 extern struct mutex cpufreq_governor_lock;
 void dbs_check_cpu(struct cpufreq_policy *policy);
index b7ef2e7f4d4a4e497ff8039738b32266fa10cb31..8c44bc3fffc5419a7f11cc63d5fc2116e5ef7256 100644 (file)
@@ -443,7 +443,7 @@ show_store_one(od, up_threshold);
 show_store_one(od, sampling_down_factor);
 show_store_one(od, ignore_nice_load);
 show_store_one(od, powersave_bias);
-declare_show_sampling_rate_min(od);
+show_one_common(od, min_sampling_rate);
 
 gov_sys_pol_attr_rw(sampling_rate);
 gov_sys_pol_attr_rw(io_is_busy);
@@ -451,10 +451,10 @@ gov_sys_pol_attr_rw(up_threshold);
 gov_sys_pol_attr_rw(sampling_down_factor);
 gov_sys_pol_attr_rw(ignore_nice_load);
 gov_sys_pol_attr_rw(powersave_bias);
-gov_sys_pol_attr_ro(sampling_rate_min);
+gov_sys_pol_attr_ro(min_sampling_rate);
 
 static struct attribute *dbs_attributes_gov_sys[] = {
-       &sampling_rate_min_gov_sys.attr,
+       &min_sampling_rate_gov_sys.attr,
        &sampling_rate_gov_sys.attr,
        &up_threshold_gov_sys.attr,
        &sampling_down_factor_gov_sys.attr,
@@ -470,7 +470,7 @@ static struct attribute_group od_attr_group_gov_sys = {
 };
 
 static struct attribute *dbs_attributes_gov_pol[] = {
-       &sampling_rate_min_gov_pol.attr,
+       &min_sampling_rate_gov_pol.attr,
        &sampling_rate_gov_pol.attr,
        &up_threshold_gov_pol.attr,
        &sampling_down_factor_gov_pol.attr,