Skip to content

Commit e4ee0bb

Browse files
jthiesatgoogleTzung-Bi Shih
authored andcommitted
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>
1 parent 3a86608 commit e4ee0bb

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

drivers/platform/chrome/cros_usbpd_notify.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include <linux/acpi.h>
9+
#include <linux/fwnode.h>
910
#include <linux/mod_devicetable.h>
1011
#include <linux/module.h>
1112
#include <linux/platform_data/cros_ec_proto.h>
@@ -15,6 +16,7 @@
1516
#define DRV_NAME "cros-usbpd-notify"
1617
#define DRV_NAME_PLAT_ACPI "cros-usbpd-notify-acpi"
1718
#define ACPI_DRV_NAME "GOOG0003"
19+
#define CREC_DRV_NAME "GOOG0004"
1820

1921
static BLOCKING_NOTIFIER_HEAD(cros_usbpd_notifier_list);
2022

@@ -98,8 +100,9 @@ static int cros_usbpd_notify_probe_acpi(struct platform_device *pdev)
98100
{
99101
struct cros_usbpd_notify_data *pdnotify;
100102
struct device *dev = &pdev->dev;
101-
struct acpi_device *adev;
103+
struct acpi_device *adev, *parent_adev;
102104
struct cros_ec_device *ec_dev;
105+
struct fwnode_handle *parent_fwnode;
103106
acpi_status status;
104107

105108
adev = ACPI_COMPANION(dev);
@@ -114,8 +117,18 @@ static int cros_usbpd_notify_probe_acpi(struct platform_device *pdev)
114117
/*
115118
* We continue even for older devices which don't have the
116119
* correct device heirarchy, namely, GOOG0003 is a child
117-
* of GOOG0004.
120+
* of GOOG0004. If GOOG0003 is a child of GOOG0004 and we
121+
* can't get a pointer to the Chrome EC device, defer the
122+
* probe function.
118123
*/
124+
parent_fwnode = fwnode_get_parent(dev->fwnode);
125+
if (parent_fwnode) {
126+
parent_adev = to_acpi_device_node(parent_fwnode);
127+
if (parent_adev &&
128+
acpi_dev_hid_match(parent_adev, CREC_DRV_NAME)) {
129+
return -EPROBE_DEFER;
130+
}
131+
}
119132
dev_warn(dev, "Couldn't get Chrome EC device pointer.\n");
120133
}
121134

0 commit comments

Comments
 (0)