devfreq: Rename devfreq_update_status() to devfreq_update_stats() and viceversa
Subsystems (4)
PATCH 1/2 devfreq: Rename devfreq_update_status() to devfreq_update_stats() and viceversa
devfreq has two functions with very similar names, devfreq_update_status() and devfreq_update_stats(). _update_status() currently updates frequency transitions statistics, while _update_stats() retrieves the device 'status'. The function names are inversed with respect to what the functions are actually doing, rename devfreq_update_status() to devfreq_update_stats() and viceversa.
---
We could also rename the current devfreq_update_stats() to devfreq_refresh_status() to make it easier to distinguish it from devfreq_update_stats().
--- drivers/devfreq/devfreq.c | 12 ++++++------ drivers/devfreq/governor.h | 4 ++-- drivers/devfreq/governor_passive.c | 2 +- drivers/devfreq/governor_simpleondemand.c | 2 +- drivers/devfreq/tegra30-devfreq.c | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-)
drivers/devfreq/devfreq.c +6 -6
@@ -151,11 +151,11 @@ static int set_freq_table(struct devfreq *devfreq) }/** -* devfreq_update_status() - Update statistics of devfreq behavior +* devfreq_update_stats() - Update statistics of devfreq behavior * @devfreq: the devfreq instance * @freq: the update target frequency */ -int devfreq_update_status (struct devfreq *devfreq,unsigned long freq) +int devfreq_update_stats (struct devfreq *devfreq,unsigned long freq) {int lev, prev_lev, ret =0 ;unsigned long cur_time;
@@ -191,7 +191,7 @@ int devfreq_update_status(struct devfreq *devfreq, unsigned long freq) devfreq->last_stat_updated = cur_time;return ret; } -EXPORT_SYMBOL (devfreq_update_status); +EXPORT_SYMBOL (devfreq_update_stats);/** * find_devfreq_governor() - find devfreq governor from name
@@ -311,7 +311,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq, freqs.new = new_freq;devfreq_notify_transition (devfreq, &freqs,DEVFREQ_POSTCHANGE ); -if (devfreq_update_status (devfreq, new_freq)) +if (devfreq_update_stats (devfreq, new_freq))dev_err (&devfreq->dev,"Couldn't update frequency transition information.\n" );
@@ -450,7 +450,7 @@ void devfreq_monitor_suspend(struct devfreq *devfreq)return ; } -devfreq_update_status (devfreq, devfreq->previous_freq); +devfreq_update_stats (devfreq, devfreq->previous_freq); devfreq->stop_polling = true;mutex_unlock (&devfreq->lock);cancel_delayed_work_sync (&devfreq->work);
@@ -1398,7 +1398,7 @@ static ssize_t trans_stat_show(struct device *dev,unsigned int max_state = devfreq->profile->max_state;if (!devfreq->stop_polling && -devfreq_update_status (devfreq, devfreq->previous_freq)) +devfreq_update_stats (devfreq, devfreq->previous_freq))return 0 ;if (max_state ==0 )return sprintf (buf,"Not Supported.\n" );
drivers/devfreq/governor.h +2 -2
@@ -64,9 +64,9 @@ extern void devfreq_interval_update(struct devfreq *devfreq,extern int devfreq_add_governor (struct devfreq_governor *governor);extern int devfreq_remove_governor (struct devfreq_governor *governor); -extern int devfreq_update_status (struct devfreq *devfreq,unsigned long freq); +extern int devfreq_update_stats (struct devfreq *devfreq,unsigned long freq); -static inline int devfreq_update_stats (struct devfreq *df) +static inline int devfreq_update_status (struct devfreq *df) {return df->profile->get_dev_status (df->dev.parent, &df->last_status); }
drivers/devfreq/governor_passive.c +1 -1
@@ -110,7 +110,7 @@ static int update_devfreq_passive(struct devfreq *devfreq, unsigned long freq) goto out;if (devfreq->profile->freq_table - && (devfreq_update_status (devfreq, freq))) + && (devfreq_update_stats (devfreq, freq)))dev_err (&devfreq->dev,"Couldn't update frequency transition information.\n" );
drivers/devfreq/governor_simpleondemand.c +1 -1
@@ -25,7 +25,7 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,unsigned int dfso_downdifferential =DFSO_DOWNDIFFERENCTIAL ;struct devfreq_simple_ondemand_data *data = df->data; - err =devfreq_update_stats (df); + err =devfreq_update_status (df);if (err)return err;
drivers/devfreq/tegra30-devfreq.c +1 -1
@@ -526,7 +526,7 @@ static int tegra_governor_get_target(struct devfreq *devfreq,unsigned int i;int err; - err =devfreq_update_stats (devfreq); + err =devfreq_update_status (devfreq);if (err)return err;
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
PATCH 2/2 devfreq: Rename df->previous_freq to df->cur_freq
The vast majority of code uses df->previous_freq to get the current frequency of the devfreq device, not the previous one. Rename the struct field to reflect this.
Add a comment to devfreq_update_stats() to make clear that df->cur_freq must only be updated after calling this function in the context of a frequency transition.
--- drivers/devfreq/devfreq.c | 28 ++++++++++++++++------------ drivers/devfreq/governor_passive.c | 6 +++--- drivers/devfreq/governor_userspace.c | 2 +- drivers/devfreq/tegra20-devfreq.c | 2 +- drivers/devfreq/tegra30-devfreq.c | 2 +- include/linux/devfreq.h | 4 ++-- include/trace/events/devfreq.h | 2 +- 7 files changed, 25 insertions(+), 21 deletions(-)
drivers/devfreq/devfreq.c +16 -12
@@ -154,6 +154,10 @@ static int set_freq_table(struct devfreq *devfreq)* devfreq_update_stats() - Update statistics of devfreq behavior * @devfreq: the devfreq instance * @freq: the update target frequency +* +* If the function is called in the context of a frequency transition +* it expects df->cur_freq to contain the value *before* the transition. +* The field must only be updated after calling devfreq_update_stats(). */ int devfreq_update_stats (struct devfreq *devfreq,unsigned long freq) {
@@ -162,11 +166,11 @@ int devfreq_update_stats(struct devfreq *devfreq, unsigned long freq) cur_time = jiffies; -/* Immediately exit if previous_freq is not initialized yet. */ -if (!devfreq->previous_freq) +/* Immediately exit if cur_freq is not initialized yet. */ +if (!devfreq->cur_freq) goto out; - prev_lev =devfreq_get_freq_level (devfreq, devfreq->previous_freq); + prev_lev =devfreq_get_freq_level (devfreq, devfreq->cur_freq);if (prev_lev <0 ) { ret = prev_lev; goto out;
@@ -295,7 +299,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,if (devfreq->profile->get_cur_freq) devfreq->profile->get_cur_freq (devfreq->dev.parent, &cur_freq);else - cur_freq = devfreq->previous_freq; + cur_freq = devfreq->cur_freq; freqs.old = cur_freq; freqs.new = new_freq;
@@ -315,7 +319,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,dev_err (&devfreq->dev,"Couldn't update frequency transition information.\n" ); - devfreq->previous_freq = new_freq; + devfreq->cur_freq = new_freq;if (devfreq->suspend_freq) devfreq->resume_freq = cur_freq;
@@ -450,7 +454,7 @@ void devfreq_monitor_suspend(struct devfreq *devfreq)return ; } -devfreq_update_stats (devfreq, devfreq->previous_freq); +devfreq_update_stats (devfreq, devfreq->cur_freq); devfreq->stop_polling = true;mutex_unlock (&devfreq->lock);cancel_delayed_work_sync (&devfreq->work);
@@ -483,7 +487,7 @@ void devfreq_monitor_resume(struct devfreq *devfreq)if (devfreq->profile->get_cur_freq && !devfreq->profile->get_cur_freq (devfreq->dev.parent, &freq)) - devfreq->previous_freq = freq; + devfreq->cur_freq = freq; out:mutex_unlock (&devfreq->lock);
@@ -644,7 +648,7 @@ struct devfreq *devfreq_add_device(struct device *dev, devfreq->dev.release = devfreq_dev_release; devfreq->profile = profile;strncpy (devfreq->governor_name, governor_name,DEVFREQ_NAME_LEN ); - devfreq->previous_freq = profile->initial_freq; + devfreq->cur_freq = profile->initial_freq; devfreq->last_status.current_frequency = profile->initial_freq; devfreq->data = data; devfreq->nb.notifier_call = devfreq_notifier_call;
@@ -1235,14 +1239,14 @@ static ssize_t cur_freq_show(struct device *dev, struct device_attribute *attr, !devfreq->profile->get_cur_freq(devfreq->dev.parent, &freq))return sprintf (buf,"%lu\n" , freq); -return sprintf (buf,"%lu\n" , devfreq->previous_freq); +return sprintf (buf,"%lu\n" , devfreq->cur_freq); }static DEVICE_ATTR_RO (cur_freq);static ssize_t target_freq_show (struct device *dev,struct device_attribute *attr,char *buf) { -return sprintf (buf,"%lu\n" ,to_devfreq (dev)->previous_freq); +return sprintf (buf,"%lu\n" ,to_devfreq (dev)->cur_freq); }static DEVICE_ATTR_RO (target_freq);
@@ -1398,7 +1402,7 @@ static ssize_t trans_stat_show(struct device *dev,unsigned int max_state = devfreq->profile->max_state;if (!devfreq->stop_polling && -devfreq_update_stats (devfreq, devfreq->previous_freq)) +devfreq_update_stats (devfreq, devfreq->cur_freq))return 0 ;if (max_state ==0 )return sprintf (buf,"Not Supported.\n" );
@@ -1413,7 +1417,7 @@ static ssize_t trans_stat_show(struct device *dev,for (i =0 ; i < max_state; i++) {if (devfreq->profile->freq_table[i] - == devfreq->previous_freq) { + == devfreq->cur_freq) { len +=sprintf (buf + len,"*" ); }else { len +=sprintf (buf + len," " );
drivers/devfreq/governor_passive.c +3 -3
@@ -114,7 +114,7 @@ static int update_devfreq_passive(struct devfreq *devfreq, unsigned long freq)dev_err (&devfreq->dev,"Couldn't update frequency transition information.\n" ); - devfreq->previous_freq = freq; + devfreq->cur_freq = freq; out:mutex_unlock (&devfreq->lock);
@@ -134,11 +134,11 @@ static int devfreq_passive_notifier_call(struct notifier_block *nb,switch (event) {case DEVFREQ_PRECHANGE : -if (parent->previous_freq > freq) +if (parent->cur_freq > freq)update_devfreq_passive (devfreq, freq);break ;case DEVFREQ_POSTCHANGE : -if (parent->previous_freq < freq) +if (parent->cur_freq < freq)update_devfreq_passive (devfreq, freq);break ; }
drivers/devfreq/governor_userspace.c +1 -1
@@ -26,7 +26,7 @@ static int devfreq_userspace_func(struct devfreq *df, unsigned long *freq)if (data->valid) *freq = data->user_frequency;else - *freq = df->previous_freq;/* No user freq specified yet */ + *freq = df->cur_freq;/* No user freq specified yet */ return 0 ; }
drivers/devfreq/tegra20-devfreq.c +1 -1
@@ -61,7 +61,7 @@ static int tegra_devfreq_target(struct device *dev, unsigned long *freq,return 0 ; restore_min_rate: -clk_set_min_rate (tegra->emc_clock, devfreq->previous_freq); +clk_set_min_rate (tegra->emc_clock, devfreq->cur_freq);return err; }
drivers/devfreq/tegra30-devfreq.c +1 -1
@@ -474,7 +474,7 @@ static int tegra_devfreq_target(struct device *dev, unsigned long *freq,return 0 ; restore_min_rate: -clk_set_min_rate (tegra->emc_clock, devfreq->previous_freq); +clk_set_min_rate (tegra->emc_clock, devfreq->cur_freq);return err; }
include/linux/devfreq.h +2 -2
@@ -120,7 +120,7 @@ struct devfreq_dev_profile {* reevaluate operable frequencies. Devfreq users may use * devfreq.nb to the corresponding register notifier call chain. * @work: delayed work for load monitoring. -* @previous_freq: previously configured frequency value. +* @cur_freq: the current frequency. * @data: Private data of the governor. The devfreq framework does not * touch this. * @min_freq: Limit minimum frequency requested by user (0: none)
@@ -156,7 +156,7 @@ struct devfreq {struct notifier_block nb;struct delayed_work work; -unsigned long previous_freq; +unsigned long cur_freq;struct devfreq_dev_status last_status;void *data;/* private data for governors */
include/trace/events/devfreq.h +1 -1
@@ -22,7 +22,7 @@ TRACE_EVENT(devfreq_monitor, ), TP_fast_assign( - __entry->freq = devfreq->previous_freq; + __entry->freq = devfreq->cur_freq; __entry->busy_time = devfreq->last_status.busy_time; __entry->total_time = devfreq->last_status.total_time; __entry->polling_ms = devfreq->profile->polling_ms;
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
Chanwoo Choi
maintainerRe: [PATCH 2/2] devfreq: Rename df->previous_freq to df->cur_freq
Hi,
I'm not objecting this patch.
But, as I commented on previous patch,
Actually, according to reference time of the 'df->previous_freq', 'previous_freq' is proper or 'cur_freq is proper.
But, In the comment of 'struct devfreq', it means the configured time as following: It was the intention of author (Myungjoo).
* @previous_freq: previously configured frequency value.
I think that it's not problem ans better to keep the name if possible.
I leave the final decision of this patch to Myungjoo. If he like this patch, I have no any objection.
Quoted 231 lines · Matthias Kaehlcke
The vast majority of code uses
df->previous_freqto get the current frequency of the devfreq device, not the previous one. Rename the struct field to reflect this.Add a comment to
devfreq_update_stats()to make clear thatdf->cur_freqmust only be updated after calling this function in the context of a frequency transition.Signed-off-by Matthias Kaehlcke <[email protected]>--- drivers/devfreq/devfreq.c | 28 ++++++++++++++++------------ drivers/devfreq/governor_passive.c | 6 +++--- drivers/devfreq/governor_userspace.c | 2 +- drivers/devfreq/tegra20-devfreq.c | 2 +- drivers/devfreq/tegra30-devfreq.c | 2 +- include/linux/devfreq.h | 4 ++-- include/trace/events/devfreq.h | 2 +- 7 files changed, 25 insertions(+), 21 deletions(-)drivers/devfreq/devfreq.c +16
-12@@ -154,6 +154,10 @@ static int set_freq_table(struct devfreq *devfreq)* devfreq_update_stats() - Update statistics of devfreq behavior * @devfreq: the devfreq instance * @freq: the update target frequency +* +* If the function is called in the context of a frequency transition +* it expects df->cur_freq to contain the value *before* the transition. +* The field must only be updated after calling devfreq_update_stats(). */ int devfreq_update_stats (struct devfreq *devfreq,unsigned long freq) {@@ -162,11 +166,11 @@ int devfreq_update_stats(struct devfreq *devfreq, unsigned long freq) cur_time = jiffies; -/* Immediately exit if previous_freq is not initialized yet. */ -if (!devfreq->previous_freq) +/* Immediately exit if cur_freq is not initialized yet. */ +if (!devfreq->cur_freq) goto out; - prev_lev =devfreq_get_freq_level (devfreq, devfreq->previous_freq); + prev_lev =devfreq_get_freq_level (devfreq, devfreq->cur_freq);if (prev_lev <0 ) { ret = prev_lev; goto out;@@ -295,7 +299,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,if (devfreq->profile->get_cur_freq) devfreq->profile->get_cur_freq (devfreq->dev.parent, &cur_freq);else - cur_freq = devfreq->previous_freq; + cur_freq = devfreq->cur_freq; freqs.old = cur_freq; freqs.new = new_freq;@@ -315,7 +319,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,dev_err (&devfreq->dev,"Couldn't update frequency transition information.\n" ); - devfreq->previous_freq = new_freq; + devfreq->cur_freq = new_freq;if (devfreq->suspend_freq) devfreq->resume_freq = cur_freq;@@ -450,7 +454,7 @@ void devfreq_monitor_suspend(struct devfreq *devfreq)return ; } -devfreq_update_stats (devfreq, devfreq->previous_freq); +devfreq_update_stats (devfreq, devfreq->cur_freq); devfreq->stop_polling = true;mutex_unlock (&devfreq->lock);cancel_delayed_work_sync (&devfreq->work);@@ -483,7 +487,7 @@ void devfreq_monitor_resume(struct devfreq *devfreq)if (devfreq->profile->get_cur_freq && !devfreq->profile->get_cur_freq (devfreq->dev.parent, &freq)) - devfreq->previous_freq = freq; + devfreq->cur_freq = freq; out:mutex_unlock (&devfreq->lock);@@ -644,7 +648,7 @@ struct devfreq *devfreq_add_device(struct device *dev, devfreq->dev.release = devfreq_dev_release; devfreq->profile = profile;strncpy (devfreq->governor_name, governor_name,DEVFREQ_NAME_LEN ); - devfreq->previous_freq = profile->initial_freq; + devfreq->cur_freq = profile->initial_freq; devfreq->last_status.current_frequency = profile->initial_freq; devfreq->data = data; devfreq->nb.notifier_call = devfreq_notifier_call;@@ -1235,14 +1239,14 @@ static ssize_t cur_freq_show(struct device *dev, struct device_attribute *attr, !devfreq->profile->get_cur_freq(devfreq->dev.parent, &freq))return sprintf (buf,"%lu\n" , freq); -return sprintf (buf,"%lu\n" , devfreq->previous_freq); +return sprintf (buf,"%lu\n" , devfreq->cur_freq); }static DEVICE_ATTR_RO (cur_freq);static ssize_t target_freq_show (struct device *dev,struct device_attribute *attr,char *buf) { -return sprintf (buf,"%lu\n" ,to_devfreq (dev)->previous_freq); +return sprintf (buf,"%lu\n" ,to_devfreq (dev)->cur_freq); }static DEVICE_ATTR_RO (target_freq);@@ -1398,7 +1402,7 @@ static ssize_t trans_stat_show(struct device *dev,unsigned int max_state = devfreq->profile->max_state;if (!devfreq->stop_polling && -devfreq_update_stats (devfreq, devfreq->previous_freq)) +devfreq_update_stats (devfreq, devfreq->cur_freq))return 0 ;if (max_state ==0 )return sprintf (buf,"Not Supported.\n" );@@ -1413,7 +1417,7 @@ static ssize_t trans_stat_show(struct device *dev,for (i =0 ; i < max_state; i++) {if (devfreq->profile->freq_table[i] - == devfreq->previous_freq) { + == devfreq->cur_freq) { len +=sprintf (buf + len,"*" ); }else { len +=sprintf (buf + len," " );drivers/devfreq/governor_passive.c +3
-3@@ -114,7 +114,7 @@ static int update_devfreq_passive(struct devfreq *devfreq, unsigned long freq)dev_err (&devfreq->dev,"Couldn't update frequency transition information.\n" ); - devfreq->previous_freq = freq; + devfreq->cur_freq = freq; out:mutex_unlock (&devfreq->lock);@@ -134,11 +134,11 @@ static int devfreq_passive_notifier_call(struct notifier_block *nb,switch (event) {case DEVFREQ_PRECHANGE : -if (parent->previous_freq > freq) +if (parent->cur_freq > freq)update_devfreq_passive (devfreq, freq);break ;case DEVFREQ_POSTCHANGE : -if (parent->previous_freq < freq) +if (parent->cur_freq < freq)update_devfreq_passive (devfreq, freq);break ; }drivers/devfreq/governor_userspace.c +1
-1@@ -26,7 +26,7 @@ static int devfreq_userspace_func(struct devfreq *df, unsigned long *freq)if (data->valid) *freq = data->user_frequency;else - *freq = df->previous_freq;/* No user freq specified yet */ + *freq = df->cur_freq;/* No user freq specified yet */ return 0 ; }drivers/devfreq/tegra20-devfreq.c +1
-1@@ -61,7 +61,7 @@ static int tegra_devfreq_target(struct device *dev, unsigned long *freq,return 0 ; restore_min_rate: -clk_set_min_rate (tegra->emc_clock, devfreq->previous_freq); +clk_set_min_rate (tegra->emc_clock, devfreq->cur_freq);return err; }drivers/devfreq/tegra30-devfreq.c +1
-1@@ -474,7 +474,7 @@ static int tegra_devfreq_target(struct device *dev, unsigned long *freq,return 0 ; restore_min_rate: -clk_set_min_rate (tegra->emc_clock, devfreq->previous_freq); +clk_set_min_rate (tegra->emc_clock, devfreq->cur_freq);return err; }include/linux/devfreq.h +2
-2@@ -120,7 +120,7 @@ struct devfreq_dev_profile {* reevaluate operable frequencies. Devfreq users may use * devfreq.nb to the corresponding register notifier call chain. * @work: delayed work for load monitoring. -* @previous_freq: previously configured frequency value. +* @cur_freq: the current frequency. * @data: Private data of the governor. The devfreq framework does not * touch this. * @min_freq: Limit minimum frequency requested by user (0: none) @@ -156,7 +156,7 @@ struct devfreq {struct notifier_block nb;struct delayed_work work; -unsigned long previous_freq; +unsigned long cur_freq;struct devfreq_dev_status last_status;void *data;/* private data for governors */ include/trace/events/devfreq.h +1
-1@@ -22,7 +22,7 @@ TRACE_EVENT(devfreq_monitor, ), TP_fast_assign( - __entry->freq = devfreq->previous_freq; + __entry->freq = devfreq->cur_freq; __entry->busy_time = devfreq->last_status.busy_time; __entry->total_time = devfreq->last_status.total_time; __entry->polling_ms = devfreq->profile->polling_ms;
Signature · 3 lines
Best Regards, Chanwoo Choi Samsung Electronics
Re: [PATCH 2/2] devfreq: Rename df->previous_freq to df->cur_freq
Quoted 9 lines · Chanwoo Choi
Hi,
I'm not objecting this patch.
But, as I commented on previous patch,
Actually, according to reference time of the 'df->previous_freq', 'previous_freq' is proper or 'cur_freqis proper.
But, In the comment of 'struct devfreq', it means the configured time as following: It was the intention of author (Myungjoo).
* @previous_freq: previously configured frequency value.
The name made perfect sense in the context of the original commit a3c98b8b2ede ("PM: Introduce devfreq: generic DVFS framework with device-specific OPPs"), where the field was indeed only used to store the previous frequency. However the devfreq sub-system has evolved in the past 8 years, and nowadays the use is different.
Quoted 1 line
I think that it's not problem ans better to keep the name if possible.
IMO it's a strong signal that over 85% of the users of the variable use it in a way that doesn't match it's name, i.e. you read the code and wonder 'why is it using the previous frequency here???'. Code should be as self explanatory as possible, misleading variable don't help with that.
Quoted 2 lines
I leave the final decision of this patch to Myungjoo. If he like this patch, I have no any objection.
Myungjoo, what do you think about the patch?
Quoted 238 lines · Matthias Kaehlcke
Quoted 231 lines
The vast majority of code uses
df->previous_freqto get the current frequency of the devfreq device, not the previous one. Rename the struct field to reflect this.Add a comment to
devfreq_update_stats()to make clear thatdf->cur_freqmust only be updated after calling this function in the context of a frequency transition.Signed-off-by Matthias Kaehlcke <[email protected]>--- drivers/devfreq/devfreq.c | 28 ++++++++++++++++------------ drivers/devfreq/governor_passive.c | 6 +++--- drivers/devfreq/governor_userspace.c | 2 +- drivers/devfreq/tegra20-devfreq.c | 2 +- drivers/devfreq/tegra30-devfreq.c | 2 +- include/linux/devfreq.h | 4 ++-- include/trace/events/devfreq.h | 2 +- 7 files changed, 25 insertions(+), 21 deletions(-)drivers/devfreq/devfreq.c +16
-12@@ -154,6 +154,10 @@ static int set_freq_table(struct devfreq *devfreq)* devfreq_update_stats() - Update statistics of devfreq behavior * @devfreq: the devfreq instance * @freq: the update target frequency +* +* If the function is called in the context of a frequency transition +* it expects df->cur_freq to contain the value *before* the transition. +* The field must only be updated after calling devfreq_update_stats(). */ int devfreq_update_stats (struct devfreq *devfreq,unsigned long freq) {@@ -162,11 +166,11 @@ int devfreq_update_stats(struct devfreq *devfreq, unsigned long freq) cur_time = jiffies; -/* Immediately exit if previous_freq is not initialized yet. */ -if (!devfreq->previous_freq) +/* Immediately exit if cur_freq is not initialized yet. */ +if (!devfreq->cur_freq) goto out; - prev_lev =devfreq_get_freq_level (devfreq, devfreq->previous_freq); + prev_lev =devfreq_get_freq_level (devfreq, devfreq->cur_freq);if (prev_lev <0 ) { ret = prev_lev; goto out;@@ -295,7 +299,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,if (devfreq->profile->get_cur_freq) devfreq->profile->get_cur_freq (devfreq->dev.parent, &cur_freq);else - cur_freq = devfreq->previous_freq; + cur_freq = devfreq->cur_freq; freqs.old = cur_freq; freqs.new = new_freq;@@ -315,7 +319,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq,dev_err (&devfreq->dev,"Couldn't update frequency transition information.\n" ); - devfreq->previous_freq = new_freq; + devfreq->cur_freq = new_freq;if (devfreq->suspend_freq) devfreq->resume_freq = cur_freq;@@ -450,7 +454,7 @@ void devfreq_monitor_suspend(struct devfreq *devfreq)return ; } -devfreq_update_stats (devfreq, devfreq->previous_freq); +devfreq_update_stats (devfreq, devfreq->cur_freq); devfreq->stop_polling = true;mutex_unlock (&devfreq->lock);cancel_delayed_work_sync (&devfreq->work);@@ -483,7 +487,7 @@ void devfreq_monitor_resume(struct devfreq *devfreq)if (devfreq->profile->get_cur_freq && !devfreq->profile->get_cur_freq (devfreq->dev.parent, &freq)) - devfreq->previous_freq = freq; + devfreq->cur_freq = freq; out:mutex_unlock (&devfreq->lock);@@ -644,7 +648,7 @@ struct devfreq *devfreq_add_device(struct device *dev, devfreq->dev.release = devfreq_dev_release; devfreq->profile = profile;strncpy (devfreq->governor_name, governor_name,DEVFREQ_NAME_LEN ); - devfreq->previous_freq = profile->initial_freq; + devfreq->cur_freq = profile->initial_freq; devfreq->last_status.current_frequency = profile->initial_freq; devfreq->data = data; devfreq->nb.notifier_call = devfreq_notifier_call;@@ -1235,14 +1239,14 @@ static ssize_t cur_freq_show(struct device *dev, struct device_attribute *attr, !devfreq->profile->get_cur_freq(devfreq->dev.parent, &freq))return sprintf (buf,"%lu\n" , freq); -return sprintf (buf,"%lu\n" , devfreq->previous_freq); +return sprintf (buf,"%lu\n" , devfreq->cur_freq); }static DEVICE_ATTR_RO (cur_freq);static ssize_t target_freq_show (struct device *dev,struct device_attribute *attr,char *buf) { -return sprintf (buf,"%lu\n" ,to_devfreq (dev)->previous_freq); +return sprintf (buf,"%lu\n" ,to_devfreq (dev)->cur_freq); }static DEVICE_ATTR_RO (target_freq);@@ -1398,7 +1402,7 @@ static ssize_t trans_stat_show(struct device *dev,unsigned int max_state = devfreq->profile->max_state;if (!devfreq->stop_polling && -devfreq_update_stats (devfreq, devfreq->previous_freq)) +devfreq_update_stats (devfreq, devfreq->cur_freq))return 0 ;if (max_state ==0 )return sprintf (buf,"Not Supported.\n" );@@ -1413,7 +1417,7 @@ static ssize_t trans_stat_show(struct device *dev,for (i =0 ; i < max_state; i++) {if (devfreq->profile->freq_table[i] - == devfreq->previous_freq) { + == devfreq->cur_freq) { len +=sprintf (buf + len,"*" ); }else { len +=sprintf (buf + len," " );drivers/devfreq/governor_passive.c +3
-3@@ -114,7 +114,7 @@ static int update_devfreq_passive(struct devfreq *devfreq, unsigned long freq)dev_err (&devfreq->dev,"Couldn't update frequency transition information.\n" ); - devfreq->previous_freq = freq; + devfreq->cur_freq = freq; out:mutex_unlock (&devfreq->lock);@@ -134,11 +134,11 @@ static int devfreq_passive_notifier_call(struct notifier_block *nb,switch (event) {case DEVFREQ_PRECHANGE : -if (parent->previous_freq > freq) +if (parent->cur_freq > freq)update_devfreq_passive (devfreq, freq);break ;case DEVFREQ_POSTCHANGE : -if (parent->previous_freq < freq) +if (parent->cur_freq < freq)update_devfreq_passive (devfreq, freq);break ; }drivers/devfreq/governor_userspace.c +1
-1@@ -26,7 +26,7 @@ static int devfreq_userspace_func(struct devfreq *df, unsigned long *freq)if (data->valid) *freq = data->user_frequency;else - *freq = df->previous_freq;/* No user freq specified yet */ + *freq = df->cur_freq;/* No user freq specified yet */ return 0 ; }drivers/devfreq/tegra20-devfreq.c +1
-1@@ -61,7 +61,7 @@ static int tegra_devfreq_target(struct device *dev, unsigned long *freq,return 0 ; restore_min_rate: -clk_set_min_rate (tegra->emc_clock, devfreq->previous_freq); +clk_set_min_rate (tegra->emc_clock, devfreq->cur_freq);return err; }drivers/devfreq/tegra30-devfreq.c +1
-1@@ -474,7 +474,7 @@ static int tegra_devfreq_target(struct device *dev, unsigned long *freq,return 0 ; restore_min_rate: -clk_set_min_rate (tegra->emc_clock, devfreq->previous_freq); +clk_set_min_rate (tegra->emc_clock, devfreq->cur_freq);return err; }include/linux/devfreq.h +2
-2@@ -120,7 +120,7 @@ struct devfreq_dev_profile {* reevaluate operable frequencies. Devfreq users may use * devfreq.nb to the corresponding register notifier call chain. * @work: delayed work for load monitoring. -* @previous_freq: previously configured frequency value. +* @cur_freq: the current frequency. * @data: Private data of the governor. The devfreq framework does not * touch this. * @min_freq: Limit minimum frequency requested by user (0: none) @@ -156,7 +156,7 @@ struct devfreq {struct notifier_block nb;struct delayed_work work; -unsigned long previous_freq; +unsigned long cur_freq;struct devfreq_dev_status last_status;void *data;/* private data for governors */ include/trace/events/devfreq.h +1
-1@@ -22,7 +22,7 @@ TRACE_EVENT(devfreq_monitor, ), TP_fast_assign( - __entry->freq = devfreq->previous_freq; + __entry->freq = devfreq->cur_freq; __entry->busy_time = devfreq->last_status.busy_time; __entry->total_time = devfreq->last_status.total_time; __entry->polling_ms = devfreq->profile->polling_ms;Signature · 3 lines
Best Regards, Chanwoo Choi Samsung Electronics
Chanwoo Choi
maintainerHi,
I'm not sure that it is necessary. I think that it depends on personal opinions. There are no correct answer perfectly. Also, after this changes, there are no any beneficial. It touch the history rather than behavior improvement.
Quoted 130 lines · Matthias Kaehlcke
devfreq has two functions with very similar names,
devfreq_update_status()anddevfreq_update_stats()._update_status()currently updates frequency transitions statistics, while_update_stats()retrieves the device 'status'. The function names are inversed with respect to what the functions are actually doing, renamedevfreq_update_status()todevfreq_update_stats()and viceversa.Signed-off-by Matthias Kaehlcke <[email protected]>---
We could also rename the currentdevfreq_update_stats()todevfreq_refresh_status()to make it easier to distinguish it fromdevfreq_update_stats().--- drivers/devfreq/devfreq.c | 12 ++++++------ drivers/devfreq/governor.h | 4 ++-- drivers/devfreq/governor_passive.c | 2 +- drivers/devfreq/governor_simpleondemand.c | 2 +- drivers/devfreq/tegra30-devfreq.c | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-)drivers/devfreq/devfreq.c +6
-6@@ -151,11 +151,11 @@ static int set_freq_table(struct devfreq *devfreq) }/** -* devfreq_update_status() - Update statistics of devfreq behavior +* devfreq_update_stats() - Update statistics of devfreq behavior * @devfreq: the devfreq instance * @freq: the update target frequency */ -int devfreq_update_status (struct devfreq *devfreq,unsigned long freq) +int devfreq_update_stats (struct devfreq *devfreq,unsigned long freq) {int lev, prev_lev, ret =0 ;unsigned long cur_time;@@ -191,7 +191,7 @@ int devfreq_update_status(struct devfreq *devfreq, unsigned long freq) devfreq->last_stat_updated = cur_time;return ret; } -EXPORT_SYMBOL (devfreq_update_status); +EXPORT_SYMBOL (devfreq_update_stats);/** * find_devfreq_governor() - find devfreq governor from name @@ -311,7 +311,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq, freqs.new = new_freq;devfreq_notify_transition (devfreq, &freqs,DEVFREQ_POSTCHANGE ); -if (devfreq_update_status (devfreq, new_freq)) +if (devfreq_update_stats (devfreq, new_freq))dev_err (&devfreq->dev,"Couldn't update frequency transition information.\n" );@@ -450,7 +450,7 @@ void devfreq_monitor_suspend(struct devfreq *devfreq)return ; } -devfreq_update_status (devfreq, devfreq->previous_freq); +devfreq_update_stats (devfreq, devfreq->previous_freq); devfreq->stop_polling = true;mutex_unlock (&devfreq->lock);cancel_delayed_work_sync (&devfreq->work);@@ -1398,7 +1398,7 @@ static ssize_t trans_stat_show(struct device *dev,unsigned int max_state = devfreq->profile->max_state;if (!devfreq->stop_polling && -devfreq_update_status (devfreq, devfreq->previous_freq)) +devfreq_update_stats (devfreq, devfreq->previous_freq))return 0 ;if (max_state ==0 )return sprintf (buf,"Not Supported.\n" );drivers/devfreq/governor.h +2
-2@@ -64,9 +64,9 @@ extern void devfreq_interval_update(struct devfreq *devfreq,extern int devfreq_add_governor (struct devfreq_governor *governor);extern int devfreq_remove_governor (struct devfreq_governor *governor); -extern int devfreq_update_status (struct devfreq *devfreq,unsigned long freq); +extern int devfreq_update_stats (struct devfreq *devfreq,unsigned long freq); -static inline int devfreq_update_stats (struct devfreq *df) +static inline int devfreq_update_status (struct devfreq *df) {return df->profile->get_dev_status (df->dev.parent, &df->last_status); }drivers/devfreq/governor_passive.c +1
-1@@ -110,7 +110,7 @@ static int update_devfreq_passive(struct devfreq *devfreq, unsigned long freq) goto out;if (devfreq->profile->freq_table - && (devfreq_update_status (devfreq, freq))) + && (devfreq_update_stats (devfreq, freq)))dev_err (&devfreq->dev,"Couldn't update frequency transition information.\n" );drivers/devfreq/governor_simpleondemand.c +1
-1@@ -25,7 +25,7 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,unsigned int dfso_downdifferential =DFSO_DOWNDIFFERENCTIAL ;struct devfreq_simple_ondemand_data *data = df->data; - err =devfreq_update_stats (df); + err =devfreq_update_status (df);if (err)return err;drivers/devfreq/tegra30-devfreq.c +1
-1@@ -526,7 +526,7 @@ static int tegra_governor_get_target(struct devfreq *devfreq,unsigned int i;int err; - err =devfreq_update_stats (devfreq); + err =devfreq_update_status (devfreq);if (err)return err;
Signature · 3 lines
Best Regards, Chanwoo Choi Samsung Electronics
Quoted 4 lines · Chanwoo Choi
Hi,
I'm not sure that it is necessary. I think that it depends on personal opinions.
I disagree that this is about personal opinions. A function name should give clues about what a function is doing and not be misleading. Once these criteria are met personal opinions can come into play.
devfreq_update_status() updates statistics, not any status, hence the name neither indicates what the function is doing, and it is misleading, especially since there is another function dealing with the 'status'.
devfreq_update_stats() updates the 'status' of the device, not any statistics/stats, as in the other case, the name doesn't indicate that and is misleading.
If you still don't agree that the names are poor, could you please make an argument about why the current function names are good/ok, besides "that's how it's currently done"?
Quoted 1 line
There are no correct answer perfectly.
I agree that there is no one answer, but the current naming is clearly poor, and we should aim to improve it. Whether that involves swapping the function names or come up with new ones is a different question.
Quoted 2 lines
Also, after this changes, there are no any beneficial. It touch the history rather than behavior improvement.
You are focussing exclusively on functional improvements, and you are right that this patch doesn't change anything in functional terms.
However I disagree that there are no benefits. Naming is important, ideally code should be self explanatory, which requires using proper function and variable names, misleading names are particularly bad. Keeping poor names for the sake of history sounds like a bad idea, please avoid getting attached to them. Fortunately internal kernel APIs can be changed, and the ones in question aren't widely used.
Quoted 137 lines · Matthias Kaehlcke
Quoted 130 lines
devfreq has two functions with very similar names,
devfreq_update_status()anddevfreq_update_stats()._update_status()currently updates frequency transitions statistics, while_update_stats()retrieves the device 'status'. The function names are inversed with respect to what the functions are actually doing, renamedevfreq_update_status()todevfreq_update_stats()and viceversa.Signed-off-by Matthias Kaehlcke <[email protected]>---
We could also rename the currentdevfreq_update_stats()todevfreq_refresh_status()to make it easier to distinguish it fromdevfreq_update_stats().--- drivers/devfreq/devfreq.c | 12 ++++++------ drivers/devfreq/governor.h | 4 ++-- drivers/devfreq/governor_passive.c | 2 +- drivers/devfreq/governor_simpleondemand.c | 2 +- drivers/devfreq/tegra30-devfreq.c | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-)drivers/devfreq/devfreq.c +6
-6@@ -151,11 +151,11 @@ static int set_freq_table(struct devfreq *devfreq) }/** -* devfreq_update_status() - Update statistics of devfreq behavior +* devfreq_update_stats() - Update statistics of devfreq behavior * @devfreq: the devfreq instance * @freq: the update target frequency */ -int devfreq_update_status (struct devfreq *devfreq,unsigned long freq) +int devfreq_update_stats (struct devfreq *devfreq,unsigned long freq) {int lev, prev_lev, ret =0 ;unsigned long cur_time;@@ -191,7 +191,7 @@ int devfreq_update_status(struct devfreq *devfreq, unsigned long freq) devfreq->last_stat_updated = cur_time;return ret; } -EXPORT_SYMBOL (devfreq_update_status); +EXPORT_SYMBOL (devfreq_update_stats);/** * find_devfreq_governor() - find devfreq governor from name @@ -311,7 +311,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq, freqs.new = new_freq;devfreq_notify_transition (devfreq, &freqs,DEVFREQ_POSTCHANGE ); -if (devfreq_update_status (devfreq, new_freq)) +if (devfreq_update_stats (devfreq, new_freq))dev_err (&devfreq->dev,"Couldn't update frequency transition information.\n" );@@ -450,7 +450,7 @@ void devfreq_monitor_suspend(struct devfreq *devfreq)return ; } -devfreq_update_status (devfreq, devfreq->previous_freq); +devfreq_update_stats (devfreq, devfreq->previous_freq); devfreq->stop_polling = true;mutex_unlock (&devfreq->lock);cancel_delayed_work_sync (&devfreq->work);@@ -1398,7 +1398,7 @@ static ssize_t trans_stat_show(struct device *dev,unsigned int max_state = devfreq->profile->max_state;if (!devfreq->stop_polling && -devfreq_update_status (devfreq, devfreq->previous_freq)) +devfreq_update_stats (devfreq, devfreq->previous_freq))return 0 ;if (max_state ==0 )return sprintf (buf,"Not Supported.\n" );drivers/devfreq/governor.h +2
-2@@ -64,9 +64,9 @@ extern void devfreq_interval_update(struct devfreq *devfreq,extern int devfreq_add_governor (struct devfreq_governor *governor);extern int devfreq_remove_governor (struct devfreq_governor *governor); -extern int devfreq_update_status (struct devfreq *devfreq,unsigned long freq); +extern int devfreq_update_stats (struct devfreq *devfreq,unsigned long freq); -static inline int devfreq_update_stats (struct devfreq *df) +static inline int devfreq_update_status (struct devfreq *df) {return df->profile->get_dev_status (df->dev.parent, &df->last_status); }drivers/devfreq/governor_passive.c +1
-1@@ -110,7 +110,7 @@ static int update_devfreq_passive(struct devfreq *devfreq, unsigned long freq) goto out;if (devfreq->profile->freq_table - && (devfreq_update_status (devfreq, freq))) + && (devfreq_update_stats (devfreq, freq)))dev_err (&devfreq->dev,"Couldn't update frequency transition information.\n" );drivers/devfreq/governor_simpleondemand.c +1
-1@@ -25,7 +25,7 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,unsigned int dfso_downdifferential =DFSO_DOWNDIFFERENCTIAL ;struct devfreq_simple_ondemand_data *data = df->data; - err =devfreq_update_stats (df); + err =devfreq_update_status (df);if (err)return err;drivers/devfreq/tegra30-devfreq.c +1
-1@@ -526,7 +526,7 @@ static int tegra_governor_get_target(struct devfreq *devfreq,unsigned int i;int err; - err =devfreq_update_stats (devfreq); + err =devfreq_update_status (devfreq);if (err)return err;Signature · 3 lines
Best Regards, Chanwoo Choi Samsung Electronics
/
Quoted 6 lines · Matthias Kaehlcke
devfreq has two functions with very similar names,
devfreq_update_status()anddevfreq_update_stats()._update_status()currently updates frequency transitions statistics, while_update_stats()retrieves the device 'status'. The function names are inversed with respect to what the functions are actually doing, renamedevfreq_update_status()todevfreq_update_stats()and viceversa.
Wouldn't having devfreq_get_stats() be a better name for this if it is retrieving the stats?
Quoted 136 lines
Signed-off-by Matthias Kaehlcke <[email protected]>---
We could also rename the currentdevfreq_update_stats()todevfreq_refresh_status()to make it easier to distinguish it fromdevfreq_update_stats().--- drivers/devfreq/devfreq.c | 12 ++++++------ drivers/devfreq/governor.h | 4 ++-- drivers/devfreq/governor_passive.c | 2 +- drivers/devfreq/governor_simpleondemand.c | 2 +- drivers/devfreq/tegra30-devfreq.c | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-)drivers/devfreq/devfreq.c +2
-2@@ -151,11 +151,11 @@ static int set_freq_table(struct devfreq *devfreq) }/** -* devfreq_update_status() - Update statistics of devfreq behavior +* devfreq_update_stats() - Update statistics of devfreq behavior * @devfreq: the devfreq instance * @freq: the update target frequency */ -int devfreq_update_status (struct devfreq *devfreq,unsigned long freq) +int devfreq_update_stats (struct devfreq *devfreq,unsigned long freq) {int lev, prev_lev, ret =0 ;drivers/devfreq/devfreq.c +1
-1unsigned long cur_time;@@ -191,7 +191,7 @@ int devfreq_update_status(struct devfreq *devfreq, unsigned long freq) devfreq->last_stat_updated = cur_time;return ret; } -EXPORT_SYMBOL (devfreq_update_status); +EXPORT_SYMBOL (devfreq_update_stats);/** *
find_devfreq_governor()- find devfreq governor from namedrivers/devfreq/devfreq.c +2
-2@@ -311,7 +311,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq, freqs.new = new_freq;devfreq_notify_transition (devfreq, &freqs,DEVFREQ_POSTCHANGE ); -if (devfreq_update_status (devfreq, new_freq)) +if (devfreq_update_stats (devfreq, new_freq))dev_err (&devfreq->dev,"Couldn't update frequency transition information.\n" );@@ -450,7 +450,7 @@ void devfreq_monitor_suspend(struct devfreq *devfreq)return ; } -devfreq_update_status (devfreq, devfreq->previous_freq); +devfreq_update_stats (devfreq, devfreq->previous_freq); devfreq->stop_polling = true;mutex_unlock (&devfreq->lock);drivers/devfreq/devfreq.c +1
-1cancel_delayed_work_sync (&devfreq->work);@@ -1398,7 +1398,7 @@ static ssize_t trans_stat_show(struct device *dev, unsigned int max_state = devfreq->profile->max_state;if (!devfreq->stop_polling && -devfreq_update_status (devfreq, devfreq->previous_freq)) +devfreq_update_stats (devfreq, devfreq->previous_freq))return 0 ;if (max_state ==0 )drivers/devfreq/devfreq.c +0
-0return sprintf (buf,"Not Supported.\n" );drivers/devfreq/governor.h +2
-2@@ -64,9 +64,9 @@ extern void devfreq_interval_update(struct devfreq *devfreq, extern int devfreq_add_governor(struct devfreq_governor *governor);extern int devfreq_remove_governor (struct devfreq_governor *governor); -extern int devfreq_update_status (struct devfreq *devfreq,unsigned long freq); +extern int devfreq_update_stats (struct devfreq *devfreq,unsigned long freq); -static inline int devfreq_update_stats (struct devfreq *df) +static inline int devfreq_update_status (struct devfreq *df){
drivers/devfreq/governor.h +0
-0return df->profile->get_dev_status (df->dev.parent, &df->last_status); }drivers/devfreq/governor_passive.c +1
-1@@ -110,7 +110,7 @@ static int update_devfreq_passive(struct devfreq *devfreq, unsigned long freq) goto out;if (devfreq->profile->freq_table - && (devfreq_update_status (devfreq, freq))) + && (devfreq_update_stats (devfreq, freq)))dev_err (&devfreq->dev,"Couldn't update frequency transition information.\n" );drivers/devfreq/governor_simpleondemand.c +1
-1@@ -25,7 +25,7 @@ static int devfreq_simple_ondemand_func(structdevfreq *df, unsigned int dfso_downdifferential = DFSO_DOWNDIFFERENCTIAL;struct devfreq_simple_ondemand_data *data = df->data; - err =devfreq_update_stats (df); + err =devfreq_update_status (df);if (err)return err;drivers/devfreq/tegra30-devfreq.c +1
-1@@ -526,7 +526,7 @@ static int tegra_governor_get_target(structdevfreq *devfreq, unsigned int i;int err; - err =devfreq_update_stats (devfreq); + err =devfreq_update_status (devfreq);if (err)return err;
Quoted 11 lines · Ben Dooks
/
Quoted 7 lines · Matthias Kaehlcke
devfreq has two functions with very similar names,
devfreq_update_status()
anddevfreq_update_stats()._update_status()currently updates frequency transitions statistics, while_update_stats()retrieves the device 'status'. The function names are inversed with respect to what the functions are actually doing, renamedevfreq_update_status()todevfreq_update_stats()and viceversa.
Quoted 2 lines
Wouldn't having
devfreq_get_stats()be a better name for this if it is retrieving the stats?
struct devfreq_dev_status is a bit ambiguous. It contains 'stat' fields like 'total_time' and 'busy_time', but also 'current_frequency' which is more a 'status'. Given the name of the struct and the name of the hook profile->get_dev_status I'm inclined to refer to it as 'status', also to disambiguate it from the transition stats.
That said I'd welcome a name that's easier to differantiate from the other devfreq_update_stat* function, like devfreq_update_status() or devfreq_refresh_status().
Quoted 133 lines
Quoted 133 lines
Signed-off-by Matthias Kaehlcke <[email protected]>---
We could also rename the currentdevfreq_update_stats()todevfreq_refresh_status()to make it easier to distinguish it fromdevfreq_update_stats().--- drivers/devfreq/devfreq.c | 12 ++++++------ drivers/devfreq/governor.h | 4 ++-- drivers/devfreq/governor_passive.c | 2 +- drivers/devfreq/governor_simpleondemand.c | 2 +- drivers/devfreq/tegra30-devfreq.c | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-)drivers/devfreq/devfreq.c +3
-3@@ -151,11 +151,11 @@ static int set_freq_table(struct devfreq *devfreq) }/** -* devfreq_update_status() - Update statistics of devfreq behavior +* devfreq_update_stats() - Update statistics of devfreq behavior * @devfreq: the devfreq instance * @freq: the update target frequency */ -int devfreq_update_status (struct devfreq *devfreq,unsigned long freq) +int devfreq_update_stats (struct devfreq *devfreq,unsigned long freq) {int lev, prev_lev, ret =0 ;unsigned long cur_time;@@ -191,7 +191,7 @@ int devfreq_update_status(struct devfreq *devfreq, unsigned long freq) devfreq->last_stat_updated = cur_time;return ret; } -EXPORT_SYMBOL (devfreq_update_status); +EXPORT_SYMBOL (devfreq_update_stats);/** *
find_devfreq_governor()- find devfreq governor from namedrivers/devfreq/devfreq.c +2
-2@@ -311,7 +311,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq, freqs.new = new_freq;devfreq_notify_transition (devfreq, &freqs,DEVFREQ_POSTCHANGE ); -if (devfreq_update_status (devfreq, new_freq)) +if (devfreq_update_stats (devfreq, new_freq))dev_err (&devfreq->dev,"Couldn't update frequency transition information.\n" );@@ -450,7 +450,7 @@ void devfreq_monitor_suspend(struct devfreq *devfreq)return ; } -devfreq_update_status (devfreq, devfreq->previous_freq); +devfreq_update_stats (devfreq, devfreq->previous_freq); devfreq->stop_polling = true;mutex_unlock (&devfreq->lock);drivers/devfreq/devfreq.c +1
-1cancel_delayed_work_sync (&devfreq->work);@@ -1398,7 +1398,7 @@ static ssize_t trans_stat_show(struct device *dev,unsigned int max_state = devfreq->profile->max_state;if (!devfreq->stop_polling && -devfreq_update_status (devfreq, devfreq->previous_freq)) +devfreq_update_stats (devfreq, devfreq->previous_freq))return 0 ;if (max_state ==0 )return sprintf (buf,"Not Supported.\n" );drivers/devfreq/governor.h +2
-2@@ -64,9 +64,9 @@ extern void devfreq_interval_update(struct devfreq *devfreq, extern int devfreq_add_governor(struct devfreq_governor *governor);extern int devfreq_remove_governor (struct devfreq_governor *governor); -extern int devfreq_update_status (struct devfreq *devfreq,unsigned long freq); +extern int devfreq_update_stats (struct devfreq *devfreq,unsigned long freq); -static inline int devfreq_update_stats (struct devfreq *df) +static inline int devfreq_update_status (struct devfreq *df){
drivers/devfreq/governor.h +0
-0return df->profile->get_dev_status (df->dev.parent, &df->last_status); }drivers/devfreq/governor_passive.c +1
-1@@ -110,7 +110,7 @@ static int update_devfreq_passive(struct devfreq *devfreq, unsigned long freq) goto out;if (devfreq->profile->freq_table - && (devfreq_update_status (devfreq, freq))) + && (devfreq_update_stats (devfreq, freq)))dev_err (&devfreq->dev,"Couldn't update frequency transition information.\n" );drivers/devfreq/governor_simpleondemand.c +1
-1@@ -25,7 +25,7 @@ static int devfreq_simple_ondemand_func(struct devfreq *df, unsigned int dfso_downdifferential = DFSO_DOWNDIFFERENCTIAL;struct devfreq_simple_ondemand_data *data = df->data; - err =devfreq_update_stats (df); + err =devfreq_update_status (df);if (err)return err;drivers/devfreq/tegra30-devfreq.c +1
-1@@ -526,7 +526,7 @@ static int tegra_governor_get_target(structdevfreq *devfreq, unsigned int i;int err; - err =devfreq_update_stats (devfreq); + err =devfreq_update_status (devfreq);if (err)return err;
Quoted 15 lines · Matthias Kaehlcke
Quoted 11 lines · Ben Dooks
/
Quoted 7 lines · Matthias Kaehlcke
devfreq has two functions with very similar names,
devfreq_update_status()
anddevfreq_update_stats()._update_status()currently updates frequency transitions statistics, while_update_stats()retrieves the device 'status'. The function names are inversed with respect to what the functions are actually doing, renamedevfreq_update_status()todevfreq_update_stats()and viceversa.Quoted 2 lines
Wouldn't having
devfreq_get_stats()be a better name for this if it is retrieving the stats?
Quoted 8 lines
struct
devfreq_dev_statusis a bit ambiguous. It contains 'stat' fields like 'total_time' and 'busy_time', but also 'current_frequency' which is more a 'status'. Given the name of the struct and the name of the hookprofile->get_dev_statusI'm inclined to refer to it as 'status', also to disambiguate it from the transition stats.That said I'd welcome a name that's easier to differantiate from the other devfreq_update_stat* function, like
devfreq_update_status()or
~~~~~~~~~~~~~~~~~~~~~~~
I meant devfreq_get_status()
Quoted 135 lines
devfreq_refresh_status().Quoted 133 lines
Quoted 133 lines
Signed-off-by Matthias Kaehlcke <[email protected]>---
We could also rename the currentdevfreq_update_stats()todevfreq_refresh_status()to make it easier to distinguish it fromdevfreq_update_stats().--- drivers/devfreq/devfreq.c | 12 ++++++------ drivers/devfreq/governor.h | 4 ++-- drivers/devfreq/governor_passive.c | 2 +- drivers/devfreq/governor_simpleondemand.c | 2 +- drivers/devfreq/tegra30-devfreq.c | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-)drivers/devfreq/devfreq.c +3
-3@@ -151,11 +151,11 @@ static int set_freq_table(struct devfreq *devfreq) }/** -* devfreq_update_status() - Update statistics of devfreq behavior +* devfreq_update_stats() - Update statistics of devfreq behavior * @devfreq: the devfreq instance * @freq: the update target frequency */ -int devfreq_update_status (struct devfreq *devfreq,unsigned long freq) +int devfreq_update_stats (struct devfreq *devfreq,unsigned long freq) {int lev, prev_lev, ret =0 ;unsigned long cur_time;@@ -191,7 +191,7 @@ int devfreq_update_status(struct devfreq *devfreq, unsigned long freq) devfreq->last_stat_updated = cur_time;return ret; } -EXPORT_SYMBOL (devfreq_update_status); +EXPORT_SYMBOL (devfreq_update_stats);/** *
find_devfreq_governor()- find devfreq governor from namedrivers/devfreq/devfreq.c +2
-2@@ -311,7 +311,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq, freqs.new = new_freq;devfreq_notify_transition (devfreq, &freqs,DEVFREQ_POSTCHANGE ); -if (devfreq_update_status (devfreq, new_freq)) +if (devfreq_update_stats (devfreq, new_freq))dev_err (&devfreq->dev,"Couldn't update frequency transition information.\n" );@@ -450,7 +450,7 @@ void devfreq_monitor_suspend(struct devfreq *devfreq)return ; } -devfreq_update_status (devfreq, devfreq->previous_freq); +devfreq_update_stats (devfreq, devfreq->previous_freq); devfreq->stop_polling = true;mutex_unlock (&devfreq->lock);drivers/devfreq/devfreq.c +1
-1cancel_delayed_work_sync (&devfreq->work);@@ -1398,7 +1398,7 @@ static ssize_t trans_stat_show(struct device *dev,unsigned int max_state = devfreq->profile->max_state;if (!devfreq->stop_polling && -devfreq_update_status (devfreq, devfreq->previous_freq)) +devfreq_update_stats (devfreq, devfreq->previous_freq))return 0 ;if (max_state ==0 )return sprintf (buf,"Not Supported.\n" );drivers/devfreq/governor.h +2
-2@@ -64,9 +64,9 @@ extern void devfreq_interval_update(struct devfreq *devfreq, extern int devfreq_add_governor(struct devfreq_governor *governor);extern int devfreq_remove_governor (struct devfreq_governor *governor); -extern int devfreq_update_status (struct devfreq *devfreq,unsigned long freq); +extern int devfreq_update_stats (struct devfreq *devfreq,unsigned long freq); -static inline int devfreq_update_stats (struct devfreq *df) +static inline int devfreq_update_status (struct devfreq *df){
drivers/devfreq/governor.h +0
-0return df->profile->get_dev_status (df->dev.parent, &df->last_status); }drivers/devfreq/governor_passive.c +1
-1@@ -110,7 +110,7 @@ static int update_devfreq_passive(struct devfreq *devfreq, unsigned long freq) goto out;if (devfreq->profile->freq_table - && (devfreq_update_status (devfreq, freq))) + && (devfreq_update_stats (devfreq, freq)))dev_err (&devfreq->dev,"Couldn't update frequency transition information.\n" );drivers/devfreq/governor_simpleondemand.c +1
-1@@ -25,7 +25,7 @@ static int devfreq_simple_ondemand_func(struct devfreq *df, unsigned int dfso_downdifferential = DFSO_DOWNDIFFERENCTIAL;struct devfreq_simple_ondemand_data *data = df->data; - err =devfreq_update_stats (df); + err =devfreq_update_status (df);if (err)return err;drivers/devfreq/tegra30-devfreq.c +1
-1@@ -526,7 +526,7 @@ static int tegra_governor_get_target(structdevfreq *devfreq, unsigned int i;int err; - err =devfreq_update_stats (devfreq); + err =devfreq_update_status (devfreq);if (err)return err;