cpufreq: Add defensive check during driver registration
authorZihuan Zhang <zhangzihuan@kylinos.cn>
Mon, 8 Sep 2025 08:57:38 +0000 (16:57 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 19 Sep 2025 21:11:44 +0000 (23:11 +0200)
commit7c0dde86c17665cb27e1c8dd23d263e2ed2d5b50
tree0fd73538093ebc07004da73ff6b0fb8d07cde5b8
parent46c435cbaf5591a349c339e080ac2a228aa99649
cpufreq: Add defensive check during driver registration

Currently, cpufreq allows drivers to implement both ->target() and
->target_index() callbacks, but that can lead to ambiguous or incorrect
behavior.

For this reason, prevent cpufreq drivers implementing both ->target()
and ->target_index() at the same time from registering.

This check can help to catch driver implementation mistakes early and
improve overall robustness, without affecting existing valid drivers.

Signed-off-by: Zihuan Zhang <zhangzihuan@kylinos.cn>
Link: https://patch.msgid.link/20250908085738.31602-1-zhangzihuan@kylinos.cn
[ rjw: Subject adjustment and changelog rewrite ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq.c