Merge tag 'powerpc-4.4-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
[firefly-linux-kernel-4.4.55.git] / drivers / thermal / devfreq_cooling.c
index a032c5d5c37405f009bd643acbe71c2b605520b6..01f0015f80dc3f4d03409aff8d4732c1f17e57b6 100644 (file)
@@ -25,6 +25,8 @@
 #include <linux/pm_opp.h>
 #include <linux/thermal.h>
 
+#include <trace/events/thermal.h>
+
 static DEFINE_MUTEX(devfreq_lock);
 static DEFINE_IDR(devfreq_idr);
 
@@ -255,7 +257,7 @@ static unsigned long
 get_dynamic_power(struct devfreq_cooling_device *dfc, unsigned long freq,
                  unsigned long voltage)
 {
-       unsigned long power;
+       u64 power;
        u32 freq_mhz;
        struct devfreq_cooling_power *dfc_power = dfc->power_ops;
 
@@ -293,6 +295,9 @@ static int devfreq_cooling_get_requested_power(struct thermal_cooling_device *cd
        /* Get static power */
        static_power = get_static_power(dfc, freq);
 
+       trace_thermal_power_devfreq_get_power(cdev, status, freq, dyn_power,
+                                             static_power);
+
        *power = dyn_power + static_power;
 
        return 0;
@@ -348,6 +353,7 @@ static int devfreq_cooling_power2state(struct thermal_cooling_device *cdev,
                        break;
 
        *state = i;
+       trace_thermal_power_devfreq_limit(cdev, freq, *state, power);
        return 0;
 }
 
@@ -391,7 +397,7 @@ static int devfreq_cooling_gen_tables(struct devfreq_cooling_device *dfc)
                power_table = kcalloc(num_opps, sizeof(*power_table),
                                      GFP_KERNEL);
                if (!power_table)
-                       ret = -ENOMEM;
+                       return -ENOMEM;
        }
 
        freq_table = kcalloc(num_opps, sizeof(*freq_table),
@@ -461,7 +467,7 @@ free_power_table:
  * devfreq should use the simple_ondemand governor, other governors
  * are not currently supported.
  */
-struct devfreq_cooling_device *
+struct thermal_cooling_device *
 of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
                                  struct devfreq_cooling_power *dfc_power)
 {
@@ -507,7 +513,7 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
 
        dfc->cdev = cdev;
 
-       return dfc;
+       return cdev;
 
 release_idr:
        release_idr(&devfreq_idr, dfc->id);
@@ -527,7 +533,7 @@ EXPORT_SYMBOL_GPL(of_devfreq_cooling_register_power);
  * @np: Pointer to OF device_node.
  * @df: Pointer to devfreq device.
  */
-struct devfreq_cooling_device *
+struct thermal_cooling_device *
 of_devfreq_cooling_register(struct device_node *np, struct devfreq *df)
 {
        return of_devfreq_cooling_register_power(np, df, NULL);
@@ -538,7 +544,7 @@ EXPORT_SYMBOL_GPL(of_devfreq_cooling_register);
  * devfreq_cooling_register() - Register devfreq cooling device.
  * @df: Pointer to devfreq device.
  */
-struct devfreq_cooling_device *devfreq_cooling_register(struct devfreq *df)
+struct thermal_cooling_device *devfreq_cooling_register(struct devfreq *df)
 {
        return of_devfreq_cooling_register(NULL, df);
 }
@@ -548,11 +554,15 @@ EXPORT_SYMBOL_GPL(devfreq_cooling_register);
  * devfreq_cooling_unregister() - Unregister devfreq cooling device.
  * @dfc: Pointer to devfreq cooling device to unregister.
  */
-void devfreq_cooling_unregister(struct devfreq_cooling_device *dfc)
+void devfreq_cooling_unregister(struct thermal_cooling_device *cdev)
 {
-       if (!dfc)
+       struct devfreq_cooling_device *dfc;
+
+       if (!cdev)
                return;
 
+       dfc = cdev->devdata;
+
        thermal_cooling_device_unregister(dfc->cdev);
        release_idr(&devfreq_idr, dfc->id);
        kfree(dfc->power_table);