提交 63ce228e 编写于 作者: R Rafael J. Wysocki

Merge branch 'opp/linux-next' of...

Merge branch 'opp/linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm into pm-opp

Pull more OPP updates for v4.18 from Viresh Kumar.

* 'opp/linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm:
  OPP: Allow same OPP table to be used for multiple genpd
  PM / OPP: Fix shared OPP table support in dev_pm_opp_register_set_opp_helper()
  PM / OPP: Fix shared OPP table support in dev_pm_opp_set_regulators()
  PM / OPP: Fix shared OPP table support in dev_pm_opp_set_prop_name()
  PM / OPP: Fix shared OPP table support in dev_pm_opp_set_supported_hw()
...@@ -1157,7 +1157,6 @@ struct opp_table *dev_pm_opp_set_supported_hw(struct device *dev, ...@@ -1157,7 +1157,6 @@ struct opp_table *dev_pm_opp_set_supported_hw(struct device *dev,
const u32 *versions, unsigned int count) const u32 *versions, unsigned int count)
{ {
struct opp_table *opp_table; struct opp_table *opp_table;
int ret;
opp_table = dev_pm_opp_get_opp_table(dev); opp_table = dev_pm_opp_get_opp_table(dev);
if (!opp_table) if (!opp_table)
...@@ -1166,29 +1165,20 @@ struct opp_table *dev_pm_opp_set_supported_hw(struct device *dev, ...@@ -1166,29 +1165,20 @@ struct opp_table *dev_pm_opp_set_supported_hw(struct device *dev,
/* Make sure there are no concurrent readers while updating opp_table */ /* Make sure there are no concurrent readers while updating opp_table */
WARN_ON(!list_empty(&opp_table->opp_list)); WARN_ON(!list_empty(&opp_table->opp_list));
/* Do we already have a version hierarchy associated with opp_table? */ /* Another CPU that shares the OPP table has set the property ? */
if (opp_table->supported_hw) { if (opp_table->supported_hw)
dev_err(dev, "%s: Already have supported hardware list\n", return opp_table;
__func__);
ret = -EBUSY;
goto err;
}
opp_table->supported_hw = kmemdup(versions, count * sizeof(*versions), opp_table->supported_hw = kmemdup(versions, count * sizeof(*versions),
GFP_KERNEL); GFP_KERNEL);
if (!opp_table->supported_hw) { if (!opp_table->supported_hw) {
ret = -ENOMEM; dev_pm_opp_put_opp_table(opp_table);
goto err; return ERR_PTR(-ENOMEM);
} }
opp_table->supported_hw_count = count; opp_table->supported_hw_count = count;
return opp_table; return opp_table;
err:
dev_pm_opp_put_opp_table(opp_table);
return ERR_PTR(ret);
} }
EXPORT_SYMBOL_GPL(dev_pm_opp_set_supported_hw); EXPORT_SYMBOL_GPL(dev_pm_opp_set_supported_hw);
...@@ -1205,12 +1195,6 @@ void dev_pm_opp_put_supported_hw(struct opp_table *opp_table) ...@@ -1205,12 +1195,6 @@ void dev_pm_opp_put_supported_hw(struct opp_table *opp_table)
/* Make sure there are no concurrent readers while updating opp_table */ /* Make sure there are no concurrent readers while updating opp_table */
WARN_ON(!list_empty(&opp_table->opp_list)); WARN_ON(!list_empty(&opp_table->opp_list));
if (!opp_table->supported_hw) {
pr_err("%s: Doesn't have supported hardware list\n",
__func__);
return;
}
kfree(opp_table->supported_hw); kfree(opp_table->supported_hw);
opp_table->supported_hw = NULL; opp_table->supported_hw = NULL;
opp_table->supported_hw_count = 0; opp_table->supported_hw_count = 0;
...@@ -1232,7 +1216,6 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_put_supported_hw); ...@@ -1232,7 +1216,6 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_put_supported_hw);
struct opp_table *dev_pm_opp_set_prop_name(struct device *dev, const char *name) struct opp_table *dev_pm_opp_set_prop_name(struct device *dev, const char *name)
{ {
struct opp_table *opp_table; struct opp_table *opp_table;
int ret;
opp_table = dev_pm_opp_get_opp_table(dev); opp_table = dev_pm_opp_get_opp_table(dev);
if (!opp_table) if (!opp_table)
...@@ -1241,26 +1224,17 @@ struct opp_table *dev_pm_opp_set_prop_name(struct device *dev, const char *name) ...@@ -1241,26 +1224,17 @@ struct opp_table *dev_pm_opp_set_prop_name(struct device *dev, const char *name)
/* Make sure there are no concurrent readers while updating opp_table */ /* Make sure there are no concurrent readers while updating opp_table */
WARN_ON(!list_empty(&opp_table->opp_list)); WARN_ON(!list_empty(&opp_table->opp_list));
/* Do we already have a prop-name associated with opp_table? */ /* Another CPU that shares the OPP table has set the property ? */
if (opp_table->prop_name) { if (opp_table->prop_name)
dev_err(dev, "%s: Already have prop-name %s\n", __func__, return opp_table;
opp_table->prop_name);
ret = -EBUSY;
goto err;
}
opp_table->prop_name = kstrdup(name, GFP_KERNEL); opp_table->prop_name = kstrdup(name, GFP_KERNEL);
if (!opp_table->prop_name) { if (!opp_table->prop_name) {
ret = -ENOMEM; dev_pm_opp_put_opp_table(opp_table);
goto err; return ERR_PTR(-ENOMEM);
} }
return opp_table; return opp_table;
err:
dev_pm_opp_put_opp_table(opp_table);
return ERR_PTR(ret);
} }
EXPORT_SYMBOL_GPL(dev_pm_opp_set_prop_name); EXPORT_SYMBOL_GPL(dev_pm_opp_set_prop_name);
...@@ -1277,11 +1251,6 @@ void dev_pm_opp_put_prop_name(struct opp_table *opp_table) ...@@ -1277,11 +1251,6 @@ void dev_pm_opp_put_prop_name(struct opp_table *opp_table)
/* Make sure there are no concurrent readers while updating opp_table */ /* Make sure there are no concurrent readers while updating opp_table */
WARN_ON(!list_empty(&opp_table->opp_list)); WARN_ON(!list_empty(&opp_table->opp_list));
if (!opp_table->prop_name) {
pr_err("%s: Doesn't have a prop-name\n", __func__);
return;
}
kfree(opp_table->prop_name); kfree(opp_table->prop_name);
opp_table->prop_name = NULL; opp_table->prop_name = NULL;
...@@ -1351,11 +1320,9 @@ struct opp_table *dev_pm_opp_set_regulators(struct device *dev, ...@@ -1351,11 +1320,9 @@ struct opp_table *dev_pm_opp_set_regulators(struct device *dev,
goto err; goto err;
} }
/* Already have regulators set */ /* Another CPU that shares the OPP table has set the regulators ? */
if (opp_table->regulators) { if (opp_table->regulators)
ret = -EBUSY; return opp_table;
goto err;
}
opp_table->regulators = kmalloc_array(count, opp_table->regulators = kmalloc_array(count,
sizeof(*opp_table->regulators), sizeof(*opp_table->regulators),
...@@ -1409,10 +1376,8 @@ void dev_pm_opp_put_regulators(struct opp_table *opp_table) ...@@ -1409,10 +1376,8 @@ void dev_pm_opp_put_regulators(struct opp_table *opp_table)
{ {
int i; int i;
if (!opp_table->regulators) { if (!opp_table->regulators)
pr_err("%s: Doesn't have regulators set\n", __func__); goto put_opp_table;
return;
}
/* Make sure there are no concurrent readers while updating opp_table */ /* Make sure there are no concurrent readers while updating opp_table */
WARN_ON(!list_empty(&opp_table->opp_list)); WARN_ON(!list_empty(&opp_table->opp_list));
...@@ -1426,6 +1391,7 @@ void dev_pm_opp_put_regulators(struct opp_table *opp_table) ...@@ -1426,6 +1391,7 @@ void dev_pm_opp_put_regulators(struct opp_table *opp_table)
opp_table->regulators = NULL; opp_table->regulators = NULL;
opp_table->regulator_count = 0; opp_table->regulator_count = 0;
put_opp_table:
dev_pm_opp_put_opp_table(opp_table); dev_pm_opp_put_opp_table(opp_table);
} }
EXPORT_SYMBOL_GPL(dev_pm_opp_put_regulators); EXPORT_SYMBOL_GPL(dev_pm_opp_put_regulators);
...@@ -1511,7 +1477,6 @@ struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev, ...@@ -1511,7 +1477,6 @@ struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev,
int (*set_opp)(struct dev_pm_set_opp_data *data)) int (*set_opp)(struct dev_pm_set_opp_data *data))
{ {
struct opp_table *opp_table; struct opp_table *opp_table;
int ret;
if (!set_opp) if (!set_opp)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
...@@ -1522,24 +1487,15 @@ struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev, ...@@ -1522,24 +1487,15 @@ struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev,
/* This should be called before OPPs are initialized */ /* This should be called before OPPs are initialized */
if (WARN_ON(!list_empty(&opp_table->opp_list))) { if (WARN_ON(!list_empty(&opp_table->opp_list))) {
ret = -EBUSY; dev_pm_opp_put_opp_table(opp_table);
goto err; return ERR_PTR(-EBUSY);
} }
/* Already have custom set_opp helper */ /* Another CPU that shares the OPP table has set the helper ? */
if (WARN_ON(opp_table->set_opp)) { if (!opp_table->set_opp)
ret = -EBUSY; opp_table->set_opp = set_opp;
goto err;
}
opp_table->set_opp = set_opp;
return opp_table; return opp_table;
err:
dev_pm_opp_put_opp_table(opp_table);
return ERR_PTR(ret);
} }
EXPORT_SYMBOL_GPL(dev_pm_opp_register_set_opp_helper); EXPORT_SYMBOL_GPL(dev_pm_opp_register_set_opp_helper);
...@@ -1552,17 +1508,10 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_register_set_opp_helper); ...@@ -1552,17 +1508,10 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_register_set_opp_helper);
*/ */
void dev_pm_opp_unregister_set_opp_helper(struct opp_table *opp_table) void dev_pm_opp_unregister_set_opp_helper(struct opp_table *opp_table)
{ {
if (!opp_table->set_opp) {
pr_err("%s: Doesn't have custom set_opp helper set\n",
__func__);
return;
}
/* Make sure there are no concurrent readers while updating opp_table */ /* Make sure there are no concurrent readers while updating opp_table */
WARN_ON(!list_empty(&opp_table->opp_list)); WARN_ON(!list_empty(&opp_table->opp_list));
opp_table->set_opp = NULL; opp_table->set_opp = NULL;
dev_pm_opp_put_opp_table(opp_table); dev_pm_opp_put_opp_table(opp_table);
} }
EXPORT_SYMBOL_GPL(dev_pm_opp_unregister_set_opp_helper); EXPORT_SYMBOL_GPL(dev_pm_opp_unregister_set_opp_helper);
......
...@@ -554,11 +554,24 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table); ...@@ -554,11 +554,24 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table);
int dev_pm_opp_of_add_table_indexed(struct device *dev, int index) int dev_pm_opp_of_add_table_indexed(struct device *dev, int index)
{ {
struct device_node *opp_np; struct device_node *opp_np;
int ret; int ret, count;
again:
opp_np = _opp_of_get_opp_desc_node(dev->of_node, index); opp_np = _opp_of_get_opp_desc_node(dev->of_node, index);
if (!opp_np) if (!opp_np) {
/*
* If only one phandle is present, then the same OPP table
* applies for all index requests.
*/
count = of_count_phandle_with_args(dev->of_node,
"operating-points-v2", NULL);
if (count == 1 && index) {
index = 0;
goto again;
}
return -ENODEV; return -ENODEV;
}
ret = _of_add_opp_table_v2(dev, opp_np); ret = _of_add_opp_table_v2(dev, opp_np);
of_node_put(opp_np); of_node_put(opp_np);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册