diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2025-04-23 13:18:40 +0300 |
---|---|---|
committer | Viresh Kumar <viresh.kumar@linaro.org> | 2025-04-24 13:35:53 +0300 |
commit | 7a3be00771aa9786c7bb4cdb0ee36fee45f67d69 (patch) | |
tree | a2941cf84b3483bf75e3f158b08f76c3a8855531 | |
parent | 4cb1383f9522a3d2f5e26b70688417187c7d48e4 (diff) | |
download | linux-7a3be00771aa9786c7bb4cdb0ee36fee45f67d69.tar.xz |
OPP: Return opp from dev_pm_opp_get()
For convenience of users, return back the pointer to the opp from
dev_pm_opp_get(), so they can do:
opp = dev_pm_opp_get(tmp_opp);
No intentional functional impact.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
-rw-r--r-- | drivers/opp/core.c | 13 | ||||
-rw-r--r-- | include/linux/pm_opp.h | 7 |
2 files changed, 11 insertions, 9 deletions
diff --git a/drivers/opp/core.c b/drivers/opp/core.c index e63a9b009df1..150439a18b87 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1188,8 +1188,8 @@ static void _find_current_opp(struct device *dev, struct opp_table *opp_table) */ if (IS_ERR(opp)) { mutex_lock(&opp_table->lock); - opp = list_first_entry(&opp_table->opp_list, struct dev_pm_opp, node); - dev_pm_opp_get(opp); + opp = dev_pm_opp_get(list_first_entry(&opp_table->opp_list, + struct dev_pm_opp, node)); mutex_unlock(&opp_table->lock); } @@ -1329,8 +1329,7 @@ static int _set_opp(struct device *dev, struct opp_table *opp_table, dev_pm_opp_put(old_opp); /* Make sure current_opp doesn't get freed */ - dev_pm_opp_get(opp); - opp_table->current_opp = opp; + opp_table->current_opp = dev_pm_opp_get(opp); return ret; } @@ -1724,9 +1723,10 @@ static void _opp_kref_release(struct kref *kref) kfree(opp); } -void dev_pm_opp_get(struct dev_pm_opp *opp) +struct dev_pm_opp *dev_pm_opp_get(struct dev_pm_opp *opp) { kref_get(&opp->kref); + return opp; } EXPORT_SYMBOL_GPL(dev_pm_opp_get); @@ -2706,8 +2706,7 @@ struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_table, list_for_each_entry(opp, &src_table->opp_list, node) { if (opp == src_opp) { - dest_opp = opp->required_opps[i]; - dev_pm_opp_get(dest_opp); + dest_opp = dev_pm_opp_get(opp->required_opps[i]); break; } } diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index c247317aae38..5e4c3428b139 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -161,7 +161,7 @@ struct dev_pm_opp *dev_pm_opp_find_bw_ceil(struct device *dev, struct dev_pm_opp *dev_pm_opp_find_bw_floor(struct device *dev, unsigned int *bw, int index); -void dev_pm_opp_get(struct dev_pm_opp *opp); +struct dev_pm_opp *dev_pm_opp_get(struct dev_pm_opp *opp); void dev_pm_opp_put(struct dev_pm_opp *opp); int dev_pm_opp_add_dynamic(struct device *dev, struct dev_pm_opp_data *opp); @@ -345,7 +345,10 @@ static inline struct dev_pm_opp *dev_pm_opp_find_bw_floor(struct device *dev, return ERR_PTR(-EOPNOTSUPP); } -static inline void dev_pm_opp_get(struct dev_pm_opp *opp) {} +static inline struct dev_pm_opp *dev_pm_opp_get(struct dev_pm_opp *opp) +{ + return opp; +} static inline void dev_pm_opp_put(struct dev_pm_opp *opp) {} |