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>
This commit is contained in:
Lifeng Zheng 2025-04-21 11:00:18 +08:00 committed by Chanwoo Choi
parent 914cc799b2
commit 5487f2595b
1 changed files with 2 additions and 5 deletions

View File

@ -152,11 +152,8 @@ void devfreq_get_freq_range(struct devfreq *devfreq,
(unsigned long)HZ_PER_KHZ * qos_max_freq);
/* Apply constraints from OPP interface */
*min_freq = max(*min_freq, devfreq->scaling_min_freq);
*max_freq = min(*max_freq, devfreq->scaling_max_freq);
if (*min_freq > *max_freq)
*min_freq = *max_freq;
*max_freq = clamp(*max_freq, devfreq->scaling_min_freq, devfreq->scaling_max_freq);
*min_freq = clamp(*min_freq, devfreq->scaling_min_freq, *max_freq);
}
EXPORT_SYMBOL(devfreq_get_freq_range);