cpufreq: allow driver-specific data
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Sun, 19 Oct 2014 09:30:27 +0000 (11:30 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 20 Oct 2014 22:51:01 +0000 (00:51 +0200)
This commit extends the cpufreq_driver structure with an additional
'void *driver_data' field that can be filled by the ->probe() function
of a cpufreq driver to pass additional custom information to the
driver itself.

A new function called cpufreq_get_driver_data() is added to allow a
cpufreq driver to retrieve those driver data, since they are typically
needed from a cpufreq_policy->init() callback, which does not have
access to the cpufreq_driver structure. This function call is similar
to the existing cpufreq_get_current_driver() function call.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq.c
include/linux/cpufreq.h

index 24bf76fba141197eda0c2d4ec24ecbf4311860d1..058d6e084a6d59473001d6e4c8fb8a6584385d40 100644 (file)
@@ -1731,6 +1731,21 @@ const char *cpufreq_get_current_driver(void)
 }
 EXPORT_SYMBOL_GPL(cpufreq_get_current_driver);
 
+/**
+ *     cpufreq_get_driver_data - return current driver data
+ *
+ *     Return the private data of the currently loaded cpufreq
+ *     driver, or NULL if no cpufreq driver is loaded.
+ */
+void *cpufreq_get_driver_data(void)
+{
+       if (cpufreq_driver)
+               return cpufreq_driver->driver_data;
+
+       return NULL;
+}
+EXPORT_SYMBOL_GPL(cpufreq_get_driver_data);
+
 /*********************************************************************
  *                     NOTIFIER LISTS INTERFACE                      *
  *********************************************************************/
index 138336b6bb0437f4cc0972f7c4ce34a59bf9b2ec..503b085b7832f66a9207b2fdcb8a2f3e98a6bf3e 100644 (file)
@@ -219,6 +219,7 @@ __ATTR(_name, 0644, show_##_name, store_##_name)
 struct cpufreq_driver {
        char                    name[CPUFREQ_NAME_LEN];
        u8                      flags;
+       void                    *driver_data;
 
        /* needed by all drivers */
        int     (*init)         (struct cpufreq_policy *policy);
@@ -312,6 +313,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data);
 int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);
 
 const char *cpufreq_get_current_driver(void);
+void *cpufreq_get_driver_data(void);
 
 static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy,
                unsigned int min, unsigned int max)