RE: [PATCH v3 1/8] PM / devfreq: Set min/max_freq when adding the devfreq device

From: MyungJoo Ham
Date: Wed Oct 11 2017 - 07:10:04 EST


> Prior to that, the min/max_freq of the devfreq device are always zero
> before the user changes the min/max_freq through sysfs entries.
> It might make the confusion for the min/max_freq.
>
> This patch initializes the available min/max_freq by using the OPP
> during adding the devfreq device.
>
> Signed-off-by: Chanwoo Choi <cw00.choi@xxxxxxxxxxx>
> ---
> drivers/devfreq/devfreq.c | 43 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 43 insertions(+)
>
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index a1c4ee818614..ae8717a6eee1 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index a1c4ee818614..ae8717a6eee1 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -69,6 +69,34 @@ static struct devfreq *find_device_devfreq(struct device *dev)
> return ERR_PTR(-ENODEV);
> }
>
> +static unsigned long find_available_min_freq(struct devfreq *devfreq)
> +{
> + struct dev_pm_opp *opp;
> + unsigned long min_freq = 0;
> +
> + opp = dev_pm_opp_find_freq_ceil(devfreq->dev.parent, &min_freq);

When min_freq is 0, dev_pm_opp_find_freq_ceil will return ERR_PTR(-EINVAL);

--- from drivers/base/power/opp/core.c ------
struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
unsigned long *freq)
{
struct opp_table *opp_table;
struct dev_pm_opp *opp;

if (!dev || !freq) {
dev_err(dev, "%s: Invalid argument freq=%p\n", __func__, freq);
return ERR_PTR(-EINVAL);
}
---------------------------------------------

Cheers,
MyungJoo