forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PM / devfreq: Add devm_devfreq_{register,unregister}_opp_notfier func…
…tion This patch add resource-managed function for devfreq opp as following functions. The devm_devfreq_register_opp_notifier() manages automatically the registration of devfreq opp using device resource management. - devm_devfreq_register_opp_notifier - devm_devfreq_unregister_opp_notifier() Signed-off-by: Chanwoo Choi <[email protected]> Signed-off-by: MyungJoo Ham <[email protected]>
- Loading branch information
1 parent
8cd8409
commit d5b040d
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1169,6 +1169,54 @@ int devfreq_unregister_opp_notifier(struct device *dev, struct devfreq *devfreq) | |
return ret; | ||
} | ||
|
||
static void devm_devfreq_opp_release(struct device *dev, void *res) | ||
{ | ||
devfreq_unregister_opp_notifier(dev, *(struct devfreq **)res); | ||
} | ||
|
||
/** | ||
* devm_ devfreq_register_opp_notifier() | ||
* - Resource-managed devfreq_register_opp_notifier() | ||
* @dev: The devfreq user device. (parent of devfreq) | ||
* @devfreq: The devfreq object. | ||
*/ | ||
int devm_devfreq_register_opp_notifier(struct device *dev, | ||
struct devfreq *devfreq) | ||
{ | ||
struct devfreq **ptr; | ||
int ret; | ||
|
||
ptr = devres_alloc(devm_devfreq_opp_release, sizeof(*ptr), GFP_KERNEL); | ||
if (!ptr) | ||
return -ENOMEM; | ||
|
||
ret = devfreq_register_opp_notifier(dev, devfreq); | ||
if (ret) { | ||
devres_free(ptr); | ||
return ret; | ||
} | ||
|
||
*ptr = devfreq; | ||
devres_add(dev, ptr); | ||
|
||
return 0; | ||
} | ||
EXPORT_SYMBOL(devm_devfreq_register_opp_notifier); | ||
|
||
/** | ||
* devm_devfreq_unregister_opp_notifier() | ||
* - Resource-managed devfreq_unregister_opp_notifier() | ||
* @dev: The devfreq user device. (parent of devfreq) | ||
* @devfreq: The devfreq object. | ||
*/ | ||
void devm_devfreq_unregister_opp_notifier(struct device *dev, | ||
struct devfreq *devfreq) | ||
{ | ||
WARN_ON(devres_release(dev, devm_devfreq_opp_release, | ||
devm_devfreq_dev_match, devfreq)); | ||
} | ||
EXPORT_SYMBOL(devm_devfreq_unregister_opp_notifier); | ||
|
||
MODULE_AUTHOR("MyungJoo Ham <[email protected]>"); | ||
MODULE_DESCRIPTION("devfreq class support"); | ||
MODULE_LICENSE("GPL"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters