From 0192aaa6cd9377b91b8022acf33a45fbd9adc3f0 Mon Sep 17 00:00:00 2001 From: Shreyas K K Date: Fri, 26 Nov 2021 00:35:03 +0530 Subject: [PATCH] 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 --- 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 b48f465ea19b..81709add4b0e 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -318,7 +318,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 = new_freq; return err; @@ -912,7 +912,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);