devfreq: Add current freq callback in device profile
Quoted 9 lines
From: Rajagopal Venkat <[email protected]>
Devfreq returns governor predicted frequency as current frequency via sysfs interface. But device may not support all frequencies that governor predicts. So add a callback in device profile to get current freq from driver. Also add a new sysfs node to expose governor predicted next target frequency.
Signed-off-by Rajagopal Venkat <[email protected]>
Quoted 91 lines
--- Documentation/ABI/testing/sysfs-class-devfreq | 11 ++++++++++- drivers/devfreq/devfreq.c | 14 ++++++++++++++ include/linux/devfreq.h | 3 +++ 3 files changed, 27 insertions(+), 1 deletion(-)Documentation/ABI/testing/sysfs-class-devfreq +10
-1@@ -19,7 +19,16 @@ Date: September 2011 Contact: MyungJoo Ham <[email protected]> Description: The /sys/class/devfreq/.../cur_freq shows the current - frequency of the corresponding devfreq object. + frequency of the corresponding devfreq object. Same as + target_freq when get_cur_freq() is not implemented by + devfreq driver. + +What: /sys/class/devfreq/.../target_freq +Date: September 2012 +Contact: Rajagopal Venkat <[email protected]> +Description: + The /sys/class/devfreq/.../target_freq shows the next governor + predicted target frequency of the corresponding devfreq object. What: /sys/class/devfreq/.../polling_interval Date: September 2011drivers/devfreq/devfreq.c +14
-0@@ -401,6 +401,19 @@ static ssize_t show_governor(struct device *dev,static ssize_t show_freq (struct device *dev,struct device_attribute *attr,char *buf) { +unsigned long freq; +struct devfreq *devfreq =to_devfreq (dev); + +if (devfreq->profile->get_cur_freq && + !devfreq->profile->get_cur_freq (devfreq->dev.parent, &freq)) +return sprintf (buf,"%lu\n" , freq); + +return sprintf (buf,"%lu\n" , devfreq->previous_freq); +} + +static ssize_t show_target_freq (struct device *dev, +struct device_attribute *attr,char *buf) +{return sprintf (buf,"%lu\n" ,to_devfreq (dev)->previous_freq); }@@ -504,6 +517,7 @@ static ssize_t show_max_freq(struct device *dev, struct device_attribute *attr,static struct device_attribute devfreq_attrs[] = {__ATTR (governor,S_IRUGO , show_governor,NULL ),__ATTR (cur_freq,S_IRUGO , show_freq,NULL ), +__ATTR (target_freq,S_IRUGO , show_target_freq,NULL ),__ATTR (polling_interval,S_IRUGO |S_IWUSR , show_polling_interval, store_polling_interval),__ATTR (min_freq,S_IRUGO |S_IWUSR , show_min_freq, store_min_freq),include/linux/devfreq.h +3
-0@@ -66,6 +66,8 @@ struct devfreq_dev_status {* explained above with "DEVFREQ_FLAG_*" macros. * @get_dev_status The device should provide the current performance * status to devfreq, which is used by governors. +* @get_cur_freq The device should provide the current frequency +* at which it is operating. * @exit An optional callback that is called when devfreq * is removing the devfreq object due to error or * from devfreq_remove_device() call. If the user @@ -79,6 +81,7 @@ struct devfreq_dev_profile {int (*target)(struct device *dev,unsigned long *freq,u32 flags);int (*get_dev_status)(struct device *dev,struct devfreq_dev_status *stat); +int (*get_cur_freq)(struct device *dev,unsigned long *freq);void (*exit)(struct device *dev); };Signature · 1 line
1.7.11.3
�淸�{.n�+돴윯돪�+%듚�깁負쪐w��{.n�+돴쪐{깸G쳺��{ay����,j�f"톒쉹��묎�z_溫(�쉸듶줷"얎�m����G쳺�◀?솳鈺�&x�~뤳턨O뺞촾퇉v�^�m����띠�◀?뻀�
Quoted 11 lines · MyungJoo Ham
Quoted 9 lines
From: Rajagopal Venkat <[email protected]>
Devfreq returns governor predicted frequency as current frequency via sysfs interface. But device may not support all frequencies that governor predicts. So add a callback in device profile to get current freq from driver. Also add a new sysfs node to expose governor predicted next target frequency.
Signed-off-by Rajagopal Venkat <[email protected]>Signed-off-by MyungJoo Ham <[email protected]>
OK, I'm taking this as an acked-by (signed-off-by would be appropriate if the patch went through your hands).
Does it apply to [3/3] only or to all of the patches in the series?
Rafael
Quoted 82 lines
Quoted 81 lines
--- Documentation/ABI/testing/sysfs-class-devfreq | 11 ++++++++++- drivers/devfreq/devfreq.c | 14 ++++++++++++++ include/linux/devfreq.h | 3 +++ 3 files changed, 27 insertions(+), 1 deletion(-)Documentation/ABI/testing/sysfs-class-devfreq +10
-1@@ -19,7 +19,16 @@ Date: September 2011 Contact: MyungJoo Ham <[email protected]> Description: The /sys/class/devfreq/.../cur_freq shows the current - frequency of the corresponding devfreq object. + frequency of the corresponding devfreq object. Same as + target_freq when get_cur_freq() is not implemented by + devfreq driver. + +What: /sys/class/devfreq/.../target_freq +Date: September 2012 +Contact: Rajagopal Venkat <[email protected]> +Description: + The /sys/class/devfreq/.../target_freq shows the next governor + predicted target frequency of the corresponding devfreq object. What: /sys/class/devfreq/.../polling_interval Date: September 2011drivers/devfreq/devfreq.c +14
-0@@ -401,6 +401,19 @@ static ssize_t show_governor(struct device *dev,static ssize_t show_freq (struct device *dev,struct device_attribute *attr,char *buf) { +unsigned long freq; +struct devfreq *devfreq =to_devfreq (dev); + +if (devfreq->profile->get_cur_freq && + !devfreq->profile->get_cur_freq (devfreq->dev.parent, &freq)) +return sprintf (buf,"%lu\n" , freq); + +return sprintf (buf,"%lu\n" , devfreq->previous_freq); +} + +static ssize_t show_target_freq (struct device *dev, +struct device_attribute *attr,char *buf) +{return sprintf (buf,"%lu\n" ,to_devfreq (dev)->previous_freq); }@@ -504,6 +517,7 @@ static ssize_t show_max_freq(struct device *dev, struct device_attribute *attr,static struct device_attribute devfreq_attrs[] = {__ATTR (governor,S_IRUGO , show_governor,NULL ),__ATTR (cur_freq,S_IRUGO , show_freq,NULL ), +__ATTR (target_freq,S_IRUGO , show_target_freq,NULL ),__ATTR (polling_interval,S_IRUGO |S_IWUSR , show_polling_interval, store_polling_interval),__ATTR (min_freq,S_IRUGO |S_IWUSR , show_min_freq, store_min_freq),include/linux/devfreq.h +3
-0@@ -66,6 +66,8 @@ struct devfreq_dev_status {* explained above with "DEVFREQ_FLAG_*" macros. * @get_dev_status The device should provide the current performance * status to devfreq, which is used by governors. +* @get_cur_freq The device should provide the current frequency +* at which it is operating. * @exit An optional callback that is called when devfreq * is removing the devfreq object due to error or * from devfreq_remove_device() call. If the user @@ -79,6 +81,7 @@ struct devfreq_dev_profile {int (*target)(struct device *dev,unsigned long *freq,u32 flags);int (*get_dev_status)(struct device *dev,struct devfreq_dev_status *stat); +int (*get_cur_freq)(struct device *dev,unsigned long *freq);void (*exit)(struct device *dev); };