2022-01-25 14:44:55

by Tzung-Bi Shih

[permalink] [raw]
Subject: [PATCH 0/6] platform/chrome: cros_ec: miscellaneous cleanups

The 1st patch fixes unhandled undos in error handling path.

The rest of patches cleans drivers/platform/chrome/cros_ec.c.

Tzung-Bi Shih (6):
platform/chrome: cros_ec: fix error handling in cros_ec_register()
platform/chrome: cros_ec: remove unused variable `was_wake_device`
platform/chrome: cros_ec: determine `wake_enabled` in
cros_ec_suspend()
platform/chrome: cros_ec: don't initialize `err` in cros_ec_register()
platform/chrome: cros_ec: sort header inclusion alphabetically
platform/chrome: cros_ec: append newline to all logs

drivers/platform/chrome/cros_ec.c | 38 ++++++++++++---------
include/linux/platform_data/cros_ec_proto.h | 3 --
2 files changed, 21 insertions(+), 20 deletions(-)

--
2.35.0.rc0.227.g00780c9af4-goog


2022-01-25 14:45:08

by Tzung-Bi Shih

[permalink] [raw]
Subject: [PATCH 3/6] platform/chrome: cros_ec: determine `wake_enabled` in cros_ec_suspend()

`wake_enabled` indicates cros_ec_resume() needs to call
disable_irq_wake() to undo enable_irq_wake() in cros_ec_suspend().

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

Signed-off-by: Tzung-Bi Shih <[email protected]>
---
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 a37448f3e179..abbe71309e40 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.0.rc0.227.g00780c9af4-goog

2022-01-25 14:45:26

by Tzung-Bi Shih

[permalink] [raw]
Subject: [PATCH 4/6] platform/chrome: cros_ec: don't initialize `err` in cros_ec_register()

`err` in cros_ec_register() doesn't need to be initialized.

Signed-off-by: Tzung-Bi Shih <[email protected]>
---
drivers/platform/chrome/cros_ec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/chrome/cros_ec.c b/drivers/platform/chrome/cros_ec.c
index abbe71309e40..c2c7a748e48f 100644
--- a/drivers/platform/chrome/cros_ec.c
+++ b/drivers/platform/chrome/cros_ec.c
@@ -182,7 +182,7 @@ static int cros_ec_ready_event(struct notifier_block *nb,
int cros_ec_register(struct cros_ec_device *ec_dev)
{
struct device *dev = ec_dev->dev;
- int err = 0;
+ int err;

BLOCKING_INIT_NOTIFIER_HEAD(&ec_dev->event_notifier);

--
2.35.0.rc0.227.g00780c9af4-goog

2022-01-25 14:45:48

by Tzung-Bi Shih

[permalink] [raw]
Subject: [PATCH 5/6] platform/chrome: cros_ec: sort header inclusion alphabetically

Sorts header inclusion alphabetically.

Signed-off-by: Tzung-Bi Shih <[email protected]>
---
drivers/platform/chrome/cros_ec.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec.c b/drivers/platform/chrome/cros_ec.c
index c2c7a748e48f..934ab30c9d08 100644
--- a/drivers/platform/chrome/cros_ec.c
+++ b/drivers/platform/chrome/cros_ec.c
@@ -9,12 +9,12 @@
* battery charging and regulator control, firmware update.
*/

-#include <linux/of_platform.h>
#include <linux/interrupt.h>
-#include <linux/slab.h>
#include <linux/module.h>
+#include <linux/of_platform.h>
#include <linux/platform_data/cros_ec_commands.h>
#include <linux/platform_data/cros_ec_proto.h>
+#include <linux/slab.h>
#include <linux/suspend.h>

#include "cros_ec.h"
--
2.35.0.rc0.227.g00780c9af4-goog

2022-01-25 14:46:08

by Tzung-Bi Shih

[permalink] [raw]
Subject: [PATCH 6/6] platform/chrome: cros_ec: append newline to all logs

To be consistent, appends newline ("\n") to all logs.

Signed-off-by: Tzung-Bi Shih <[email protected]>
---
drivers/platform/chrome/cros_ec.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec.c b/drivers/platform/chrome/cros_ec.c
index 934ab30c9d08..679df6af5612 100644
--- a/drivers/platform/chrome/cros_ec.c
+++ b/drivers/platform/chrome/cros_ec.c
@@ -213,7 +213,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
IRQF_TRIGGER_LOW | IRQF_ONESHOT,
"chromeos-ec", ec_dev);
if (err) {
- dev_err(dev, "Failed to request IRQ %d: %d",
+ dev_err(dev, "Failed to request IRQ %d: %d\n",
ec_dev->irq, err);
return err;
}
@@ -264,7 +264,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
*/
err = cros_ec_sleep_event(ec_dev, 0);
if (err < 0)
- dev_dbg(ec_dev->dev, "Error %d clearing sleep event to ec",
+ dev_dbg(ec_dev->dev, "Error %d clearing sleep event to ec\n",
err);

if (ec_dev->mkbp_event_supported) {
@@ -337,7 +337,7 @@ int cros_ec_suspend(struct cros_ec_device *ec_dev)

ret = cros_ec_sleep_event(ec_dev, sleep_event);
if (ret < 0)
- dev_dbg(ec_dev->dev, "Error %d sending suspend event to ec",
+ dev_dbg(ec_dev->dev, "Error %d sending suspend event to ec\n",
ret);

if (device_may_wakeup(dev))
@@ -382,7 +382,7 @@ int cros_ec_resume(struct cros_ec_device *ec_dev)

ret = cros_ec_sleep_event(ec_dev, sleep_event);
if (ret < 0)
- dev_dbg(ec_dev->dev, "Error %d sending resume event to ec",
+ dev_dbg(ec_dev->dev, "Error %d sending resume event to ec\n",
ret);

if (ec_dev->wake_enabled)
--
2.35.0.rc0.227.g00780c9af4-goog