PM / devfreq: Fix devfreq_add_device() when drivers are built as modules.
authorEnric Balletbo i Serra <enric.balletbo@collabora.com>
Wed, 4 Jul 2018 08:45:50 +0000 (10:45 +0200)
committerJunghoon Kim <jhoon20.kim@samsung.com>
Thu, 14 Feb 2019 05:58:23 +0000 (14:58 +0900)
commit5b33bb50ded87367d13b382a90af3cda0e70b5b4
tree9516f48f93297739b2a93db94dba2eaa84007a3c
parent8a396a8c57b0668115489c34c4c2f6abb0ff1bf1
PM / devfreq: Fix devfreq_add_device() when drivers are built as modules.

When the devfreq driver and the governor driver are built as modules,
the call to devfreq_add_device() or governor_store() fails because the
governor driver is not loaded at the time the devfreq driver loads. The
devfreq driver has a build dependency on the governor but also should
have a runtime dependency. We need to make sure that the governor driver
is loaded before the devfreq driver.

This patch fixes this bug by adding a try_then_request_governor()
function. First tries to find the governor, and then, if it is not found,
it requests the module and tries again.

Change-Id: I71cdbcc2867980714de984d0c0c2641f7eda8b46
Fixes: 1b5c1be2c88e (PM / devfreq: map devfreq drivers to governor using name)
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
[cw00.choi: Backported from mainline kernel]
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
drivers/devfreq/devfreq.c