* [PATCH V2] opp: Don't ignore clk_get() errors other than -ENOENT
@ 2021-02-01 4:22 Viresh Kumar
2021-02-01 19:54 ` Dmitry Osipenko
2021-02-11 19:19 ` Stephen Boyd
0 siblings, 2 replies; 4+ messages in thread
From: Viresh Kumar @ 2021-02-01 4:22 UTC (permalink / raw)
To: Viresh Kumar, Nishanth Menon, Stephen Boyd
Cc: Viresh Kumar, linux-pm, Vincent Guittot, Rafael Wysocki,
Dmitry Osipenko, linux-kernel
Not all devices that need to use OPP core need to have clocks, a missing
clock is fine in which case -ENOENT shall be returned by clk_get().
Anything else is an error and must be handled properly.
Reported-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
V2:
- s/ENODEV/ENOENT
- Use dev_err_probe()
Stephen, is the understanding correct that -ENOENT is the only error
returned for missing clocks ?
drivers/opp/core.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index a518173fd64a..0beb3ee79523 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -1252,6 +1252,8 @@ static struct opp_table *_update_opp_table_clk(struct device *dev,
struct opp_table *opp_table,
bool getclk)
{
+ int ret;
+
/*
* Return early if we don't need to get clk or we have already tried it
* earlier.
@@ -1261,18 +1263,19 @@ static struct opp_table *_update_opp_table_clk(struct device *dev,
/* Find clk for the device */
opp_table->clk = clk_get(dev, NULL);
- if (IS_ERR(opp_table->clk)) {
- int ret = PTR_ERR(opp_table->clk);
- if (ret == -EPROBE_DEFER) {
- dev_pm_opp_put_opp_table(opp_table);
- return ERR_PTR(ret);
- }
+ ret = PTR_ERR_OR_ZERO(opp_table->clk);
+ if (!ret)
+ return opp_table;
+ if (ret == -ENOENT) {
dev_dbg(dev, "%s: Couldn't find clock: %d\n", __func__, ret);
+ return opp_table;
}
- return opp_table;
+ dev_pm_opp_put_opp_table(opp_table);
+
+ return ERR_PTR(dev_err_probe(dev, ret, "Couldn't find clock\n"));
}
/*
--
2.25.0.rc1.19.g042ed3e048af
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH V2] opp: Don't ignore clk_get() errors other than -ENOENT
2021-02-01 4:22 [PATCH V2] opp: Don't ignore clk_get() errors other than -ENOENT Viresh Kumar
@ 2021-02-01 19:54 ` Dmitry Osipenko
2021-02-02 4:35 ` Viresh Kumar
2021-02-11 19:19 ` Stephen Boyd
1 sibling, 1 reply; 4+ messages in thread
From: Dmitry Osipenko @ 2021-02-01 19:54 UTC (permalink / raw)
To: Viresh Kumar, Viresh Kumar, Nishanth Menon, Stephen Boyd
Cc: linux-pm, Vincent Guittot, Rafael Wysocki, linux-kernel
01.02.2021 07:22, Viresh Kumar пишет:
> Not all devices that need to use OPP core need to have clocks, a missing
> clock is fine in which case -ENOENT shall be returned by clk_get().
>
> Anything else is an error and must be handled properly.
>
> Reported-by: Dmitry Osipenko <digetx@gmail.com>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> V2:
> - s/ENODEV/ENOENT
> - Use dev_err_probe()
>
> Stephen, is the understanding correct that -ENOENT is the only error
> returned for missing clocks ?
>
> drivers/opp/core.c | 17 ++++++++++-------
> 1 file changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/opp/core.c b/drivers/opp/core.c
> index a518173fd64a..0beb3ee79523 100644
> --- a/drivers/opp/core.c
> +++ b/drivers/opp/core.c
> @@ -1252,6 +1252,8 @@ static struct opp_table *_update_opp_table_clk(struct device *dev,
> struct opp_table *opp_table,
> bool getclk)
> {
> + int ret;
> +
> /*
> * Return early if we don't need to get clk or we have already tried it
> * earlier.
> @@ -1261,18 +1263,19 @@ static struct opp_table *_update_opp_table_clk(struct device *dev,
>
> /* Find clk for the device */
> opp_table->clk = clk_get(dev, NULL);
> - if (IS_ERR(opp_table->clk)) {
> - int ret = PTR_ERR(opp_table->clk);
>
> - if (ret == -EPROBE_DEFER) {
> - dev_pm_opp_put_opp_table(opp_table);
> - return ERR_PTR(ret);
> - }
> + ret = PTR_ERR_OR_ZERO(opp_table->clk);
> + if (!ret)
> + return opp_table;
>
> + if (ret == -ENOENT) {
> dev_dbg(dev, "%s: Couldn't find clock: %d\n", __func__, ret);
> + return opp_table;
> }
>
> - return opp_table;
> + dev_pm_opp_put_opp_table(opp_table);
> +
> + return ERR_PTR(dev_err_probe(dev, ret, "Couldn't find clock\n"));
> }
>
> /*
>
Thanks, looks okay.
Although, I think the previous variant of coding style was a bit more appropriate, i.e. like this:
dev_err_probe(dev, "%s: Couldn't find clock: %d\n", __func__, ret);
return ERR_PTR(ret);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2] opp: Don't ignore clk_get() errors other than -ENOENT
2021-02-01 19:54 ` Dmitry Osipenko
@ 2021-02-02 4:35 ` Viresh Kumar
0 siblings, 0 replies; 4+ messages in thread
From: Viresh Kumar @ 2021-02-02 4:35 UTC (permalink / raw)
To: Dmitry Osipenko
Cc: Viresh Kumar, Nishanth Menon, Stephen Boyd, linux-pm,
Vincent Guittot, Rafael Wysocki, linux-kernel
On 01-02-21, 22:54, Dmitry Osipenko wrote:
> Thanks, looks okay.
>
> Although, I think the previous variant of coding style was a bit more appropriate, i.e. like this:
>
> dev_err_probe(dev, "%s: Couldn't find clock: %d\n", __func__, ret);
>
> return ERR_PTR(ret);
Okay will move to that.
--
viresh
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2] opp: Don't ignore clk_get() errors other than -ENOENT
2021-02-01 4:22 [PATCH V2] opp: Don't ignore clk_get() errors other than -ENOENT Viresh Kumar
2021-02-01 19:54 ` Dmitry Osipenko
@ 2021-02-11 19:19 ` Stephen Boyd
1 sibling, 0 replies; 4+ messages in thread
From: Stephen Boyd @ 2021-02-11 19:19 UTC (permalink / raw)
To: Nishanth Menon, Viresh Kumar, Viresh Kumar
Cc: Viresh Kumar, linux-pm, Vincent Guittot, Rafael Wysocki,
Dmitry Osipenko, linux-kernel
Quoting Viresh Kumar (2021-01-31 20:22:58)
> Not all devices that need to use OPP core need to have clocks, a missing
> clock is fine in which case -ENOENT shall be returned by clk_get().
>
> Anything else is an error and must be handled properly.
>
> Reported-by: Dmitry Osipenko <digetx@gmail.com>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> V2:
> - s/ENODEV/ENOENT
> - Use dev_err_probe()
>
> Stephen, is the understanding correct that -ENOENT is the only error
> returned for missing clocks ?
Yeah pretty much. See clk_get_optional().
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-02-11 19:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-01 4:22 [PATCH V2] opp: Don't ignore clk_get() errors other than -ENOENT Viresh Kumar
2021-02-01 19:54 ` Dmitry Osipenko
2021-02-02 4:35 ` Viresh Kumar
2021-02-11 19:19 ` Stephen Boyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).