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

opp: Add devres wrapper for dev_pm_opp_of_add_table

Add devres wrapper for dev_pm_opp_of_add_table() to simplify drivers
code.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

authored by

Yangtao Li and committed by
Viresh Kumar
3d5cfbb6 9c4f220f

+42
+36
drivers/opp/of.c
··· 1104 1104 return ret; 1105 1105 } 1106 1106 1107 + static void devm_pm_opp_of_table_release(void *data) 1108 + { 1109 + dev_pm_opp_of_remove_table(data); 1110 + } 1111 + 1112 + /** 1113 + * devm_pm_opp_of_add_table() - Initialize opp table from device tree 1114 + * @dev: device pointer used to lookup OPP table. 1115 + * 1116 + * Register the initial OPP table with the OPP library for given device. 1117 + * 1118 + * The opp_table structure will be freed after the device is destroyed. 1119 + * 1120 + * Return: 1121 + * 0 On success OR 1122 + * Duplicate OPPs (both freq and volt are same) and opp->available 1123 + * -EEXIST Freq are same and volt are different OR 1124 + * Duplicate OPPs (both freq and volt are same) and !opp->available 1125 + * -ENOMEM Memory allocation failure 1126 + * -ENODEV when 'operating-points' property is not found or is invalid data 1127 + * in device node. 1128 + * -ENODATA when empty 'operating-points' property is found 1129 + * -EINVAL when invalid entries are found in opp-v2 table 1130 + */ 1131 + int devm_pm_opp_of_add_table(struct device *dev) 1132 + { 1133 + int ret; 1134 + 1135 + ret = dev_pm_opp_of_add_table(dev); 1136 + if (ret) 1137 + return ret; 1138 + 1139 + return devm_add_action_or_reset(dev, devm_pm_opp_of_table_release, dev); 1140 + } 1141 + EXPORT_SYMBOL_GPL(devm_pm_opp_of_add_table); 1142 + 1107 1143 /** 1108 1144 * dev_pm_opp_of_add_table() - Initialize opp table from device tree 1109 1145 * @dev: device pointer used to lookup OPP table.
+6
include/linux/pm_opp.h
··· 441 441 int dev_pm_opp_of_add_table_indexed(struct device *dev, int index); 442 442 int dev_pm_opp_of_add_table_noclk(struct device *dev, int index); 443 443 void dev_pm_opp_of_remove_table(struct device *dev); 444 + int devm_pm_opp_of_add_table(struct device *dev); 444 445 int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask); 445 446 void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask); 446 447 int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); ··· 472 471 473 472 static inline void dev_pm_opp_of_remove_table(struct device *dev) 474 473 { 474 + } 475 + 476 + static inline int devm_pm_opp_of_add_table(struct device *dev) 477 + { 478 + return -EOPNOTSUPP; 475 479 } 476 480 477 481 static inline int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask)