usb: common: usb-conn-gpio: Make VBUS supply completely optional
authorAlexander Stein <alexander.stein@ew.tq-group.com>
Wed, 9 Mar 2022 09:38:42 +0000 (10:38 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 15 Mar 2022 17:22:15 +0000 (18:22 +0100)
It makes sense that if the USB connector is a child of an USB port
providing VBUS supply, there is no need to do it again.
But this does not handle the case where VBUS is controlled by PWR from
USB host controller, without any regulator at all.
Support this by making VBUS pure optional.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Link: https://lore.kernel.org/r/20220309093842.113260-1-alexander.stein@ew.tq-group.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/common/usb-conn-gpio.c

index 0158148..395f9bb 100644 (file)
@@ -175,7 +175,6 @@ static int usb_conn_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct usb_conn_info *info;
-       bool need_vbus = true;
        int ret = 0;
 
        info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
@@ -205,22 +204,9 @@ static int usb_conn_probe(struct platform_device *pdev)
 
        INIT_DELAYED_WORK(&info->dw_det, usb_conn_detect_cable);
 
-       /*
-        * If the USB connector is a child of a USB port and that port already provides the VBUS
-        * supply, there's no need for the USB connector to provide it again.
-        */
-       if (dev->parent && dev->parent->of_node) {
-               if (of_find_property(dev->parent->of_node, "vbus-supply", NULL))
-                       need_vbus = false;
-       }
-
-       if (!need_vbus) {
-               info->vbus = devm_regulator_get_optional(dev, "vbus");
-               if (PTR_ERR(info->vbus) == -ENODEV)
-                       info->vbus = NULL;
-       } else {
-               info->vbus = devm_regulator_get(dev, "vbus");
-       }
+       info->vbus = devm_regulator_get_optional(dev, "vbus");
+       if (PTR_ERR(info->vbus) == -ENODEV)
+               info->vbus = NULL;
 
        if (IS_ERR(info->vbus)) {
                ret = PTR_ERR(info->vbus);