[PATCH] powercap: idle_inject: Simplify if condition

Thorsten Blum posted 1 patch 1 year, 8 months ago
drivers/powercap/idle_inject.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] powercap: idle_inject: Simplify if condition
Posted by Thorsten Blum 1 year, 8 months ago
The if condition !A || A && B can be simplified to !A || B.

Fixes the following Coccinelle/coccicheck warning reported by
excluded_middle.cocci:

	WARNING !A || A && B is equivalent to !A || B

Compile-tested only.

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
 drivers/powercap/idle_inject.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/powercap/idle_inject.c b/drivers/powercap/idle_inject.c
index e18a2cc4e46a..bafc59904ed3 100644
--- a/drivers/powercap/idle_inject.c
+++ b/drivers/powercap/idle_inject.c
@@ -127,7 +127,7 @@ static enum hrtimer_restart idle_inject_timer_fn(struct hrtimer *timer)
 	struct idle_inject_device *ii_dev =
 		container_of(timer, struct idle_inject_device, timer);
 
-	if (!ii_dev->update || (ii_dev->update && ii_dev->update()))
+	if (!ii_dev->update || ii_dev->update())
 		idle_inject_wakeup(ii_dev);
 
 	duration_us = READ_ONCE(ii_dev->run_duration_us);
-- 
2.39.2
Re: [PATCH] powercap: idle_inject: Simplify if condition
Posted by Rafael J. Wysocki 1 year, 8 months ago
On Wed, Jun 5, 2024 at 3:59 PM Thorsten Blum <thorsten.blum@toblux.com> wrote:
>
> The if condition !A || A && B can be simplified to !A || B.
>
> Fixes the following Coccinelle/coccicheck warning reported by
> excluded_middle.cocci:
>
>         WARNING !A || A && B is equivalent to !A || B
>
> Compile-tested only.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
> ---
>  drivers/powercap/idle_inject.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/powercap/idle_inject.c b/drivers/powercap/idle_inject.c
> index e18a2cc4e46a..bafc59904ed3 100644
> --- a/drivers/powercap/idle_inject.c
> +++ b/drivers/powercap/idle_inject.c
> @@ -127,7 +127,7 @@ static enum hrtimer_restart idle_inject_timer_fn(struct hrtimer *timer)
>         struct idle_inject_device *ii_dev =
>                 container_of(timer, struct idle_inject_device, timer);
>
> -       if (!ii_dev->update || (ii_dev->update && ii_dev->update()))
> +       if (!ii_dev->update || ii_dev->update())
>                 idle_inject_wakeup(ii_dev);
>
>         duration_us = READ_ONCE(ii_dev->run_duration_us);
> --

Applied as 6.11 material, thanks!