aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/power/opp/core.c
diff options
context:
space:
mode:
authorSudeep Holla <Sudeep.Holla@arm.com>2016-05-03 10:05:04 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-05-04 19:38:44 -0400
commit411466c5081d2f649b3583cae0f6c9ad5edec636 (patch)
treece07767ac0e4c5f1e5371e336819aa47598ae31e /drivers/base/power/opp/core.c
parentddbb74bc70c0dbaab85d1aa2564b0b3217267454 (diff)
PM / OPP: add non-OF versions of dev_pm_opp_{cpumask_, }remove_table
Functions dev_pm_opp_of_{cpumask_,}remove_table removes/frees all the static OPP entries associated with the device and/or all cpus(in case of cpumask) that are created from DT. However the OPP entries are populated reading from the firmware or some different method using dev_pm_opp_add are marked dynamic and can't be removed using above functions. This patch adds non DT/OF versions of dev_pm_opp_{cpumask_,}remove_table to support the above mentioned usecase. This is in preparation to make use of the same in scpi-cpufreq.c Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/base/power/opp/core.c')
-rw-r--r--drivers/base/power/opp/core.c58
1 files changed, 43 insertions, 15 deletions
diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
index 433b60092972..9f8bf04b4dbe 100644
--- a/drivers/base/power/opp/core.c
+++ b/drivers/base/power/opp/core.c
@@ -1845,21 +1845,11 @@ struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev)
1845} 1845}
1846EXPORT_SYMBOL_GPL(dev_pm_opp_get_notifier); 1846EXPORT_SYMBOL_GPL(dev_pm_opp_get_notifier);
1847 1847
1848#ifdef CONFIG_OF 1848/*
1849/** 1849 * Free OPPs either created using static entries present in DT or even the
1850 * dev_pm_opp_of_remove_table() - Free OPP table entries created from static DT 1850 * dynamically added entries based on remove_all param.
1851 * entries
1852 * @dev: device pointer used to lookup OPP table.
1853 *
1854 * Free OPPs created using static entries present in DT.
1855 *
1856 * Locking: The internal opp_table and opp structures are RCU protected.
1857 * Hence this function indirectly uses RCU updater strategy with mutex locks
1858 * to keep the integrity of the internal data structures. Callers should ensure
1859 * that this function is *NOT* called under RCU protection or in contexts where
1860 * mutex cannot be locked.
1861 */ 1851 */
1862void dev_pm_opp_of_remove_table(struct device *dev) 1852static void _dev_pm_opp_remove_table(struct device *dev, bool remove_all)
1863{ 1853{
1864 struct opp_table *opp_table; 1854 struct opp_table *opp_table;
1865 struct dev_pm_opp *opp, *tmp; 1855 struct dev_pm_opp *opp, *tmp;
@@ -1884,7 +1874,7 @@ void dev_pm_opp_of_remove_table(struct device *dev)
1884 if (list_is_singular(&opp_table->dev_list)) { 1874 if (list_is_singular(&opp_table->dev_list)) {
1885 /* Free static OPPs */ 1875 /* Free static OPPs */
1886 list_for_each_entry_safe(opp, tmp, &opp_table->opp_list, node) { 1876 list_for_each_entry_safe(opp, tmp, &opp_table->opp_list, node) {
1887 if (!opp->dynamic) 1877 if (remove_all || !opp->dynamic)
1888 _opp_remove(opp_table, opp, true); 1878 _opp_remove(opp_table, opp, true);
1889 } 1879 }
1890 } else { 1880 } else {
@@ -1894,6 +1884,44 @@ void dev_pm_opp_of_remove_table(struct device *dev)
1894unlock: 1884unlock:
1895 mutex_unlock(&opp_table_lock); 1885 mutex_unlock(&opp_table_lock);
1896} 1886}
1887
1888/**
1889 * dev_pm_opp_remove_table() - Free all OPPs associated with the device
1890 * @dev: device pointer used to lookup OPP table.
1891 *
1892 * Free both OPPs created using static entries present in DT and the
1893 * dynamically added entries.
1894 *
1895 * Locking: The internal opp_table and opp structures are RCU protected.
1896 * Hence this function indirectly uses RCU updater strategy with mutex locks
1897 * to keep the integrity of the internal data structures. Callers should ensure
1898 * that this function is *NOT* called under RCU protection or in contexts where
1899 * mutex cannot be locked.
1900 */
1901void dev_pm_opp_remove_table(struct device *dev)
1902{
1903 _dev_pm_opp_remove_table(dev, true);
1904}
1905EXPORT_SYMBOL_GPL(dev_pm_opp_remove_table);
1906
1907#ifdef CONFIG_OF
1908/**
1909 * dev_pm_opp_of_remove_table() - Free OPP table entries created from static DT
1910 * entries
1911 * @dev: device pointer used to lookup OPP table.
1912 *
1913 * Free OPPs created using static entries present in DT.
1914 *
1915 * Locking: The internal opp_table and opp structures are RCU protected.
1916 * Hence this function indirectly uses RCU updater strategy with mutex locks
1917 * to keep the integrity of the internal data structures. Callers should ensure
1918 * that this function is *NOT* called under RCU protection or in contexts where
1919 * mutex cannot be locked.
1920 */
1921void dev_pm_opp_of_remove_table(struct device *dev)
1922{
1923 _dev_pm_opp_remove_table(dev, false);
1924}
1897EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table); 1925EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table);
1898 1926
1899/* Returns opp descriptor node for a device, caller must do of_node_put() */ 1927/* Returns opp descriptor node for a device, caller must do of_node_put() */