From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Benson Leung <bleung@chromium.org>,
Abhishek Pandit-Subedi <abhishekpandit@chromium.org>,
Jameson Thies <jthies@google.com>,
Andrei Kuchynski <akuchynski@chromium.org>
Cc: tmichalec@google.com, tzungbi@kernel.org,
chrome-platform@lists.linux.dev
Subject: [PATCH] platform/chrome: cros_ec_typec: Defer probe until EC device is registered
Date: Tue, 16 Sep 2025 09:24:14 +0000 [thread overview]
Message-ID: <20250916092415.1707444-1-tzungbi@kernel.org> (raw)
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 <tzungbi@kernel.org>
---
drivers/platform/chrome/cros_ec_typec.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index b712bcff6fb2..17379e8b13b3 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -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(
--
2.51.0.384.g4c02a37b29-goog
reply other threads:[~2025-09-16 9:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250916092415.1707444-1-tzungbi@kernel.org \
--to=tzungbi@kernel.org \
--cc=abhishekpandit@chromium.org \
--cc=akuchynski@chromium.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=jthies@google.com \
--cc=tmichalec@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox