Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3b64c4ce authored by Jack Pham's avatar Jack Pham
Browse files

usb: pd: Return different errors in devm_usbpd_get_by_phandle()



Allow callers of devm_usbpd_get_by_phandle() to distinguish
between different errors depending on what failure is encountered.
For instance, return -EPROBE_DEFER if the device is available
but not yet probed, which allows callers to appropriately try
again later.

Change-Id: I96b03d0a4c2a04a405af5a40f9f713443bc5769b
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
parent 4e2a8a0f
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -2228,12 +2228,15 @@ struct usbpd *devm_usbpd_get_by_phandle(struct device *dev, const char *phandle)
	struct platform_device *pdev;
	struct device *pd_dev;

	if (!usbpd_class.p) /* usbpd_init() not yet called */
		return ERR_PTR(-EAGAIN);

	if (!dev->of_node)
		return ERR_PTR(-ENODEV);
		return ERR_PTR(-EINVAL);

	pd_np = of_parse_phandle(dev->of_node, phandle, 0);
	if (!pd_np)
		return ERR_PTR(-ENODEV);
		return ERR_PTR(-ENXIO);

	pdev = of_find_device_by_node(pd_np);
	if (!pdev)
@@ -2243,7 +2246,8 @@ struct usbpd *devm_usbpd_get_by_phandle(struct device *dev, const char *phandle)
			match_usbpd_device);
	if (!pd_dev) {
		platform_device_put(pdev);
		return ERR_PTR(-ENODEV);
		/* device was found but maybe hadn't probed yet, so defer */
		return ERR_PTR(-EPROBE_DEFER);
	}

	ptr = devres_alloc(devm_usbpd_put, sizeof(*ptr), GFP_KERNEL);
@@ -2255,7 +2259,7 @@ struct usbpd *devm_usbpd_get_by_phandle(struct device *dev, const char *phandle)

	pd = dev_get_drvdata(pd_dev);
	if (!pd)
		return ERR_PTR(-ENODEV);
		return ERR_PTR(-EPROBE_DEFER);

	*ptr = pd;
	devres_add(dev, ptr);