platform/chrome: cros_ec_typec: Defer probe until EC device is registered
Tzung-Bi Shih
maintainerPATCH 1/1 platform/chrome: cros_ec_typec: Defer probe until EC device is registered
Similar to 48633acccf38 ("Input: cros_ec_keyb - Defer probe until parent EC device is registered"), use cros_ec_device_registered() to check parent's status. If the device is not yet ready, return -EPROBE_DEFER to ensure the probe is retried later.
This technically reverts:
- 731a4702b668 ("platform/chrome: cros_ec_typec: Check ec platform device pointer").
- 7464ff8bf2d7 ("platform/chrome: cros_ec_typec: Check for EC driver").
Signed-off-by Tzung-Bi Shih <[email protected]>
--- drivers/platform/chrome/cros_ec_typec.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/platform/chrome/cros_ec_typec.c +8 -7
@@ -1341,7 +1341,7 @@ MODULE_DEVICE_TABLE(of, cros_typec_of_match);static int cros_typec_probe (struct platform_device *pdev) { -struct cros_ec_dev *ec_dev =NULL ; +struct cros_ec_dev *ec_dev;struct device *dev = &pdev->dev;struct cros_typec_data *typec;struct ec_response_usb_pd_ports resp;
@@ -1354,10 +1354,14 @@ static int cros_typec_probe(struct platform_device *pdev) typec->dev = dev; typec->ec =dev_get_drvdata (pdev->dev.parent); -if (!typec->ec || !typec->ec->ec) { -dev_warn (dev,"couldn't find parent EC device\n" ); +if (!typec->ec) +return -EPROBE_DEFER ; +/* +* Even if the cros_ec_device pointer is available, still need to check +* if the device is fully registered before using it. +*/ +if (!cros_ec_device_registered (typec->ec))return -EPROBE_DEFER ; - }platform_set_drvdata (pdev, typec);
@@ -1368,9 +1372,6 @@ static int cros_typec_probe(struct platform_device *pdev) } ec_dev =dev_get_drvdata (&typec->ec->ec->dev); -if (!ec_dev) -return -EPROBE_DEFER ; - typec->typec_cmd_supported =cros_ec_check_features (ec_dev,EC_FEATURE_TYPEC_CMD ); typec->needs_mux_ack =cros_ec_check_features (ec_dev,EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK ); typec->ap_driven_altmode = cros_ec_check_features(
Signature · 1 line
2.51.0.384.g4c02a37b29-goog