platform/chrome: cros_ec: miscellaneous cleanups
Subsystems (2)
cover 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(-)
Signature · 1 line
2.35.0.rc0.227.g00780c9af4-goog
PATCH 1/6 platform/chrome: cros_ec: fix error handling in cros_ec_register()
Fixes cros_ec_register() doesn't unregister platform devices if blocking_notifier_chain_register() fails.
Also uses the single exit path to handle the platform device unregistration.
This fix depends on the fact that all the callers of cros_ec_register() allocate zeroed memory.
--- drivers/platform/chrome/cros_ec.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/platform/chrome/cros_ec.c +10 -6
@@ -245,18 +245,16 @@ int cros_ec_register(struct cros_ec_device *ec_dev)if (IS_ERR (ec_dev->pd)) {dev_err (ec_dev->dev,"Failed to create CrOS PD platform device\n" ); -platform_device_unregister (ec_dev->ec); -return PTR_ERR (ec_dev->pd); + err =PTR_ERR (ec_dev->pd); + goto exit; } }if (IS_ENABLED (CONFIG_OF ) && dev->of_node) { err =devm_of_platform_populate (dev);if (err) { -platform_device_unregister (ec_dev->pd); -platform_device_unregister (ec_dev->ec);dev_err (dev,"Failed to register sub-devices\n" ); -return err; + goto exit; } }
@@ -278,7 +276,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev) err =blocking_notifier_chain_register (&ec_dev->event_notifier, &ec_dev->notifier_ready);if (err) -return err; + goto exit; }dev_info (dev,"Chrome EC device registered\n" );
@@ -291,6 +289,12 @@ int cros_ec_register(struct cros_ec_device *ec_dev)cros_ec_irq_thread (0 , ec_dev);return 0 ; +exit: +if (ec_dev->pd && !IS_ERR (ec_dev->pd)) +platform_device_unregister (ec_dev->pd); +if (ec_dev->ec && !IS_ERR (ec_dev->ec)) +platform_device_unregister (ec_dev->ec); +return err; }EXPORT_SYMBOL (cros_ec_register);
Signature · 1 line
2.35.0.rc0.227.g00780c9af4-goog
PATCH 2/6 platform/chrome: cros_ec: remove unused variable `was_wake_device`
In reply to Tzung-Bi Shihwas_wake_device is unused. Removes it.
--- drivers/platform/chrome/cros_ec.c | 1 - include/linux/platform_data/cros_ec_proto.h | 3 --- 2 files changed, 4 deletions(-)
drivers/platform/chrome/cros_ec.c +0 -1
@@ -344,7 +344,6 @@ int cros_ec_suspend(struct cros_ec_device *ec_dev) ec_dev->wake_enabled = !enable_irq_wake (ec_dev->irq);disable_irq (ec_dev->irq); - ec_dev->was_wake_device = ec_dev->wake_enabled; ec_dev->suspended = true;return 0 ;
include/linux/platform_data/cros_ec_proto.h +0 -3
@@ -76,8 +76,6 @@ struct cros_ec_command {* struct cros_ec_device - Information about a ChromeOS EC device. * @phys_name: Name of physical comms layer (e.g. 'i2c-4'). * @dev: Device pointer for physical comms device -* @was_wake_device: True if this device was set to wake the system from -* sleep at the last suspend. * @cros_class: The class structure for this device. * @cmd_readmem: Direct read of the EC memory-mapped region, if supported. * @offset: Is within EC_LPC_ADDR_MEMMAP region.
@@ -137,7 +135,6 @@ struct cros_ec_device {/* These are used by other drivers that want to talk to the EC */ const char *phys_name;struct device *dev; -bool was_wake_device;struct class *cros_class;int (*cmd_readmem)(struct cros_ec_device *ec,unsigned int offset,unsigned int bytes,void *dest);
Signature · 1 line
2.35.0.rc0.227.g00780c9af4-goog
PATCH 3/6 platform/chrome: cros_ec: determine `wake_enabled` in cros_ec_suspend()
In reply to Tzung-Bi Shihwake_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().
--- drivers/platform/chrome/cros_ec.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/platform/chrome/cros_ec.c +4 -3
@@ -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.
Signature · 1 line
2.35.0.rc0.227.g00780c9af4-goog
PATCH 4/6 platform/chrome: cros_ec: don't initialize `err` in cros_ec_register()
In reply to Tzung-Bi Shiherr in cros_ec_register() doesn't need to be initialized.
--- drivers/platform/chrome/cros_ec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/chrome/cros_ec.c +1 -1
@@ -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);
Signature · 1 line
2.35.0.rc0.227.g00780c9af4-goog
PATCH 5/6 platform/chrome: cros_ec: sort header inclusion alphabetically
In reply to Tzung-Bi ShihSorts header inclusion alphabetically.
--- drivers/platform/chrome/cros_ec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/chrome/cros_ec.c +2 -2
@@ -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"
Signature · 1 line
2.35.0.rc0.227.g00780c9af4-goog
PATCH 6/6 platform/chrome: cros_ec: append newline to all logs
In reply to Tzung-Bi ShihTo be consistent, appends newline ("\n") to all logs.
--- drivers/platform/chrome/cros_ec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/platform/chrome/cros_ec.c +4 -4
@@ -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)
Signature · 1 line
2.35.0.rc0.227.g00780c9af4-goog