Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PM / devfreq: Add devfreq_get_devfreq_by_node function

Split off part of devfreq_get_devfreq_by_phandle into a separate
function. This allows callers to fetch devfreq instances by enumerating
devicetree instead of explicit phandles.

Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
[cw00.choi: Export devfreq_get_devfreq_by_node function and
add function to devfreq.h when CONFIG_PM_DEVFREQ is enabled.]
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

authored by

Leonard Crestez and committed by
Chanwoo Choi
7b38b7b0 a1b8638b

+41 -11
+35 -11
drivers/devfreq/devfreq.c
··· 984 984 985 985 #ifdef CONFIG_OF 986 986 /* 987 + * devfreq_get_devfreq_by_node - Get the devfreq device from devicetree 988 + * @node - pointer to device_node 989 + * 990 + * return the instance of devfreq device 991 + */ 992 + struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node) 993 + { 994 + struct devfreq *devfreq; 995 + 996 + if (!node) 997 + return ERR_PTR(-EINVAL); 998 + 999 + mutex_lock(&devfreq_list_lock); 1000 + list_for_each_entry(devfreq, &devfreq_list, node) { 1001 + if (devfreq->dev.parent 1002 + && devfreq->dev.parent->of_node == node) { 1003 + mutex_unlock(&devfreq_list_lock); 1004 + return devfreq; 1005 + } 1006 + } 1007 + mutex_unlock(&devfreq_list_lock); 1008 + 1009 + return ERR_PTR(-ENODEV); 1010 + } 1011 + 1012 + /* 987 1013 * devfreq_get_devfreq_by_phandle - Get the devfreq device from devicetree 988 1014 * @dev - instance to the given device 989 1015 * @index - index into list of devfreq ··· 1031 1005 if (!node) 1032 1006 return ERR_PTR(-ENODEV); 1033 1007 1034 - mutex_lock(&devfreq_list_lock); 1035 - list_for_each_entry(devfreq, &devfreq_list, node) { 1036 - if (devfreq->dev.parent 1037 - && devfreq->dev.parent->of_node == node) { 1038 - mutex_unlock(&devfreq_list_lock); 1039 - of_node_put(node); 1040 - return devfreq; 1041 - } 1042 - } 1043 - mutex_unlock(&devfreq_list_lock); 1008 + devfreq = devfreq_get_devfreq_by_node(node); 1044 1009 of_node_put(node); 1045 1010 1046 - return ERR_PTR(-EPROBE_DEFER); 1011 + return devfreq; 1047 1012 } 1013 + 1048 1014 #else 1015 + struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node) 1016 + { 1017 + return ERR_PTR(-ENODEV); 1018 + } 1019 + 1049 1020 struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, int index) 1050 1021 { 1051 1022 return ERR_PTR(-ENODEV); 1052 1023 } 1053 1024 #endif /* CONFIG_OF */ 1025 + EXPORT_SYMBOL_GPL(devfreq_get_devfreq_by_node); 1054 1026 EXPORT_SYMBOL_GPL(devfreq_get_devfreq_by_phandle); 1055 1027 1056 1028 /**
+6
include/linux/devfreq.h
··· 261 261 struct devfreq *devfreq, 262 262 struct notifier_block *nb, 263 263 unsigned int list); 264 + struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node); 264 265 struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev, int index); 265 266 266 267 #if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND) ··· 413 412 struct notifier_block *nb, 414 413 unsigned int list) 415 414 { 415 + } 416 + 417 + static inline struct devfreq *devfreq_get_devfreq_by_node(struct device_node *node) 418 + { 419 + return ERR_PTR(-ENODEV); 416 420 } 417 421 418 422 static inline struct devfreq *devfreq_get_devfreq_by_phandle(struct device *dev,