FROMGIT: platform/chrome: cros_ec_typec: Defer probe on missing EC parent

If cros_typec_probe is called before EC device is registered,
cros_typec_probe will fail. It may happen when cros-ec-typec.ko is
loaded before EC bus layer module (e.g. cros_ec_lpcs.ko,
cros_ec_spi.ko).

Return -EPROBE_DEFER when cros_typec_probe doesn't get EC device, so
the probe function can be called again after EC device is registered.

Signed-off-by: Tomasz Michalec <tmichalec@google.com>
Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Link: https://lore.kernel.org/r/20250610153748.1858519-1-tmichalec@google.com
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>

Bug: 400637437
(cherry picked from commit 8866f4e557eba43e991f99711515217a95f62d2e
 https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git
 for-next)
Change-Id: I985d0035ad6c734554c7968a291fc4c9f36f4070
Signed-off-by: Tomasz Michalec <tmichalec@google.com>
This commit is contained in:
Tomasz Michalec
2025-06-10 17:37:47 +02:00
committed by Treehugger Robot
parent c40a59df7f
commit ede5aa33f4

View File

@@ -1226,8 +1226,8 @@ static int cros_typec_probe(struct platform_device *pdev)
typec->ec = dev_get_drvdata(pdev->dev.parent);
if (!typec->ec) {
dev_err(dev, "couldn't find parent EC device\n");
return -ENODEV;
dev_warn(dev, "couldn't find parent EC device\n");
return -EPROBE_DEFER;
}
platform_set_drvdata(pdev, typec);