Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1554799
| From | Stephen Boyd <sboyd@codeaurora.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 02/12] PM / OPP: Add 'struct kref' to OPP table |
| Date | 2017-01-10 00:40 +0100 |
| Message-ID | <sXRHH-231-5@gated-at.bofh.it> (permalink) |
| References | <sLHNL-7ku-5@gated-at.bofh.it> <sLHXs-7qQ-25@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 12/07, Viresh Kumar wrote:
> @@ -894,8 +895,36 @@ static void _kfree_device_rcu(struct rcu_head *head)
> kfree_rcu(opp_table, rcu_head);
> }
>
> -static void _free_opp_table(struct opp_table *opp_table)
> +void _get_opp_table_kref(struct opp_table *opp_table)
> {
> + kref_get(&opp_table->kref);
> +}
> +
> +struct opp_table *dev_pm_opp_get_opp_table(struct device *dev)
> +{
> + struct opp_table *opp_table;
> +
> + /* Hold our table modification lock here */
> + mutex_lock(&opp_table_lock);
> +
> + opp_table = _find_opp_table(dev);
> + if (!IS_ERR(opp_table)) {
> + _get_opp_table_kref(opp_table);
It seems odd to have _get_opp_table_kref() take a pointer to
increment a kref on. It would be better to have _find_opp_table()
return the pointer with the reference already taken so that we
don't have to update callers with reference grabbing calls.
Typically if a function returns a reference counted pointer the
reference counting has already been done.
> + goto unlock;
> + }
> +
> + opp_table = _allocate_opp_table(dev);
> +
> +unlock:
> + mutex_unlock(&opp_table_lock);
> +
> + return opp_table;
> +}
> +EXPORT_SYMBOL_GPL(dev_pm_opp_get_opp_table);
> +
> +static void _opp_table_kref_release_unlocked(struct kref *kref)
> +{
> + struct opp_table *opp_table = container_of(kref, struct opp_table, kref);
> struct opp_device *opp_dev;
>
> /* Release clk */
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
Re: [PATCH 02/12] PM / OPP: Add 'struct kref' to OPP table Stephen Boyd <sboyd@codeaurora.org> - 2017-01-10 00:40 +0100
Re: [PATCH 02/12] PM / OPP: Add 'struct kref' to OPP table Viresh Kumar <viresh.kumar@linaro.org> - 2017-01-10 05:30 +0100
Re: [PATCH 02/12] PM / OPP: Add 'struct kref' to OPP table Stephen Boyd <sboyd@codeaurora.org> - 2017-01-13 10:00 +0100
csiph-web