diff mbox series

[v5,3/5] platform/chrome: cros_ec: determine `wake_enabled` in cros_ec_suspend()

Message ID 20220216080306.3864163-4-tzungbi@google.com (mailing list archive)
State Accepted
Commit 9fbe967d4e6e017c85c94aead6a1310b5f77db9a
Headers show
Series platform/chrome: cros_ec: miscellaneous cleanups | expand

Commit Message

Tzung-Bi Shih Feb. 16, 2022, 8:03 a.m. UTC
`wake_enabled` indicates cros_ec_resume() needs to call
disable_irq_wake() to undo enable_irq_wake() in cros_ec_suspend().

Determine `wake_enabled` in cros_ec_suspend() instead of
reset-after-used in cros_ec_resume().

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
Changes from v4:
(https://patchwork.kernel.org/project/chrome-platform/patch/20220216043639.3839185-4-tzungbi@google.com/)
- Undo changes from v3; rollback to v2.

Changes from v3:
(https://patchwork.kernel.org/project/chrome-platform/patch/20220209095703.517608-4-tzungbi@google.com/)
- Change the patch title.
- Simplify by initializing wake_enabled in cros_ec_register().

No changes from v2.

Changes from v1:
(https://lore.kernel.org/lkml/20220125101527.1812887-1-tzungbi@google.com/T/#u)
- Use imperative mood in commit message.

 drivers/platform/chrome/cros_ec.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Prashant Malani Feb. 17, 2022, 2:21 a.m. UTC | #1
On Feb 16 16:03, Tzung-Bi Shih wrote:
> `wake_enabled` indicates cros_ec_resume() needs to call
> disable_irq_wake() to undo enable_irq_wake() in cros_ec_suspend().
> 
> Determine `wake_enabled` in cros_ec_suspend() instead of
> reset-after-used in cros_ec_resume().
> 
> Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>

I don't see what is the issue with reset-after-use here, as long as the
variable is initialized correctly. This patch strikes me as larger than
it really needs to me. Anyway, FWIW:

Reviewed-by: Prashant Malani <pmalani@chromiu.org>

> ---
> Changes from v4:
> (https://patchwork.kernel.org/project/chrome-platform/patch/20220216043639.3839185-4-tzungbi@google.com/)
> - Undo changes from v3; rollback to v2.
> 
> Changes from v3:
> (https://patchwork.kernel.org/project/chrome-platform/patch/20220209095703.517608-4-tzungbi@google.com/)
> - Change the patch title.
> - Simplify by initializing wake_enabled in cros_ec_register().
> 
> No changes from v2.
> 
> Changes from v1:
> (https://lore.kernel.org/lkml/20220125101527.1812887-1-tzungbi@google.com/T/#u)
> - Use imperative mood in commit message.
> 
>  drivers/platform/chrome/cros_ec.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/platform/chrome/cros_ec.c b/drivers/platform/chrome/cros_ec.c
> index 25cd8df6e7b0..a013fbceeb03 100644
> --- a/drivers/platform/chrome/cros_ec.c
> +++ b/drivers/platform/chrome/cros_ec.c
> @@ -342,6 +342,8 @@ int cros_ec_suspend(struct cros_ec_device *ec_dev)
>  
>  	if (device_may_wakeup(dev))
>  		ec_dev->wake_enabled = !enable_irq_wake(ec_dev->irq);
> +	else
> +		ec_dev->wake_enabled = false;
>  
>  	disable_irq(ec_dev->irq);
>  	ec_dev->suspended = true;
> @@ -383,10 +385,9 @@ int cros_ec_resume(struct cros_ec_device *ec_dev)
>  		dev_dbg(ec_dev->dev, "Error %d sending resume event to ec",
>  			ret);
>  
> -	if (ec_dev->wake_enabled) {
> +	if (ec_dev->wake_enabled)
>  		disable_irq_wake(ec_dev->irq);
> -		ec_dev->wake_enabled = 0;
> -	}
> +
>  	/*
>  	 * Let the mfd devices know about events that occur during
>  	 * suspend. This way the clients know what to do with them.
> -- 
> 2.35.1.265.g69c8d7142f-goog
>
diff mbox series

Patch

diff --git a/drivers/platform/chrome/cros_ec.c b/drivers/platform/chrome/cros_ec.c
index 25cd8df6e7b0..a013fbceeb03 100644
--- a/drivers/platform/chrome/cros_ec.c
+++ b/drivers/platform/chrome/cros_ec.c
@@ -342,6 +342,8 @@  int cros_ec_suspend(struct cros_ec_device *ec_dev)
 
 	if (device_may_wakeup(dev))
 		ec_dev->wake_enabled = !enable_irq_wake(ec_dev->irq);
+	else
+		ec_dev->wake_enabled = false;
 
 	disable_irq(ec_dev->irq);
 	ec_dev->suspended = true;
@@ -383,10 +385,9 @@  int cros_ec_resume(struct cros_ec_device *ec_dev)
 		dev_dbg(ec_dev->dev, "Error %d sending resume event to ec",
 			ret);
 
-	if (ec_dev->wake_enabled) {
+	if (ec_dev->wake_enabled)
 		disable_irq_wake(ec_dev->irq);
-		ec_dev->wake_enabled = 0;
-	}
+
 	/*
 	 * Let the mfd devices know about events that occur during
 	 * suspend. This way the clients know what to do with them.