mfd: cros_ec_dev: Register shutdown function for debugfs
authorDaniel Hung-yu Wu <hywu@google.com>
Wed, 18 Apr 2018 10:24:02 +0000 (12:24 +0200)
committerLee Jones <lee.jones@linaro.org>
Tue, 29 May 2018 08:10:54 +0000 (09:10 +0100)
Reboot or shutdown during delayed works could corrupt communication with
EC and certain I2C controller may not be able to recover from the error
state.

This patch registers a shutdown callback used to cancel the debugfs log
worker thread.

Signed-off-by: Daniel Hung-yu Wu <hywu@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

index a393b3c11aa068c3612a7801b41b27f265bcbed3..1f889523885d4a873a509b126f0ef30aa7fb700f 100644 (file)
@@ -472,6 +472,14 @@ static int ec_device_remove(struct platform_device *pdev)
        return 0;
 }
 
+static void ec_device_shutdown(struct platform_device *pdev)
+{
+       struct cros_ec_dev *ec = dev_get_drvdata(&pdev->dev);
+
+       /* Be sure to clear up debugfs delayed works */
+       cros_ec_debugfs_remove(ec);
+}
+
 static const struct platform_device_id cros_ec_id[] = {
        { DRV_NAME, 0 },
        { /* sentinel */ },
@@ -514,6 +522,7 @@ static struct platform_driver cros_ec_dev_driver = {
        },
        .probe = ec_device_probe,
        .remove = ec_device_remove,
+       .shutdown = ec_device_shutdown,
 };
 
 static int __init cros_ec_dev_init(void)