[1/2] devfreq: Rename devfreq_update_status() to devfreq_update_stats() and viceversa
diff mbox series

Message ID 20190925184314.30251-1-mka@chromium.org
State New
Headers show
Series
  • [1/2] devfreq: Rename devfreq_update_status() to devfreq_update_stats() and viceversa
Related show

Commit Message

Matthias Kaehlcke Sept. 25, 2019, 6:43 p.m. UTC
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.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
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(-)

Comments

Chanwoo Choi Sept. 26, 2019, 1:36 a.m. UTC | #1
Hi,

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.

On 19. 9. 26. 오전 3:43, Matthias Kaehlcke wrote:
> 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.
> 
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
> 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(-)
> 
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 446490c9d635..fb4318d59aa9 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -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");
> diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
> index bbe5ff9fcecf..e11f447be2b5 100644
> --- a/drivers/devfreq/governor.h
> +++ b/drivers/devfreq/governor.h
> @@ -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);
>  }
> diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c
> index be6eeab9c814..1c746b96d3db 100644
> --- a/drivers/devfreq/governor_passive.c
> +++ b/drivers/devfreq/governor_passive.c
> @@ -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");
>  
> diff --git a/drivers/devfreq/governor_simpleondemand.c b/drivers/devfreq/governor_simpleondemand.c
> index 3d809f228619..2cbf26bdcfd6 100644
> --- a/drivers/devfreq/governor_simpleondemand.c
> +++ b/drivers/devfreq/governor_simpleondemand.c
> @@ -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;
>  
> diff --git a/drivers/devfreq/tegra30-devfreq.c b/drivers/devfreq/tegra30-devfreq.c
> index a6ba75f4106d..536273a811fe 100644
> --- a/drivers/devfreq/tegra30-devfreq.c
> +++ b/drivers/devfreq/tegra30-devfreq.c
> @@ -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;
>  
>
Ben Dooks Sept. 26, 2019, 7:21 a.m. UTC | #2
/

On 2019-09-25 19:43, Matthias Kaehlcke wrote:
> 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.

Wouldn't having devfreq_get_stats() be a better name for this if it
is retrieving the stats?

> 
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
> 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(-)
> 
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 446490c9d635..fb4318d59aa9 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -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");
> diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
> index bbe5ff9fcecf..e11f447be2b5 100644
> --- a/drivers/devfreq/governor.h
> +++ b/drivers/devfreq/governor.h
> @@ -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);
>  }
> diff --git a/drivers/devfreq/governor_passive.c
> b/drivers/devfreq/governor_passive.c
> index be6eeab9c814..1c746b96d3db 100644
> --- a/drivers/devfreq/governor_passive.c
> +++ b/drivers/devfreq/governor_passive.c
> @@ -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");
> 
> diff --git a/drivers/devfreq/governor_simpleondemand.c
> b/drivers/devfreq/governor_simpleondemand.c
> index 3d809f228619..2cbf26bdcfd6 100644
> --- a/drivers/devfreq/governor_simpleondemand.c
> +++ b/drivers/devfreq/governor_simpleondemand.c
> @@ -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;
> 
> diff --git a/drivers/devfreq/tegra30-devfreq.c
> b/drivers/devfreq/tegra30-devfreq.c
> index a6ba75f4106d..536273a811fe 100644
> --- a/drivers/devfreq/tegra30-devfreq.c
> +++ b/drivers/devfreq/tegra30-devfreq.c
> @@ -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;
Matthias Kaehlcke Sept. 26, 2019, 4:51 p.m. UTC | #3
On Thu, Sep 26, 2019 at 10:36:04AM +0900, Chanwoo Choi wrote:
> 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"?

> 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.

> 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.

> On 19. 9. 26. 오전 3:43, Matthias Kaehlcke wrote:
> > 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.
> > 
> > Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> > ---
> > 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(-)
> > 
> > diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> > index 446490c9d635..fb4318d59aa9 100644
> > --- a/drivers/devfreq/devfreq.c
> > +++ b/drivers/devfreq/devfreq.c
> > @@ -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");
> > diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
> > index bbe5ff9fcecf..e11f447be2b5 100644
> > --- a/drivers/devfreq/governor.h
> > +++ b/drivers/devfreq/governor.h
> > @@ -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);
> >  }
> > diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c
> > index be6eeab9c814..1c746b96d3db 100644
> > --- a/drivers/devfreq/governor_passive.c
> > +++ b/drivers/devfreq/governor_passive.c
> > @@ -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");
> >  
> > diff --git a/drivers/devfreq/governor_simpleondemand.c b/drivers/devfreq/governor_simpleondemand.c
> > index 3d809f228619..2cbf26bdcfd6 100644
> > --- a/drivers/devfreq/governor_simpleondemand.c
> > +++ b/drivers/devfreq/governor_simpleondemand.c
> > @@ -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;
> >  
> > diff --git a/drivers/devfreq/tegra30-devfreq.c b/drivers/devfreq/tegra30-devfreq.c
> > index a6ba75f4106d..536273a811fe 100644
> > --- a/drivers/devfreq/tegra30-devfreq.c
> > +++ b/drivers/devfreq/tegra30-devfreq.c
> > @@ -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;
> >  
> > 
> 
> 
> -- 
> Best Regards,
> Chanwoo Choi
> Samsung Electronics
Matthias Kaehlcke Sept. 26, 2019, 5:11 p.m. UTC | #4
On Thu, Sep 26, 2019 at 08:21:51AM +0100, Ben Dooks wrote:
> /
> 
> On 2019-09-25 19:43, Matthias Kaehlcke wrote:
> > 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.
> 
> 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().

> > Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> > ---
> > 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(-)
> > 
> > diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> > index 446490c9d635..fb4318d59aa9 100644
> > --- a/drivers/devfreq/devfreq.c
> > +++ b/drivers/devfreq/devfreq.c
> > @@ -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");
> > diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
> > index bbe5ff9fcecf..e11f447be2b5 100644
> > --- a/drivers/devfreq/governor.h
> > +++ b/drivers/devfreq/governor.h
> > @@ -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);
> >  }
> > diff --git a/drivers/devfreq/governor_passive.c
> > b/drivers/devfreq/governor_passive.c
> > index be6eeab9c814..1c746b96d3db 100644
> > --- a/drivers/devfreq/governor_passive.c
> > +++ b/drivers/devfreq/governor_passive.c
> > @@ -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");
> > 
> > diff --git a/drivers/devfreq/governor_simpleondemand.c
> > b/drivers/devfreq/governor_simpleondemand.c
> > index 3d809f228619..2cbf26bdcfd6 100644
> > --- a/drivers/devfreq/governor_simpleondemand.c
> > +++ b/drivers/devfreq/governor_simpleondemand.c
> > @@ -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;
> > 
> > diff --git a/drivers/devfreq/tegra30-devfreq.c
> > b/drivers/devfreq/tegra30-devfreq.c
> > index a6ba75f4106d..536273a811fe 100644
> > --- a/drivers/devfreq/tegra30-devfreq.c
> > +++ b/drivers/devfreq/tegra30-devfreq.c
> > @@ -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;
Matthias Kaehlcke Sept. 26, 2019, 5:14 p.m. UTC | #5
On Thu, Sep 26, 2019 at 10:11:00AM -0700, Matthias Kaehlcke wrote:
> On Thu, Sep 26, 2019 at 08:21:51AM +0100, Ben Dooks wrote:
> > /
> > 
> > On 2019-09-25 19:43, Matthias Kaehlcke wrote:
> > > 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.
> > 
> > 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
                                      ~~~~~~~~~~~~~~~~~~~~~~~
I meant devfreq_get_status()

> devfreq_refresh_status().
> 
> > > Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> > > ---
> > > 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(-)
> > > 
> > > diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> > > index 446490c9d635..fb4318d59aa9 100644
> > > --- a/drivers/devfreq/devfreq.c
> > > +++ b/drivers/devfreq/devfreq.c
> > > @@ -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");
> > > diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
> > > index bbe5ff9fcecf..e11f447be2b5 100644
> > > --- a/drivers/devfreq/governor.h
> > > +++ b/drivers/devfreq/governor.h
> > > @@ -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);
> > >  }
> > > diff --git a/drivers/devfreq/governor_passive.c
> > > b/drivers/devfreq/governor_passive.c
> > > index be6eeab9c814..1c746b96d3db 100644
> > > --- a/drivers/devfreq/governor_passive.c
> > > +++ b/drivers/devfreq/governor_passive.c
> > > @@ -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");
> > > 
> > > diff --git a/drivers/devfreq/governor_simpleondemand.c
> > > b/drivers/devfreq/governor_simpleondemand.c
> > > index 3d809f228619..2cbf26bdcfd6 100644
> > > --- a/drivers/devfreq/governor_simpleondemand.c
> > > +++ b/drivers/devfreq/governor_simpleondemand.c
> > > @@ -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;
> > > 
> > > diff --git a/drivers/devfreq/tegra30-devfreq.c
> > > b/drivers/devfreq/tegra30-devfreq.c
> > > index a6ba75f4106d..536273a811fe 100644
> > > --- a/drivers/devfreq/tegra30-devfreq.c
> > > +++ b/drivers/devfreq/tegra30-devfreq.c
> > > @@ -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;

Patch
diff mbox series

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 446490c9d635..fb4318d59aa9 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -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");
diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
index bbe5ff9fcecf..e11f447be2b5 100644
--- a/drivers/devfreq/governor.h
+++ b/drivers/devfreq/governor.h
@@ -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);
 }
diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c
index be6eeab9c814..1c746b96d3db 100644
--- a/drivers/devfreq/governor_passive.c
+++ b/drivers/devfreq/governor_passive.c
@@ -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");
 
diff --git a/drivers/devfreq/governor_simpleondemand.c b/drivers/devfreq/governor_simpleondemand.c
index 3d809f228619..2cbf26bdcfd6 100644
--- a/drivers/devfreq/governor_simpleondemand.c
+++ b/drivers/devfreq/governor_simpleondemand.c
@@ -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;
 
diff --git a/drivers/devfreq/tegra30-devfreq.c b/drivers/devfreq/tegra30-devfreq.c
index a6ba75f4106d..536273a811fe 100644
--- a/drivers/devfreq/tegra30-devfreq.c
+++ b/drivers/devfreq/tegra30-devfreq.c
@@ -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;