The only device-specific part of panthor's get_dev_status devfreq callback is getting the clock frequency. All the other logic surrounding what it does may be useful for other devfreq implementations however.
Expose it in the panthor_devfreq.h header file, and make it call back into get_cur_freq instead of poking the common clock framework directly. Signed-off-by: Nicolas Frattaroli <nicolas.frattar...@collabora.com> --- drivers/gpu/drm/panthor/panthor_devfreq.c | 11 ++++++++--- drivers/gpu/drm/panthor/panthor_devfreq.h | 3 +++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/panthor/panthor_devfreq.c b/drivers/gpu/drm/panthor/panthor_devfreq.c index 02eb3ca15d1874e1cbafc6b614b196c5cc75b6a1..34b621b155f1324ba4f0a07c981da669d945a545 100644 --- a/drivers/gpu/drm/panthor/panthor_devfreq.c +++ b/drivers/gpu/drm/panthor/panthor_devfreq.c @@ -50,14 +50,18 @@ static void panthor_devfreq_reset(struct panthor_devfreq *pdevfreq) pdevfreq->time_last_update = ktime_get(); } -static int panthor_devfreq_get_dev_status(struct device *dev, - struct devfreq_dev_status *status) +int panthor_devfreq_get_dev_status(struct device *dev, + struct devfreq_dev_status *status) { struct panthor_device *ptdev = dev_get_drvdata(dev); struct panthor_devfreq *pdevfreq = ptdev->devfreq; + struct devfreq_dev_profile *p = pdevfreq->devfreq->profile; unsigned long irqflags; + int ret; - status->current_frequency = clk_get_rate(ptdev->clks.core); + ret = p->get_cur_freq(dev, &status->current_frequency); + if (ret) + return ret; spin_lock_irqsave(&pdevfreq->lock, irqflags); @@ -79,6 +83,7 @@ static int panthor_devfreq_get_dev_status(struct device *dev, return 0; } +EXPORT_SYMBOL(panthor_devfreq_get_dev_status); static int panthor_devfreq_get_cur_freq(struct device *dev, unsigned long *freq) { diff --git a/drivers/gpu/drm/panthor/panthor_devfreq.h b/drivers/gpu/drm/panthor/panthor_devfreq.h index e8b5ccddd45c52ee3215e9c84c6ebd9109640282..a891cb5fdc34636444f141e10f5d45828fc35b51 100644 --- a/drivers/gpu/drm/panthor/panthor_devfreq.h +++ b/drivers/gpu/drm/panthor/panthor_devfreq.h @@ -52,6 +52,9 @@ void panthor_devfreq_suspend(struct panthor_device *ptdev); void panthor_devfreq_record_busy(struct panthor_device *ptdev); void panthor_devfreq_record_idle(struct panthor_device *ptdev); +int panthor_devfreq_get_dev_status(struct device *dev, + struct devfreq_dev_status *status); + unsigned long panthor_devfreq_get_freq(struct panthor_device *ptdev); #endif /* __PANTHOR_DEVFREQ_H__ */ -- 2.51.0