[PATCH v3] media: cros-ec-cec: do not bail on device_init_wakeup failure
From: Dariusz Marcinkiewicz
Date: Fri Jun 26 2020 - 08:50:13 EST
Do not fail probing when device_init_wakeup fails. Also clear wakeup
on remove.
device_init_wakeup fails when the device is already enabled as wakeup
device. Hence, the driver fails to probe the device if:
- The device has already been enabled for wakeup (via /proc/acpi/wakeup)
- The driver has been unloaded and is being loaded again.
This goal of the patch is to fix the above cases.
Overwhelming majority of the drivers do not consider device_init_wakeup
failure as a fatal error and proceed regardless of whether it succeeds
or not.
Changes since v2:
- disabled wakeup in remove
- CC'ing stable
- description fixed
Changes since v1:
- added Fixes tag
Fixes: cd70de2d356ee ("media: platform: Add ChromeOS EC CEC driver")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Dariusz Marcinkiewicz <darekm@xxxxxxxxxx>
---
drivers/media/cec/platform/cros-ec/cros-ec-cec.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/media/cec/platform/cros-ec/cros-ec-cec.c b/drivers/media/cec/platform/cros-ec/cros-ec-cec.c
index 0e7e2772f08f..3881ed7bc3d9 100644
--- a/drivers/media/cec/platform/cros-ec/cros-ec-cec.c
+++ b/drivers/media/cec/platform/cros-ec/cros-ec-cec.c
@@ -277,12 +277,6 @@ static int cros_ec_cec_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, cros_ec_cec);
cros_ec_cec->cros_ec = cros_ec;
- ret = device_init_wakeup(&pdev->dev, 1);
- if (ret) {
- dev_err(&pdev->dev, "failed to initialize wakeup\n");
- return ret;
- }
-
cros_ec_cec->adap = cec_allocate_adapter(&cros_ec_cec_ops, cros_ec_cec,
DRV_NAME,
CEC_CAP_DEFAULTS |
@@ -310,6 +304,8 @@ static int cros_ec_cec_probe(struct platform_device *pdev)
if (ret < 0)
goto out_probe_notify;
+ device_init_wakeup(&pdev->dev, 1);
+
return 0;
out_probe_notify:
@@ -339,6 +335,8 @@ static int cros_ec_cec_remove(struct platform_device *pdev)
cros_ec_cec->adap);
cec_unregister_adapter(cros_ec_cec->adap);
+ device_init_wakeup(&pdev->dev, 0);
+
return 0;
}
--
2.27.0.212.ge8ba1cc988-goog