cpufreq: governor: Rearrange governor data structures
[deliverable/linux.git] / drivers / cpufreq / cpufreq_governor.h
index a9df62e87fcb632cf7501e1f6db59b009fbafb01..95e6834d36a831c8a43701aa84c023e3b79a2c1b 100644 (file)
@@ -78,14 +78,15 @@ __ATTR(_name, 0644, show_##_name##_gov_pol, store_##_name##_gov_pol)
 static ssize_t show_##file_name##_gov_sys                              \
 (struct kobject *kobj, struct attribute *attr, char *buf)              \
 {                                                                      \
-       struct _gov##_dbs_tuners *tuners = _gov##_dbs_cdata.gdbs_data->tuners; \
+       struct _gov##_dbs_tuners *tuners = _gov##_dbs_gov.gdbs_data->tuners; \
        return sprintf(buf, "%u\n", tuners->file_name);                 \
 }                                                                      \
                                                                        \
 static ssize_t show_##file_name##_gov_pol                              \
 (struct cpufreq_policy *policy, char *buf)                             \
 {                                                                      \
-       struct dbs_data *dbs_data = policy->governor_data;              \
+       struct policy_dbs_info *policy_dbs = policy->governor_data;     \
+       struct dbs_data *dbs_data = policy_dbs->dbs_data;               \
        struct _gov##_dbs_tuners *tuners = dbs_data->tuners;            \
        return sprintf(buf, "%u\n", tuners->file_name);                 \
 }
@@ -94,15 +95,15 @@ static ssize_t show_##file_name##_gov_pol                           \
 static ssize_t store_##file_name##_gov_sys                             \
 (struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) \
 {                                                                      \
-       struct dbs_data *dbs_data = _gov##_dbs_cdata.gdbs_data;         \
+       struct dbs_data *dbs_data = _gov##_dbs_gov.gdbs_data;           \
        return store_##file_name(dbs_data, buf, count);                 \
 }                                                                      \
                                                                        \
 static ssize_t store_##file_name##_gov_pol                             \
 (struct cpufreq_policy *policy, const char *buf, size_t count)         \
 {                                                                      \
-       struct dbs_data *dbs_data = policy->governor_data;              \
-       return store_##file_name(dbs_data, buf, count);                 \
+       struct policy_dbs_info *policy_dbs = policy->governor_data;     \
+       return store_##file_name(policy_dbs->dbs_data, buf, count);                     \
 }
 
 #define show_store_one(_gov, file_name)                                        \
@@ -130,8 +131,15 @@ static void *get_cpu_dbs_info_s(int cpu)                           \
  * cs_*: Conservative governor
  */
 
+/* Governor demand based switching data (per-policy or global). */
+struct dbs_data {
+       unsigned int min_sampling_rate;
+       int usage_count;
+       void *tuners;
+};
+
 /* Common to all CPUs of a policy */
-struct cpu_common_dbs_info {
+struct policy_dbs_info {
        struct cpufreq_policy *policy;
        /*
         * Per policy mutex that serializes load evaluation from limit-change
@@ -144,12 +152,14 @@ struct cpu_common_dbs_info {
        atomic_t skip_work;
        struct irq_work irq_work;
        struct work_struct work;
+       /* dbs_data may be shared between multiple policy objects */
+       struct dbs_data *dbs_data;
 };
 
-static inline void gov_update_sample_delay(struct cpu_common_dbs_info *shared,
+static inline void gov_update_sample_delay(struct policy_dbs_info *policy_dbs,
                                           unsigned int delay_us)
 {
-       shared->sample_delay_ns = delay_us * NSEC_PER_USEC;
+       policy_dbs->sample_delay_ns = delay_us * NSEC_PER_USEC;
 }
 
 /* Per cpu structures */
@@ -165,7 +175,7 @@ struct cpu_dbs_info {
         */
        unsigned int prev_load;
        struct update_util_data update_util;
-       struct cpu_common_dbs_info *shared;
+       struct policy_dbs_info *policy_dbs;
 };
 
 struct od_cpu_dbs_info_s {
@@ -204,9 +214,9 @@ struct cs_dbs_tuners {
 };
 
 /* Common Governor data across policies */
-struct dbs_data;
-struct common_dbs_data {
-       /* Common across governors */
+struct dbs_governor {
+       struct cpufreq_governor gov;
+
        #define GOV_ONDEMAND            0
        #define GOV_CONSERVATIVE        1
        int governor;
@@ -230,13 +240,10 @@ struct common_dbs_data {
        void *gov_ops;
 };
 
-/* Governor Per policy data */
-struct dbs_data {
-       struct common_dbs_data *cdata;
-       unsigned int min_sampling_rate;
-       int usage_count;
-       void *tuners;
-};
+static inline struct dbs_governor *dbs_governor_of(struct cpufreq_policy *policy)
+{
+       return container_of(policy->governor, struct dbs_governor, gov);
+}
 
 /* Governor specific ops, will be passed to dbs_data->gov_ops */
 struct od_ops {
@@ -261,22 +268,22 @@ static inline int delay_for_sampling_rate(unsigned int sampling_rate)
 static ssize_t show_sampling_rate_min_gov_sys                          \
 (struct kobject *kobj, struct attribute *attr, char *buf)              \
 {                                                                      \
-       struct dbs_data *dbs_data = _gov##_dbs_cdata.gdbs_data;         \
+       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 dbs_data *dbs_data = policy->governor_data;              \
+       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 dbs_data *dbs_data, int cpu);
-int cpufreq_governor_dbs(struct cpufreq_policy *policy,
-               struct common_dbs_data *cdata, unsigned int event);
+void dbs_check_cpu(struct cpufreq_policy *policy);
+int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event);
 void od_register_powersave_bias_handler(unsigned int (*f)
                (struct cpufreq_policy *, unsigned int, unsigned int),
                unsigned int powersave_bias);
This page took 0.045041 seconds and 5 git commands to generate.