linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers/clocksource/dw_apb_timer_of: fixed probe failure
@ 2021-11-09 15:34 Alexey Sheplyakov
  2021-12-06 15:25 ` Dinh Nguyen
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alexey Sheplyakov @ 2021-11-09 15:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Alexey Sheplyakov, Vadim V . Vlasov, Daniel Lezcano, Dinh Nguyen,
	Thomas Gleixner

The driver refuses to probe with -EINVAL since the commit
5d9814df0aec ("clocksource/drivers/dw_apb_timer_of: Add error handling if no clock available").

Before the driver used to probe successfully if either
"clock-freq" or "clock-frequency" properties has been specified
in the device tree.

That commit changed

if (A && B)
	panic("No clock nor clock-frequency property");

into

if (!A && !B)
	return 0;

That's a bug: the reverse of `A && B` is '!A || !B', not '!A && !B'

Signed-off-by: Vadim V. Vlasov <vadim.vlasov@elpitech.ru>
Signed-off-by: Alexey Sheplyakov <asheplyakov@basealt.ru>
Fixes: 5d9814df0aec56a6 ("clocksource/drivers/dw_apb_timer_of: Add error handling if no clock available").
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vadim V. Vlasov <vadim.vlasov@elpitech.ru>
---
 drivers/clocksource/dw_apb_timer_of.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/dw_apb_timer_of.c b/drivers/clocksource/dw_apb_timer_of.c
index 3819ef5b7098..3245eb0c602d 100644
--- a/drivers/clocksource/dw_apb_timer_of.c
+++ b/drivers/clocksource/dw_apb_timer_of.c
@@ -47,7 +47,7 @@ static int __init timer_get_base_and_rate(struct device_node *np,
 			pr_warn("pclk for %pOFn is present, but could not be activated\n",
 				np);
 
-	if (!of_property_read_u32(np, "clock-freq", rate) &&
+	if (!of_property_read_u32(np, "clock-freq", rate) ||
 	    !of_property_read_u32(np, "clock-frequency", rate))
 		return 0;
 
-- 
2.30.2


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

* Re: [PATCH] drivers/clocksource/dw_apb_timer_of: fixed probe failure
  2021-11-09 15:34 [PATCH] drivers/clocksource/dw_apb_timer_of: fixed probe failure Alexey Sheplyakov
@ 2021-12-06 15:25 ` Dinh Nguyen
  2021-12-06 15:39 ` Daniel Lezcano
  2021-12-11 13:05 ` [tip: timers/urgent] clocksource/drivers/dw_apb_timer_of: Fix " tip-bot2 for Alexey Sheplyakov
  2 siblings, 0 replies; 4+ messages in thread
From: Dinh Nguyen @ 2021-12-06 15:25 UTC (permalink / raw)
  To: Alexey Sheplyakov, linux-kernel
  Cc: Vadim V . Vlasov, Daniel Lezcano, Thomas Gleixner



On 11/9/21 9:34 AM, Alexey Sheplyakov wrote:
> The driver refuses to probe with -EINVAL since the commit
> 5d9814df0aec ("clocksource/drivers/dw_apb_timer_of: Add error handling if no clock available").
> 
> Before the driver used to probe successfully if either
> "clock-freq" or "clock-frequency" properties has been specified
> in the device tree.
> 
> That commit changed
> 
> if (A && B)
> 	panic("No clock nor clock-frequency property");
> 
> into
> 
> if (!A && !B)
> 	return 0;
> 
> That's a bug: the reverse of `A && B` is '!A || !B', not '!A && !B'
> 
> Signed-off-by: Vadim V. Vlasov <vadim.vlasov@elpitech.ru>
> Signed-off-by: Alexey Sheplyakov <asheplyakov@basealt.ru>
> Fixes: 5d9814df0aec56a6 ("clocksource/drivers/dw_apb_timer_of: Add error handling if no clock available").
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Dinh Nguyen <dinguyen@kernel.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Vadim V. Vlasov <vadim.vlasov@elpitech.ru>
> ---
>   drivers/clocksource/dw_apb_timer_of.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clocksource/dw_apb_timer_of.c b/drivers/clocksource/dw_apb_timer_of.c
> index 3819ef5b7098..3245eb0c602d 100644
> --- a/drivers/clocksource/dw_apb_timer_of.c
> +++ b/drivers/clocksource/dw_apb_timer_of.c
> @@ -47,7 +47,7 @@ static int __init timer_get_base_and_rate(struct device_node *np,
>   			pr_warn("pclk for %pOFn is present, but could not be activated\n",
>   				np);
>   
> -	if (!of_property_read_u32(np, "clock-freq", rate) &&
> +	if (!of_property_read_u32(np, "clock-freq", rate) ||
>   	    !of_property_read_u32(np, "clock-frequency", rate))
>   		return 0;
>   
> 

Acked-by: Dinh Nguyen <dinguyen@kernel.org>

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

* Re: [PATCH] drivers/clocksource/dw_apb_timer_of: fixed probe failure
  2021-11-09 15:34 [PATCH] drivers/clocksource/dw_apb_timer_of: fixed probe failure Alexey Sheplyakov
  2021-12-06 15:25 ` Dinh Nguyen
@ 2021-12-06 15:39 ` Daniel Lezcano
  2021-12-11 13:05 ` [tip: timers/urgent] clocksource/drivers/dw_apb_timer_of: Fix " tip-bot2 for Alexey Sheplyakov
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Lezcano @ 2021-12-06 15:39 UTC (permalink / raw)
  To: Alexey Sheplyakov, linux-kernel
  Cc: Vadim V . Vlasov, Dinh Nguyen, Thomas Gleixner

On 09/11/2021 16:34, Alexey Sheplyakov wrote:
> The driver refuses to probe with -EINVAL since the commit
> 5d9814df0aec ("clocksource/drivers/dw_apb_timer_of: Add error handling if no clock available").
> 
> Before the driver used to probe successfully if either
> "clock-freq" or "clock-frequency" properties has been specified
> in the device tree.
> 
> That commit changed
> 
> if (A && B)
> 	panic("No clock nor clock-frequency property");
> 
> into
> 
> if (!A && !B)
> 	return 0;
> 
> That's a bug: the reverse of `A && B` is '!A || !B', not '!A && !B'
> 
> Signed-off-by: Vadim V. Vlasov <vadim.vlasov@elpitech.ru>
> Signed-off-by: Alexey Sheplyakov <asheplyakov@basealt.ru>
> Fixes: 5d9814df0aec56a6 ("clocksource/drivers/dw_apb_timer_of: Add error handling if no clock available").
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: Dinh Nguyen <dinguyen@kernel.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Vadim V. Vlasov <vadim.vlasov@elpitech.ru>
> ---

Applied, thanks

>  drivers/clocksource/dw_apb_timer_of.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clocksource/dw_apb_timer_of.c b/drivers/clocksource/dw_apb_timer_of.c
> index 3819ef5b7098..3245eb0c602d 100644
> --- a/drivers/clocksource/dw_apb_timer_of.c
> +++ b/drivers/clocksource/dw_apb_timer_of.c
> @@ -47,7 +47,7 @@ static int __init timer_get_base_and_rate(struct device_node *np,
>  			pr_warn("pclk for %pOFn is present, but could not be activated\n",
>  				np);
>  
> -	if (!of_property_read_u32(np, "clock-freq", rate) &&
> +	if (!of_property_read_u32(np, "clock-freq", rate) ||
>  	    !of_property_read_u32(np, "clock-frequency", rate))
>  		return 0;
>  
> 


-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

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

* [tip: timers/urgent] clocksource/drivers/dw_apb_timer_of: Fix probe failure
  2021-11-09 15:34 [PATCH] drivers/clocksource/dw_apb_timer_of: fixed probe failure Alexey Sheplyakov
  2021-12-06 15:25 ` Dinh Nguyen
  2021-12-06 15:39 ` Daniel Lezcano
@ 2021-12-11 13:05 ` tip-bot2 for Alexey Sheplyakov
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Alexey Sheplyakov @ 2021-12-11 13:05 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Vadim V. Vlasov, Alexey Sheplyakov, Daniel Lezcano, Dinh Nguyen,
	Thomas Gleixner, x86, linux-kernel

The following commit has been merged into the timers/urgent branch of tip:

Commit-ID:     a663bd19114d79f0902e2490fc484e5a7419cdc2
Gitweb:        https://git.kernel.org/tip/a663bd19114d79f0902e2490fc484e5a7419cdc2
Author:        Alexey Sheplyakov <asheplyakov@basealt.ru>
AuthorDate:    Tue, 09 Nov 2021 19:34:02 +04:00
Committer:     Daniel Lezcano <daniel.lezcano@linaro.org>
CommitterDate: Fri, 10 Dec 2021 17:46:54 +01:00

clocksource/drivers/dw_apb_timer_of: Fix probe failure

The driver refuses to probe with -EINVAL since the commit 5d9814df0aec
("clocksource/drivers/dw_apb_timer_of: Add error handling if no clock
available").

Before the driver used to probe successfully if either "clock-freq" or
"clock-frequency" properties has been specified in the device tree.

That commit changed

if (A && B)
	panic("No clock nor clock-frequency property");

into

if (!A && !B)
	return 0;

That's a bug: the reverse of `A && B` is '!A || !B', not '!A && !B'

Signed-off-by: Vadim V. Vlasov <vadim.vlasov@elpitech.ru>
Signed-off-by: Alexey Sheplyakov <asheplyakov@basealt.ru>
Fixes: 5d9814df0aec56a6 ("clocksource/drivers/dw_apb_timer_of: Add error handling if no clock available").
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vadim V. Vlasov <vadim.vlasov@elpitech.ru>
Acked-by: Dinh Nguyen <dinguyen@kernel.org>
Link: https://lore.kernel.org/r/20211109153401.157491-1-asheplyakov@basealt.ru
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/clocksource/dw_apb_timer_of.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/dw_apb_timer_of.c b/drivers/clocksource/dw_apb_timer_of.c
index 3819ef5..3245eb0 100644
--- a/drivers/clocksource/dw_apb_timer_of.c
+++ b/drivers/clocksource/dw_apb_timer_of.c
@@ -47,7 +47,7 @@ static int __init timer_get_base_and_rate(struct device_node *np,
 			pr_warn("pclk for %pOFn is present, but could not be activated\n",
 				np);
 
-	if (!of_property_read_u32(np, "clock-freq", rate) &&
+	if (!of_property_read_u32(np, "clock-freq", rate) ||
 	    !of_property_read_u32(np, "clock-frequency", rate))
 		return 0;
 

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

end of thread, other threads:[~2021-12-11 13:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-09 15:34 [PATCH] drivers/clocksource/dw_apb_timer_of: fixed probe failure Alexey Sheplyakov
2021-12-06 15:25 ` Dinh Nguyen
2021-12-06 15:39 ` Daniel Lezcano
2021-12-11 13:05 ` [tip: timers/urgent] clocksource/drivers/dw_apb_timer_of: Fix " tip-bot2 for Alexey Sheplyakov

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).