[PATCH v2 3/6] devfreq: Factor out devfreq_set_governor()
Jie Zhan
zhanjie9 at hisilicon.com
Fri May 15 03:32:01 PDT 2026
On 5/14/2026 2:09 PM, Yaxiong Tian wrote:
>
> 在 2026/5/13 17:38, Jie Zhan 写道:
>> Factor out common governor setting logic into devfreq_set_governor() so as
>> to consolidate the code in governor_store() and devfreq_add_device().
>>
>> The caller is expected to hold 'devfreq_list_lock', enforced via
>> lockdep_assert_held(). This is required because devfreq_add_device() must
>> hold the lock from setting governor until the device is added to
>> 'devfreq_list', so that a concurrent devfreq_remove_governor() cannot free
>> the governor in between.
>>
>> Signed-off-by: Jie Zhan <zhanjie9 at hisilicon.com>
>
> I'm a bit unclear about the purpose of this commit, or the problem it solves. Can you explain it more clearly?
>
>
`governor_store()` and `devfreq_add_device()` share the similar governor
setting code when `devfreq->governor` can be NULL, so unifying and
factoring out the common governor setting logic with two main purposes:
1. Reduce code duplication.
2. Prepare for the next few patches which add refcounting for the governor
modules -- There would be less `try_module_get()` and `module_put()` by
factoring out `devfreq_set_governor()`.
I'll explain this more in the commit log.
Thanks,
Jie
>> ---
>> drivers/devfreq/devfreq.c | 117 ++++++++++++++++++--------------------
>> 1 file changed, 56 insertions(+), 61 deletions(-)
[ ... ]
More information about the linux-arm-kernel
mailing list