Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1205695
| From | Viresh Kumar <viresh.kumar@linaro.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH V2 1/6] PM / OPP: Free resources and properly return error on failure |
| Date | 2015-08-12 10:30 +0200 |
| Message-ID | <pWzA6-7iu-15@gated-at.bofh.it> (permalink) |
| References | (2 earlier) <pWj2i-86m-27@gated-at.bofh.it> <pWjbY-8hI-27@gated-at.bofh.it> <pWlns-3c7-21@gated-at.bofh.it> <pWy1k-4Y3-15@gated-at.bofh.it> <pWzqp-77n-17@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 12-08-15, 11:11, Dan Carpenter wrote:
> If it doesn't WARN() then it's not buggy, but it's still ugly. We
> should not call of_free_opp_table() because we *tried* to add an OPP, we
> should only call it if we *succeeded*.
This is done in order to write lesser code. Otherwise we need
something like this:
diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index bcbd92c3b717..650e92e2f2f0 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -1317,14 +1317,15 @@ static int _of_init_opp_table_v2(struct device *dev,
/* We have opp-list node now, iterate over it and add OPPs */
for_each_available_child_of_node(opp_np, np) {
- count++;
-
ret = _opp_add_static_v2(dev, np);
if (ret) {
dev_err(dev, "%s: Failed to add OPP, %d\n", __func__,
ret);
+ if (!count)
+ goto put_opp_np;
goto free_table;
}
+ count++;
}
/* There should be one of more OPP defined */
To some people, this will look even more *ugly*. And so I just called
free_table() on error.
> The way the code is written and from your emails I was afraid that if
> you tried to call _opp_add_static_v2() and it fails then it leaves
> artifacts lying around that need to be cleaned up by the caller.
No. The problem is that we are trying to add OPPs in a while loop and
on failure we need to free all we added earlier.
--
viresh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH V2 1/6] PM / OPP: Free resources and properly return error on failure Viresh Kumar <viresh.kumar@linaro.org> - 2015-08-11 12:40 +0200
Re: [PATCH V2 1/6] PM / OPP: Free resources and properly return error on failure Dan Carpenter <dan.carpenter@oracle.com> - 2015-08-11 16:50 +0200
Re: [PATCH V2 1/6] PM / OPP: Free resources and properly return error on failure Viresh Kumar <viresh.kumar@linaro.org> - 2015-08-11 17:00 +0200
Re: [PATCH V2 1/6] PM / OPP: Free resources and properly return error on failure Dan Carpenter <dan.carpenter@oracle.com> - 2015-08-11 19:20 +0200
Re: [PATCH V2 1/6] PM / OPP: Free resources and properly return error on failure Viresh Kumar <viresh.kumar@linaro.org> - 2015-08-12 08:50 +0200
Re: [PATCH V2 1/6] PM / OPP: Free resources and properly return error on failure Dan Carpenter <dan.carpenter@oracle.com> - 2015-08-12 10:20 +0200
Re: [PATCH V2 1/6] PM / OPP: Free resources and properly return error on failure Viresh Kumar <viresh.kumar@linaro.org> - 2015-08-12 10:30 +0200
Re: [PATCH V2 1/6] PM / OPP: Free resources and properly return error on failure Dan Carpenter <dan.carpenter@oracle.com> - 2015-08-12 11:10 +0200
Re: [PATCH V2 1/6] PM / OPP: Free resources and properly return error on failure Viresh Kumar <viresh.kumar@linaro.org> - 2015-08-12 12:20 +0200
Re: [PATCH V2 1/6] PM / OPP: Free resources and properly return error on failure Dan Carpenter <dan.carpenter@oracle.com> - 2015-08-12 13:00 +0200
csiph-web