From 99fb0f25c448ab72481bd700b66e0e48c583ef5a Mon Sep 17 00:00:00 2001 From: Wenkai Du Date: Thu, 22 Feb 2018 13:30:52 -0800 Subject: Revert "mfd: cros_ec: Add ACPI GPE handler for LID0 devices" This reverts commit e04653a9dcf4d98defe2149c885382e5cc72082f. It is no longer needed to install Chrome EC GPE handler to have GPE enabled in suspend to idle path. It is found that with this handler installed, EC wake up doesn't work because default EC event handler that can wake up system is not getting called. Signed-off-by: Wenkai Du Acked-by: Benson Leung Signed-off-by: Lee Jones --- drivers/mfd/cros_ec.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'drivers/mfd/cros_ec.c') diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c index d61024141e2b..c221163d5b9e 100644 --- a/drivers/mfd/cros_ec.c +++ b/drivers/mfd/cros_ec.c @@ -173,8 +173,6 @@ int cros_ec_register(struct cros_ec_device *ec_dev) dev_info(dev, "Chrome EC device registered\n"); - cros_ec_acpi_install_gpe_handler(dev); - return 0; fail_mfd: @@ -188,8 +186,6 @@ int cros_ec_remove(struct cros_ec_device *ec_dev) { mfd_remove_devices(ec_dev->dev); - cros_ec_acpi_remove_gpe_handler(); - if (ec_dev->irq) free_irq(ec_dev->irq, ec_dev); @@ -204,14 +200,9 @@ int cros_ec_suspend(struct cros_ec_device *ec_dev) int ret; u8 sleep_event; - if (!IS_ENABLED(CONFIG_ACPI) || pm_suspend_via_firmware()) { - sleep_event = HOST_SLEEP_EVENT_S3_SUSPEND; - } else { - sleep_event = HOST_SLEEP_EVENT_S0IX_SUSPEND; - - /* Clearing the GPE status for any pending event */ - cros_ec_acpi_clear_gpe(); - } + sleep_event = (!IS_ENABLED(CONFIG_ACPI) || pm_suspend_via_firmware()) ? + HOST_SLEEP_EVENT_S3_SUSPEND : + HOST_SLEEP_EVENT_S0IX_SUSPEND; ret = cros_ec_sleep_event(ec_dev, sleep_event); if (ret < 0) -- cgit v1.2.3 From 0dbbf25561b29ffab5ba6277429760abdf49ceff Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Wed, 18 Apr 2018 12:23:58 +0200 Subject: mfd: cros_ec: Fail early if we cannot identify the EC If we cannot communicate with the EC chip to detect the protocol version and its features, it's very likely useless to continue. Else we will commit all kind of uninformed mistakes (using the wrong protocol, the wrong buffer size, mixing the EC with other chips). Signed-off-by: Vincent Palatin Acked-by: Benson Leung Signed-off-by: Enric Balletbo i Serra Reviewed-by: Gwendal Grignou Reviewed-by: Andy Shevchenko Signed-off-by: Lee Jones --- drivers/mfd/cros_ec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers/mfd/cros_ec.c') diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c index c221163d5b9e..1e5276970778 100644 --- a/drivers/mfd/cros_ec.c +++ b/drivers/mfd/cros_ec.c @@ -112,7 +112,11 @@ int cros_ec_register(struct cros_ec_device *ec_dev) mutex_init(&ec_dev->lock); - cros_ec_query_all(ec_dev); + err = cros_ec_query_all(ec_dev); + if (err) { + dev_err(dev, "Cannot identify the EC: error %d\n", err); + return err; + } if (ec_dev->irq) { err = request_threaded_irq(ec_dev->irq, NULL, ec_irq_thread, -- cgit v1.2.3 From eb3f2f2396d1f8e1043b7613aa657fb4fd4ebc3e Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Wed, 18 Apr 2018 12:23:59 +0200 Subject: mfd: cros_ec: Free IRQ automatically Free the IRQ we might have requested when removing the cros_ec device, so we can unload and reload the driver properly. Signed-off-by: Vincent Palatin Signed-off-by: Enric Balletbo i Serra Acked-by: Vincent Palatin Reviewed-by: Andy Shevchenko Signed-off-by: Lee Jones --- drivers/mfd/cros_ec.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'drivers/mfd/cros_ec.c') diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c index 1e5276970778..58e05069163e 100644 --- a/drivers/mfd/cros_ec.c +++ b/drivers/mfd/cros_ec.c @@ -119,9 +119,9 @@ int cros_ec_register(struct cros_ec_device *ec_dev) } if (ec_dev->irq) { - err = request_threaded_irq(ec_dev->irq, NULL, ec_irq_thread, - IRQF_TRIGGER_LOW | IRQF_ONESHOT, - "chromeos-ec", ec_dev); + err = devm_request_threaded_irq(dev, ec_dev->irq, NULL, + ec_irq_thread, IRQF_TRIGGER_LOW | IRQF_ONESHOT, + "chromeos-ec", ec_dev); if (err) { dev_err(dev, "Failed to request IRQ %d: %d", ec_dev->irq, err); @@ -135,7 +135,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev) dev_err(dev, "Failed to register Embedded Controller subdevice %d\n", err); - goto fail_mfd; + return err; } if (ec_dev->max_passthru) { @@ -153,7 +153,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev) dev_err(dev, "Failed to register Power Delivery subdevice %d\n", err); - goto fail_mfd; + return err; } } @@ -162,7 +162,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev) if (err) { mfd_remove_devices(dev); dev_err(dev, "Failed to register sub-devices\n"); - goto fail_mfd; + return err; } } @@ -178,11 +178,6 @@ int cros_ec_register(struct cros_ec_device *ec_dev) dev_info(dev, "Chrome EC device registered\n"); return 0; - -fail_mfd: - if (ec_dev->irq) - free_irq(ec_dev->irq, ec_dev); - return err; } EXPORT_SYMBOL(cros_ec_register); @@ -190,9 +185,6 @@ int cros_ec_remove(struct cros_ec_device *ec_dev) { mfd_remove_devices(ec_dev->dev); - if (ec_dev->irq) - free_irq(ec_dev->irq, ec_dev); - return 0; } EXPORT_SYMBOL(cros_ec_remove); -- cgit v1.2.3