mfd: cros_ec: Don't try to grab log when suspended
authorDouglas Anderson <dianders@chromium.org>
Wed, 18 Apr 2018 10:24:00 +0000 (12:24 +0200)
committerLee Jones <lee.jones@linaro.org>
Tue, 29 May 2018 08:10:39 +0000 (09:10 +0100)
We should stop our worker thread while we're suspended.  If we don't
then we'll get messages like:

  cros-ec-spi spi5.0: spi transfer failed: -108
  cros-ec-spi spi5.0: cs-deassert spi transfer failed: -108
  cros-ec-ctl cros-ec-ctl.0.auto: EC communication failed

Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/mfd/cros_ec_dev.c
drivers/platform/chrome/cros_ec_debugfs.c
include/linux/mfd/cros_ec.h

index eafd06f62a3afb492e1c2ec64526d591703a3a31..5a7d4e1dea708cdd3fe4048f84f5b1157ba9b3fc 100644 (file)
@@ -466,6 +466,8 @@ static __maybe_unused int ec_device_suspend(struct device *dev)
 {
        struct cros_ec_dev *ec = dev_get_drvdata(dev);
 
+       cros_ec_debugfs_suspend(ec);
+
        lb_suspend(ec);
 
        return 0;
@@ -475,6 +477,8 @@ static __maybe_unused int ec_device_resume(struct device *dev)
 {
        struct cros_ec_dev *ec = dev_get_drvdata(dev);
 
+       cros_ec_debugfs_resume(ec);
+
        lb_resume(ec);
 
        return 0;
index cc265ed8deb7f8aa7926566f26ac27aafb925196..c62ee8e610a0fcd307718f38cabe998a669ab8ea 100644 (file)
@@ -470,3 +470,23 @@ void cros_ec_debugfs_remove(struct cros_ec_dev *ec)
        cros_ec_cleanup_console_log(ec->debug_info);
 }
 EXPORT_SYMBOL(cros_ec_debugfs_remove);
+
+void cros_ec_debugfs_suspend(struct cros_ec_dev *ec)
+{
+       /*
+        * cros_ec_debugfs_init() failures are non-fatal; it's also possible
+        * that we initted things but decided that console log wasn't supported.
+        * We'll use the same set of checks that cros_ec_debugfs_remove() +
+        * cros_ec_cleanup_console_log() end up using to handle those cases.
+        */
+       if (ec->debug_info && ec->debug_info->log_buffer.buf)
+               cancel_delayed_work_sync(&ec->debug_info->log_poll_work);
+}
+EXPORT_SYMBOL(cros_ec_debugfs_suspend);
+
+void cros_ec_debugfs_resume(struct cros_ec_dev *ec)
+{
+       if (ec->debug_info && ec->debug_info->log_buffer.buf)
+               schedule_delayed_work(&ec->debug_info->log_poll_work, 0);
+}
+EXPORT_SYMBOL(cros_ec_debugfs_resume);
index 4ff0cec979b007c023652ecaeb730a8360980245..b8e750d91200339723fcc92bf50230be577db474 100644 (file)
@@ -327,5 +327,7 @@ extern struct attribute_group cros_ec_vbc_attr_group;
 /* debugfs stuff */
 int cros_ec_debugfs_init(struct cros_ec_dev *ec);
 void cros_ec_debugfs_remove(struct cros_ec_dev *ec);
+void cros_ec_debugfs_suspend(struct cros_ec_dev *ec);
+void cros_ec_debugfs_resume(struct cros_ec_dev *ec);
 
 #endif /* __LINUX_MFD_CROS_EC_H */