From 89bd841849c291a3419b8e9776d7893340b3ec0f Mon Sep 17 00:00:00 2001 From: Shreyas K K Date: Fri, 26 Nov 2021 00:35:03 +0530 Subject: [PATCH] BACKPORT: devfreq: Fix suspend callback for non-zero min_freq With commit commit 921884ca1498 ("devfreq: Fix PM callbacks to support zero frequency"), suspend_freq of zero is considered valid. However, the devfreq_set_target is called with zero frequency. To avoid this, do not call devfreq_set_target if the suspend_freq is less than the minimun allowed frequency. Change-Id: I506165d28395eb67138ae2dac53e842357809bbb Signed-off-by: Shreyas K K Signed-off-by: UtsavBalar1231 --- drivers/devfreq/devfreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 1e653026280f..31e4b42bda8b 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -321,7 +321,7 @@ static int devfreq_set_target(struct devfreq *devfreq, unsigned long new_freq, devfreq->previous_freq = new_freq; - if (devfreq->suspend_freq >= 0) + if (devfreq->suspend_freq >= devfreq->scaling_min_freq) devfreq->resume_freq = cur_freq; return err; @@ -910,7 +910,7 @@ int devfreq_suspend_device(struct devfreq *devfreq) return ret; } - if (devfreq->suspend_freq >= 0) { + if (devfreq->suspend_freq >= devfreq->scaling_min_freq) { mutex_lock(&devfreq->lock); ret = devfreq_set_target(devfreq, devfreq->suspend_freq, 0); mutex_unlock(&devfreq->lock);