linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: Fix phase init check
@ 2020-02-25 13:42 Maxime Ripard
  2020-02-25 16:56 ` Stephen Boyd
  2020-02-28 18:57 ` Stephen Boyd
  0 siblings, 2 replies; 3+ messages in thread
From: Maxime Ripard @ 2020-02-25 13:42 UTC (permalink / raw)
  To: Mike Turquette, Stephen Boyd; +Cc: linux-clk, Maxime Ripard

Commit 2760878662a2 ("clk: Bail out when calculating phase fails during clk
registration") introduced a check on error values at the time the clock is
registered to bail out when such an error occurs.

However, it doesn't check whether the returned value is positive which will
happen if the driver returns a non-zero phase, and ends up returning that
to the caller on success, breaking the API that implies that the driver
should return 0 on success.

Fixes: 2760878662a2 ("clk: Bail out when calculating phase fails during clk registration")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/clk/clk.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index ebfc1e2103cb..f122e9911b57 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3344,6 +3344,7 @@ static int __clk_core_init(struct clk_core *core)
 	int ret;
 	struct clk_core *parent;
 	unsigned long rate;
+	int phase;
 
 	if (!core)
 		return -EINVAL;
@@ -3457,8 +3458,9 @@ static int __clk_core_init(struct clk_core *core)
 	 * Since a phase is by definition relative to its parent, just
 	 * query the current clock phase, or just assume it's in phase.
 	 */
-	ret = clk_core_get_phase(core);
-	if (ret < 0) {
+	phase = clk_core_get_phase(core);
+	if (phase < 0) {
+		ret = phase;
 		pr_warn("%s: Failed to get phase for clk '%s'\n", __func__,
 			core->name);
 		goto out;
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk: Fix phase init check
  2020-02-25 13:42 [PATCH] clk: Fix phase init check Maxime Ripard
@ 2020-02-25 16:56 ` Stephen Boyd
  2020-02-28 18:57 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2020-02-25 16:56 UTC (permalink / raw)
  To: Maxime Ripard, Mike Turquette, Stephen Boyd; +Cc: linux-clk, Maxime Ripard

Quoting Maxime Ripard (2020-02-25 05:42:48)
> Commit 2760878662a2 ("clk: Bail out when calculating phase fails during clk
> registration") introduced a check on error values at the time the clock is
> registered to bail out when such an error occurs.
> 
> However, it doesn't check whether the returned value is positive which will
> happen if the driver returns a non-zero phase, and ends up returning that
> to the caller on success, breaking the API that implies that the driver
> should return 0 on success.

I had to read this a few times to understand. I'll reword it to indicate
that __clk_core_init() should return 0 on success and not the phase
which is typically a positive value.

> 
> Fixes: 2760878662a2 ("clk: Bail out when calculating phase fails during clk registration")
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>

Thanks. I think we need a 

Reported-by: "kernelci.org bot" <bot@kernelci.org>

tag added as well.

> ---
>  drivers/clk/clk.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index ebfc1e2103cb..f122e9911b57 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -3344,6 +3344,7 @@ static int __clk_core_init(struct clk_core *core)
>         int ret;
>         struct clk_core *parent;
>         unsigned long rate;
> +       int phase;
>  
>         if (!core)
>                 return -EINVAL;
> @@ -3457,8 +3458,9 @@ static int __clk_core_init(struct clk_core *core)
>          * Since a phase is by definition relative to its parent, just
>          * query the current clock phase, or just assume it's in phase.
>          */
> -       ret = clk_core_get_phase(core);
> -       if (ret < 0) {
> +       phase = clk_core_get_phase(core);
> +       if (phase < 0) {
> +               ret = phase;
>                 pr_warn("%s: Failed to get phase for clk '%s'\n", __func__,
>                         core->name);
>                 goto out;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk: Fix phase init check
  2020-02-25 13:42 [PATCH] clk: Fix phase init check Maxime Ripard
  2020-02-25 16:56 ` Stephen Boyd
@ 2020-02-28 18:57 ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2020-02-28 18:57 UTC (permalink / raw)
  To: Maxime Ripard, Mike Turquette, Stephen Boyd; +Cc: linux-clk, Maxime Ripard

Quoting Maxime Ripard (2020-02-25 05:42:48)
> Commit 2760878662a2 ("clk: Bail out when calculating phase fails during clk
> registration") introduced a check on error values at the time the clock is
> registered to bail out when such an error occurs.
> 
> However, it doesn't check whether the returned value is positive which will
> happen if the driver returns a non-zero phase, and ends up returning that
> to the caller on success, breaking the API that implies that the driver
> should return 0 on success.
> 
> Fixes: 2760878662a2 ("clk: Bail out when calculating phase fails during clk registration")
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Applied to clk-next

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-28 18:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-25 13:42 [PATCH] clk: Fix phase init check Maxime Ripard
2020-02-25 16:56 ` Stephen Boyd
2020-02-28 18:57 ` 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).