Merge tag 'sunxi-fixes-for-4.3' of https://git.kernel.org/pub/scm/linux/kernel/git...
[linux-drm-fsl-dcu.git] / include / linux / devfreq.h
index ce447f0f1bad49e24351cec2c1ae0e2d2620ad4a..68030e22af3527958ac39006031dd62388228091 100644 (file)
@@ -65,7 +65,10 @@ struct devfreq_dev_status {
  *                     The "flags" parameter's possible values are
  *                     explained above with "DEVFREQ_FLAG_*" macros.
  * @get_dev_status:    The device should provide the current performance
- *                     status to devfreq, which is used by governors.
+ *                     status to devfreq. Governors are recommended not to
+ *                     use this directly. Instead, governors are recommended
+ *                     to use devfreq_update_stats() along with
+ *                     devfreq.last_status.
  * @get_cur_freq:      The device should provide the current frequency
  *                     at which it is operating.
  * @exit:              An optional callback that is called when devfreq
@@ -161,6 +164,7 @@ struct devfreq {
        struct delayed_work work;
 
        unsigned long previous_freq;
+       struct devfreq_dev_status last_status;
 
        void *data; /* private data for governors */
 
@@ -204,6 +208,19 @@ extern int devm_devfreq_register_opp_notifier(struct device *dev,
 extern void devm_devfreq_unregister_opp_notifier(struct device *dev,
                                                struct devfreq *devfreq);
 
+/**
+ * devfreq_update_stats() - update the last_status pointer in struct devfreq
+ * @df:                the devfreq instance whose status needs updating
+ *
+ *  Governors are recommended to use this function along with last_status,
+ * which allows other entities to reuse the last_status without affecting
+ * the values fetched later by governors.
+ */
+static inline int devfreq_update_stats(struct devfreq *df)
+{
+       return df->profile->get_dev_status(df->dev.parent, &df->last_status);
+}
+
 #if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND)
 /**
  * struct devfreq_simple_ondemand_data - void *data fed to struct devfreq
@@ -289,6 +306,11 @@ static inline void devm_devfreq_unregister_opp_notifier(struct device *dev,
                                                        struct devfreq *devfreq)
 {
 }
+
+static inline int devfreq_update_stats(struct devfreq *df)
+{
+       return -EINVAL;
+}
 #endif /* CONFIG_PM_DEVFREQ */
 
 #endif /* __LINUX_DEVFREQ_H__ */