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_set_supported_hw

Add devres wrapper for dev_pm_opp_set_supported_hw() 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
9c4f220f 32aee78b

+37
+29
drivers/opp/core.c
··· 1857 1857 } 1858 1858 EXPORT_SYMBOL_GPL(dev_pm_opp_put_supported_hw); 1859 1859 1860 + static void devm_pm_opp_supported_hw_release(void *data) 1861 + { 1862 + dev_pm_opp_put_supported_hw(data); 1863 + } 1864 + 1865 + /** 1866 + * devm_pm_opp_set_supported_hw() - Set supported platforms 1867 + * @dev: Device for which supported-hw has to be set. 1868 + * @versions: Array of hierarchy of versions to match. 1869 + * @count: Number of elements in the array. 1870 + * 1871 + * This is a resource-managed variant of dev_pm_opp_set_supported_hw(). 1872 + * 1873 + * Return: 0 on success and errorno otherwise. 1874 + */ 1875 + int devm_pm_opp_set_supported_hw(struct device *dev, const u32 *versions, 1876 + unsigned int count) 1877 + { 1878 + struct opp_table *opp_table; 1879 + 1880 + opp_table = dev_pm_opp_set_supported_hw(dev, versions, count); 1881 + if (IS_ERR(opp_table)) 1882 + return PTR_ERR(opp_table); 1883 + 1884 + return devm_add_action_or_reset(dev, devm_pm_opp_supported_hw_release, 1885 + opp_table); 1886 + } 1887 + EXPORT_SYMBOL_GPL(devm_pm_opp_set_supported_hw); 1888 + 1860 1889 /** 1861 1890 * dev_pm_opp_set_prop_name() - Set prop-extn name 1862 1891 * @dev: Device for which the prop-name has to be set.
+8
include/linux/pm_opp.h
··· 144 144 145 145 struct opp_table *dev_pm_opp_set_supported_hw(struct device *dev, const u32 *versions, unsigned int count); 146 146 void dev_pm_opp_put_supported_hw(struct opp_table *opp_table); 147 + int devm_pm_opp_set_supported_hw(struct device *dev, const u32 *versions, unsigned int count); 147 148 struct opp_table *dev_pm_opp_set_prop_name(struct device *dev, const char *name); 148 149 void dev_pm_opp_put_prop_name(struct opp_table *opp_table); 149 150 struct opp_table *dev_pm_opp_set_regulators(struct device *dev, const char * const names[], unsigned int count); ··· 321 320 } 322 321 323 322 static inline void dev_pm_opp_put_supported_hw(struct opp_table *opp_table) {} 323 + 324 + static inline int devm_pm_opp_set_supported_hw(struct device *dev, 325 + const u32 *versions, 326 + unsigned int count) 327 + { 328 + return -EOPNOTSUPP; 329 + } 324 330 325 331 static inline struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev, 326 332 int (*set_opp)(struct dev_pm_set_opp_data *data))