Skip to content

Commit 5487f25

Browse files
Lifeng Zhengchanwoochoi
authored andcommitted
PM / devfreq: Limit max_freq with scaling_min_freq
Limit max_freq in devfreq_get_freq_range() with scaling_min_freq to avoid showing an unreachable freq when reading it. Use macro clamp to simplify code. Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com> Link: https://lore.kernel.org/lkml/20250421030020.3108405-3-zhenglifeng1@huawei.com/ Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
1 parent 914cc79 commit 5487f25

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

drivers/devfreq/devfreq.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,8 @@ void devfreq_get_freq_range(struct devfreq *devfreq,
152152
(unsigned long)HZ_PER_KHZ * qos_max_freq);
153153

154154
/* Apply constraints from OPP interface */
155-
*min_freq = max(*min_freq, devfreq->scaling_min_freq);
156-
*max_freq = min(*max_freq, devfreq->scaling_max_freq);
157-
158-
if (*min_freq > *max_freq)
159-
*min_freq = *max_freq;
155+
*max_freq = clamp(*max_freq, devfreq->scaling_min_freq, devfreq->scaling_max_freq);
156+
*min_freq = clamp(*min_freq, devfreq->scaling_min_freq, *max_freq);
160157
}
161158
EXPORT_SYMBOL(devfreq_get_freq_range);
162159

0 commit comments

Comments
 (0)