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

OPP: Add dev_pm_opp_set_level()

To configure a device to a specific performance level, consumer drivers
currently need to determine the OPP based on the exact level and then
set it, resulting in code duplication across drivers.

The new helper API, dev_pm_opp_set_level(), addresses this issue by
providing a streamlined method for consumer drivers to find and set the
OPP based on the desired performance level, thereby eliminating
redundancy.

Signed-off-by: Praveen Talari <quic_ptalari@quicinc.com>
[ Viresh: Lot of fixes in the code, and rebased over latest changes.
Fixed commit log too. ]
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

authored by

Praveen Talari and committed by
Viresh Kumar
ee3de3cf ff9c5120

+11
+11
include/linux/pm_opp.h
··· 197 197 void dev_pm_opp_remove_table(struct device *dev); 198 198 void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask); 199 199 int dev_pm_opp_sync_regulators(struct device *dev); 200 + 200 201 #else 201 202 static inline struct opp_table *dev_pm_opp_get_opp_table(struct device *dev) 202 203 { ··· 716 715 static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) 717 716 { 718 717 return dev_pm_opp_get_freq_indexed(opp, 0); 718 + } 719 + 720 + static inline int dev_pm_opp_set_level(struct device *dev, unsigned int level) 721 + { 722 + struct dev_pm_opp *opp __free(put_opp) = dev_pm_opp_find_level_exact(dev, level); 723 + 724 + if (IS_ERR(opp)) 725 + return PTR_ERR(opp); 726 + 727 + return dev_pm_opp_set_opp(dev, opp); 719 728 } 720 729 721 730 #endif /* __LINUX_OPP_H__ */