Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

platform/chrome: cros_usbpd_notify: defer probe when parent EC driver isn't ready

The cros-usbpd-notify-acpi probe currently does not exit when it fails
to get a pointer to the ChromeOS EC device. It is expected behavior on
older devices, where GOOG0004 is not a parent of GOOG0003.

Update the cros-usbpd-notify-acpi probe to check for a GOOG0004 parent
fwnode. If the device has correct device hierarchy and fails to get an
EC device pointer, defer the probe function.

Signed-off-by: Jameson Thies <jthies@google.com>
Reviewed-by: Benson Leung <bleung@chromium.org>
Link: https://lore.kernel.org/r/20251007004043.4109957-1-jthies@google.com
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>

authored by

Jameson Thies and committed by
Tzung-Bi Shih
e4ee0bb0 3a866087

+15 -2
+15 -2
drivers/platform/chrome/cros_usbpd_notify.c
··· 6 6 */ 7 7 8 8 #include <linux/acpi.h> 9 + #include <linux/fwnode.h> 9 10 #include <linux/mod_devicetable.h> 10 11 #include <linux/module.h> 11 12 #include <linux/platform_data/cros_ec_proto.h> ··· 16 15 #define DRV_NAME "cros-usbpd-notify" 17 16 #define DRV_NAME_PLAT_ACPI "cros-usbpd-notify-acpi" 18 17 #define ACPI_DRV_NAME "GOOG0003" 18 + #define CREC_DRV_NAME "GOOG0004" 19 19 20 20 static BLOCKING_NOTIFIER_HEAD(cros_usbpd_notifier_list); 21 21 ··· 100 98 { 101 99 struct cros_usbpd_notify_data *pdnotify; 102 100 struct device *dev = &pdev->dev; 103 - struct acpi_device *adev; 101 + struct acpi_device *adev, *parent_adev; 104 102 struct cros_ec_device *ec_dev; 103 + struct fwnode_handle *parent_fwnode; 105 104 acpi_status status; 106 105 107 106 adev = ACPI_COMPANION(dev); ··· 117 114 /* 118 115 * We continue even for older devices which don't have the 119 116 * correct device heirarchy, namely, GOOG0003 is a child 120 - * of GOOG0004. 117 + * of GOOG0004. If GOOG0003 is a child of GOOG0004 and we 118 + * can't get a pointer to the Chrome EC device, defer the 119 + * probe function. 121 120 */ 121 + parent_fwnode = fwnode_get_parent(dev->fwnode); 122 + if (parent_fwnode) { 123 + parent_adev = to_acpi_device_node(parent_fwnode); 124 + if (parent_adev && 125 + acpi_dev_hid_match(parent_adev, CREC_DRV_NAME)) { 126 + return -EPROBE_DEFER; 127 + } 128 + } 122 129 dev_warn(dev, "Couldn't get Chrome EC device pointer.\n"); 123 130 } 124 131