Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1203837 > unrolled thread
| Started by | Viresh Kumar <viresh.kumar@linaro.org> |
|---|---|
| First post | 2015-08-10 08:40 +0200 |
| Last post | 2015-08-11 08:10 +0200 |
| Articles | 10 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() Viresh Kumar <viresh.kumar@linaro.org> - 2015-08-10 08:40 +0200
Re: [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() Stephen Boyd <sboyd@codeaurora.org> - 2015-08-10 21:30 +0200
Re: [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() Viresh Kumar <viresh.kumar@linaro.org> - 2015-08-11 02:30 +0200
Re: [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() Stephen Boyd <sboyd@codeaurora.org> - 2015-08-11 02:40 +0200
Re: [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() Viresh Kumar <viresh.kumar@linaro.org> - 2015-08-11 04:30 +0200
Re: [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() Stephen Boyd <sboyd@codeaurora.org> - 2015-08-11 08:10 +0200
Re: [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() Viresh Kumar <viresh.kumar@linaro.org> - 2015-08-11 09:00 +0200
Re: [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() Viresh Kumar <viresh.kumar@linaro.org> - 2015-08-11 10:40 +0200
Re: [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() Viresh Kumar <viresh.kumar@linaro.org> - 2015-08-11 04:40 +0200
Re: [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() Stephen Boyd <sboyd@codeaurora.org> - 2015-08-11 08:10 +0200
| From | Viresh Kumar <viresh.kumar@linaro.org> |
|---|---|
| Date | 2015-08-10 08:40 +0200 |
| Subject | [PATCH 2/6] PM / OPP: restructure _of_init_opp_table_v2() |
| Message-ID | <pVOUy-6bs-19@gated-at.bofh.it> |
'dev_opp' will always be NULL in _of_init_opp_table_v2() after creating
OPPs for a device. There is no point comparing it against NULL there.
Restructure code a bit to make it more efficient.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/base/power/opp.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index 1daaa1a418a2..c9747fb192b1 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -1295,20 +1295,19 @@ static int _of_init_opp_table_v2(struct device *dev,
if (WARN_ON(!count))
goto out;
- if (!ret) {
- if (!dev_opp) {
- dev_opp = _find_device_opp(dev);
- if (WARN_ON(!dev_opp))
- goto out;
- }
-
- dev_opp->np = opp_np;
- dev_opp->shared_opp = of_property_read_bool(opp_np,
- "opp-shared");
- } else {
+ if (ret) {
of_free_opp_table(dev);
+ goto out;
}
+ dev_opp = _find_device_opp(dev);
+ if (WARN_ON(!dev_opp))
+ goto out;
+
+ dev_opp->np = opp_np;
+ dev_opp->shared_opp = of_property_read_bool(opp_np,
+ "opp-shared");
+
out:
return ret;
}
--
2.4.0
--
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/
[toc] | [next] | [standalone]
| From | Stephen Boyd <sboyd@codeaurora.org> |
|---|---|
| Date | 2015-08-10 21:30 +0200 |
| Message-ID | <pW0VI-7eq-9@gated-at.bofh.it> |
| In reply to | #1203837 |
On 08/10, Viresh Kumar wrote:
> 'dev_opp' will always be NULL in _of_init_opp_table_v2() after creating
> OPPs for a device. There is no point comparing it against NULL there.
>
> Restructure code a bit to make it more efficient.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Curious if these are a response to the static checker mails? If
so it would be good to add a reported-by tag.
> ---
> drivers/base/power/opp.c | 21 ++++++++++-----------
> 1 file changed, 10 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
> index 1daaa1a418a2..c9747fb192b1 100644
> --- a/drivers/base/power/opp.c
> +++ b/drivers/base/power/opp.c
> @@ -1295,20 +1295,19 @@ static int _of_init_opp_table_v2(struct device *dev,
> if (WARN_ON(!count))
> goto out;
>
> - if (!ret) {
> - if (!dev_opp) {
> - dev_opp = _find_device_opp(dev);
> - if (WARN_ON(!dev_opp))
> - goto out;
> - }
> -
> - dev_opp->np = opp_np;
> - dev_opp->shared_opp = of_property_read_bool(opp_np,
> - "opp-shared");
> - } else {
> + if (ret) {
> of_free_opp_table(dev);
> + goto out;
> }
>
> + dev_opp = _find_device_opp(dev);
> + if (WARN_ON(!dev_opp))
> + goto out;
Doesn't ret = 0 in this case? Why not drop the goto and just
return some error code. Same for the goto out up above.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
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/
[toc] | [prev] | [next] | [standalone]
| From | Viresh Kumar <viresh.kumar@linaro.org> |
|---|---|
| Date | 2015-08-11 02:30 +0200 |
| Message-ID | <pW5C3-5yL-11@gated-at.bofh.it> |
| In reply to | #1204509 |
On 10-08-15, 12:23, Stephen Boyd wrote:
> On 08/10, Viresh Kumar wrote:
> > 'dev_opp' will always be NULL in _of_init_opp_table_v2() after creating
> > OPPs for a device. There is no point comparing it against NULL there.
> >
> > Restructure code a bit to make it more efficient.
> >
> > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
>
> Curious if these are a response to the static checker mails? If
> so it would be good to add a reported-by tag.
No it wasn't, I had these waiting in my queue even before Rafael
applied the earlier ones. I was waiting for them to get in before
sending more stuff :)
> > ---
> > drivers/base/power/opp.c | 21 ++++++++++-----------
> > 1 file changed, 10 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
> > index 1daaa1a418a2..c9747fb192b1 100644
> > --- a/drivers/base/power/opp.c
> > +++ b/drivers/base/power/opp.c
> > @@ -1295,20 +1295,19 @@ static int _of_init_opp_table_v2(struct device *dev,
> > if (WARN_ON(!count))
> > goto out;
> >
> > - if (!ret) {
> > - if (!dev_opp) {
> > - dev_opp = _find_device_opp(dev);
> > - if (WARN_ON(!dev_opp))
> > - goto out;
> > - }
> > -
> > - dev_opp->np = opp_np;
> > - dev_opp->shared_opp = of_property_read_bool(opp_np,
> > - "opp-shared");
> > - } else {
> > + if (ret) {
> > of_free_opp_table(dev);
> > + goto out;
> > }
> >
> > + dev_opp = _find_device_opp(dev);
> > + if (WARN_ON(!dev_opp))
> > + goto out;
>
> Doesn't ret = 0 in this case?
Because ret is already 0, juse see the above if (ret) check.
> Why not drop the goto and just
> return some error code. Same for the goto out up above.
Actually yes, because we don't do anything special in goto now. But it
required more (unrelated) code changes, plus I didn't wanted to break
the 'return from single place' rule for this function, in case we
really need to free some resource or undo some work from the goto
place.
But if you suggest/insist, then I will do it in a separate patch.
--
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/
[toc] | [prev] | [next] | [standalone]
| From | Stephen Boyd <sboyd@codeaurora.org> |
|---|---|
| Date | 2015-08-11 02:40 +0200 |
| Message-ID | <pW5LI-5JT-1@gated-at.bofh.it> |
| In reply to | #1204648 |
On 08/10/2015 05:23 PM, Viresh Kumar wrote:
> On 10-08-15, 12:23, Stephen Boyd wrote:
>>
>>> ---
>>> drivers/base/power/opp.c | 21 ++++++++++-----------
>>> 1 file changed, 10 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
>>> index 1daaa1a418a2..c9747fb192b1 100644
>>> --- a/drivers/base/power/opp.c
>>> +++ b/drivers/base/power/opp.c
>>> @@ -1295,20 +1295,19 @@ static int _of_init_opp_table_v2(struct device *dev,
>>> if (WARN_ON(!count))
>>> goto out;
>>>
>>> - if (!ret) {
>>> - if (!dev_opp) {
>>> - dev_opp = _find_device_opp(dev);
>>> - if (WARN_ON(!dev_opp))
>>> - goto out;
>>> - }
>>> -
>>> - dev_opp->np = opp_np;
>>> - dev_opp->shared_opp = of_property_read_bool(opp_np,
>>> - "opp-shared");
>>> - } else {
>>> + if (ret) {
>>> of_free_opp_table(dev);
>>> + goto out;
>>> }
>>>
>>> + dev_opp = _find_device_opp(dev);
>>> + if (WARN_ON(!dev_opp))
>>> + goto out;
>> Doesn't ret = 0 in this case?
> Because ret is already 0, juse see the above if (ret) check.
So ret is 0. I thought it was an error path, but I guess this is a
warning path and we return 0 still?
>
>> Why not drop the goto and just
>> return some error code. Same for the goto out up above.
> Actually yes, because we don't do anything special in goto now. But it
> required more (unrelated) code changes, plus I didn't wanted to break
> the 'return from single place' rule for this function, in case we
> really need to free some resource or undo some work from the goto
> place.
>
> But if you suggest/insist, then I will do it in a separate patch.
I am not insisting anything. But another patch to get rid of the goto
sounds fine.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
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/
[toc] | [prev] | [next] | [standalone]
| From | Viresh Kumar <viresh.kumar@linaro.org> |
|---|---|
| Date | 2015-08-11 04:30 +0200 |
| Message-ID | <pW7u9-8lO-3@gated-at.bofh.it> |
| In reply to | #1204649 |
On 10-08-15, 17:31, Stephen Boyd wrote:
> So ret is 0. I thought it was an error path, but I guess this is a
> warning path and we return 0 still?
Urg ..
-------------------------8<-------------------------
Message-Id: <d0e8a9cd6b0fb38fa946cb6274f258d7aa66c00e.1439259818.git.viresh.kumar@linaro.org>
From: Viresh Kumar <viresh.kumar@linaro.org>
Date: Tue, 4 Aug 2015 11:57:36 +0530
Subject: [PATCH] PM / OPP: restructure _of_init_opp_table_v2()
'dev_opp' will always be NULL in _of_init_opp_table_v2() after creating
OPPs for a device. There is no point comparing it against NULL there.
Restructure code a bit to make it more efficient.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/base/power/opp.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index 1daaa1a418a2..f42e098b71fe 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -1295,20 +1295,21 @@ static int _of_init_opp_table_v2(struct device *dev,
if (WARN_ON(!count))
goto out;
- if (!ret) {
- if (!dev_opp) {
- dev_opp = _find_device_opp(dev);
- if (WARN_ON(!dev_opp))
- goto out;
- }
-
- dev_opp->np = opp_np;
- dev_opp->shared_opp = of_property_read_bool(opp_np,
- "opp-shared");
- } else {
+ if (ret) {
of_free_opp_table(dev);
+ goto out;
}
+ dev_opp = _find_device_opp(dev);
+ if (WARN_ON(!dev_opp)) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ dev_opp->np = opp_np;
+ dev_opp->shared_opp = of_property_read_bool(opp_np,
+ "opp-shared");
+
out:
return ret;
}
--
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/
[toc] | [prev] | [next] | [standalone]
| From | Stephen Boyd <sboyd@codeaurora.org> |
|---|---|
| Date | 2015-08-11 08:10 +0200 |
| Message-ID | <pWaV3-4VF-5@gated-at.bofh.it> |
| In reply to | #1204698 |
On 08/11, Viresh Kumar wrote: > On 10-08-15, 17:31, Stephen Boyd wrote: > > So ret is 0. I thought it was an error path, but I guess this is a > > warning path and we return 0 still? > > Urg .. Oh I see this is an existing problem... Same problem goes for the count check. It may be better to fix those two cases first and then do this cleanup. But I don't mind either way. > > -------------------------8<------------------------- > > Message-Id: <d0e8a9cd6b0fb38fa946cb6274f258d7aa66c00e.1439259818.git.viresh.kumar@linaro.org> > From: Viresh Kumar <viresh.kumar@linaro.org> > Date: Tue, 4 Aug 2015 11:57:36 +0530 > Subject: [PATCH] PM / OPP: restructure _of_init_opp_table_v2() > > 'dev_opp' will always be NULL in _of_init_opp_table_v2() after creating > OPPs for a device. There is no point comparing it against NULL there. > > Restructure code a bit to make it more efficient. > > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> > --- Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project -- 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/
[toc] | [prev] | [next] | [standalone]
| From | Viresh Kumar <viresh.kumar@linaro.org> |
|---|---|
| Date | 2015-08-11 09:00 +0200 |
| Message-ID | <pWbHr-5QC-9@gated-at.bofh.it> |
| In reply to | #1204768 |
On 10-08-15, 23:08, Stephen Boyd wrote:
> On 08/11, Viresh Kumar wrote:
> > On 10-08-15, 17:31, Stephen Boyd wrote:
> > > So ret is 0. I thought it was an error path, but I guess this is a
> > > warning path and we return 0 still?
> >
> > Urg ..
>
> Oh I see this is an existing problem... Same problem goes for the
> count check. It may be better to fix those two cases first and
> then do this cleanup. But I don't mind either way.
-------------------------8<-------------------------
Message-Id: <b2d2d842165ec1748a56ecc03b85bd89321a644b.1439276231.git.viresh.kumar@linaro.org>
From: Viresh Kumar <viresh.kumar@linaro.org>
Date: Tue, 11 Aug 2015 12:22:07 +0530
Subject: [PATCH] PM / OPP: Return proper errors on failure
We are returning 0 by mistake, fix it.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/base/power/opp.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index 1daaa1a418a2..be3356a3a452 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -1292,14 +1292,18 @@ static int _of_init_opp_table_v2(struct device *dev,
}
/* There should be one of more OPP defined */
- if (WARN_ON(!count))
+ if (WARN_ON(!count)) {
+ ret = -ENOENT;
goto out;
+ }
if (!ret) {
if (!dev_opp) {
dev_opp = _find_device_opp(dev);
- if (WARN_ON(!dev_opp))
+ if (WARN_ON(!dev_opp)) {
+ ret = -ENOENT;
goto out;
+ }
}
dev_opp->np = opp_np;
--
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/
[toc] | [prev] | [next] | [standalone]
| From | Viresh Kumar <viresh.kumar@linaro.org> |
|---|---|
| Date | 2015-08-11 10:40 +0200 |
| Message-ID | <pWdge-8dF-9@gated-at.bofh.it> |
| In reply to | #1204826 |
On 11-08-15, 12:27, Viresh Kumar wrote:
> diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
> index 1daaa1a418a2..be3356a3a452 100644
> --- a/drivers/base/power/opp.c
> +++ b/drivers/base/power/opp.c
> @@ -1292,14 +1292,18 @@ static int _of_init_opp_table_v2(struct device *dev,
> }
>
> /* There should be one of more OPP defined */
> - if (WARN_ON(!count))
> + if (WARN_ON(!count)) {
> + ret = -ENOENT;
> goto out;
> + }
>
> if (!ret) {
> if (!dev_opp) {
> dev_opp = _find_device_opp(dev);
> - if (WARN_ON(!dev_opp))
> + if (WARN_ON(!dev_opp)) {
Dan also reported that !dev_opp isn't enough as we need to use IS_ERR
here.
We have got enough updates here, let me resend the series again to get
more reviews on proper patches.
--
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/
[toc] | [prev] | [next] | [standalone]
| From | Viresh Kumar <viresh.kumar@linaro.org> |
|---|---|
| Date | 2015-08-11 04:40 +0200 |
| Message-ID | <pW7DP-5l-5@gated-at.bofh.it> |
| In reply to | #1204649 |
On 10-08-15, 17:31, Stephen Boyd wrote:
> I am not insisting anything. But another patch to get rid of the
> goto sounds fine.
The separate patch to kill goto.
---------------------8<-------------------------
Message-Id: <9f9b9ea6ea3685d5f71c132e7efb18917253961f.1439260355.git.viresh.kumar@linaro.org>
From: Viresh Kumar <viresh.kumar@linaro.org>
Date: Tue, 11 Aug 2015 08:01:01 +0530
Subject: [PATCH] PM / OPP: Remove unnecessary goto statements
The code simply returns after jumping to the out label and doesn't free
any resources, etc.
Kill the unnecessary goto statements.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/base/power/opp.c | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index f42e098b71fe..220e8d77e2c4 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -1269,14 +1269,14 @@ static int _of_init_opp_table_v2(struct device *dev,
{
struct device_node *np;
struct device_opp *dev_opp;
- int ret = 0, count = 0;
+ int ret, count = 0;
dev_opp = _managed_opp(opp_np);
if (dev_opp) {
/* OPPs are already managed */
if (!_add_list_dev(dev, dev_opp))
- ret = -ENOMEM;
- goto out;
+ return -ENOMEM;
+ return 0;
}
/* We have opp-list node now, iterate over it and add OPPs */
@@ -1287,31 +1287,24 @@ static int _of_init_opp_table_v2(struct device *dev,
if (ret) {
dev_err(dev, "%s: Failed to add OPP, %d\n", __func__,
ret);
- break;
+ of_free_opp_table(dev);
+ return ret;
}
}
/* There should be one of more OPP defined */
if (WARN_ON(!count))
- goto out;
-
- if (ret) {
- of_free_opp_table(dev);
- goto out;
- }
+ return -ENOENT;
dev_opp = _find_device_opp(dev);
- if (WARN_ON(!dev_opp)) {
- ret = -EINVAL;
- goto out;
- }
+ if (WARN_ON(!dev_opp))
+ return -EINVAL;
dev_opp->np = opp_np;
dev_opp->shared_opp = of_property_read_bool(opp_np,
"opp-shared");
-out:
- return ret;
+ return 0;
}
/* Initializes OPP tables based on old-deprecated bindings */
--
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/
[toc] | [prev] | [next] | [standalone]
| From | Stephen Boyd <sboyd@codeaurora.org> |
|---|---|
| Date | 2015-08-11 08:10 +0200 |
| Message-ID | <pWaV4-4VF-13@gated-at.bofh.it> |
| In reply to | #1204702 |
On 08/11, Viresh Kumar wrote: > On 10-08-15, 17:31, Stephen Boyd wrote: > > I am not insisting anything. But another patch to get rid of the > > goto sounds fine. > > The separate patch to kill goto. > > ---------------------8<------------------------- > > Message-Id: <9f9b9ea6ea3685d5f71c132e7efb18917253961f.1439260355.git.viresh.kumar@linaro.org> > From: Viresh Kumar <viresh.kumar@linaro.org> > Date: Tue, 11 Aug 2015 08:01:01 +0530 > Subject: [PATCH] PM / OPP: Remove unnecessary goto statements > > The code simply returns after jumping to the out label and doesn't free > any resources, etc. > > Kill the unnecessary goto statements. > > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project -- 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/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web