Commit 552fce98 authored by Rob Clark's avatar Rob Clark

drm/msm: Split out get_freq() helper

In the next patch, it grows a bit more, so lets not duplicate the logic
in multiple places.
Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20210726144653.2180096-3-robdclark@gmail.comSigned-off-by: default avatarRob Clark <robdclark@chromium.org>
parent af5b4fff
...@@ -37,17 +37,21 @@ static int msm_devfreq_target(struct device *dev, unsigned long *freq, ...@@ -37,17 +37,21 @@ static int msm_devfreq_target(struct device *dev, unsigned long *freq,
return 0; return 0;
} }
static unsigned long get_freq(struct msm_gpu *gpu)
{
if (gpu->funcs->gpu_get_freq)
return gpu->funcs->gpu_get_freq(gpu);
return clk_get_rate(gpu->core_clk);
}
static int msm_devfreq_get_dev_status(struct device *dev, static int msm_devfreq_get_dev_status(struct device *dev,
struct devfreq_dev_status *status) struct devfreq_dev_status *status)
{ {
struct msm_gpu *gpu = dev_to_gpu(dev); struct msm_gpu *gpu = dev_to_gpu(dev);
ktime_t time; ktime_t time;
if (gpu->funcs->gpu_get_freq) status->current_frequency = get_freq(gpu);
status->current_frequency = gpu->funcs->gpu_get_freq(gpu);
else
status->current_frequency = clk_get_rate(gpu->core_clk);
status->busy_time = gpu->funcs->gpu_busy(gpu); status->busy_time = gpu->funcs->gpu_busy(gpu);
time = ktime_get(); time = ktime_get();
...@@ -59,12 +63,7 @@ static int msm_devfreq_get_dev_status(struct device *dev, ...@@ -59,12 +63,7 @@ static int msm_devfreq_get_dev_status(struct device *dev,
static int msm_devfreq_get_cur_freq(struct device *dev, unsigned long *freq) static int msm_devfreq_get_cur_freq(struct device *dev, unsigned long *freq)
{ {
struct msm_gpu *gpu = dev_to_gpu(dev); *freq = get_freq(dev_to_gpu(dev));
if (gpu->funcs->gpu_get_freq)
*freq = gpu->funcs->gpu_get_freq(gpu);
else
*freq = clk_get_rate(gpu->core_clk);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment