usb: dwc3: omap: Use devm_regulator_get_optional()
authorRob Herring (Arm) <robh@kernel.org>
Tue, 31 Dec 2024 16:44:56 +0000 (10:44 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Jan 2025 10:14:05 +0000 (11:14 +0100)
The 'vbus-supply' regulator is optional, so use
devm_regulator_get_optional() instead of checking for property presence
first.

While here, rework the error handling to use dev_err_probe() which
handles deferred probe correctly without an error message.

Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://lore.kernel.org/r/20241231164456.262581-1-robh@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc3/dwc3-omap.c

index b261c46124c612a79fa84970dccc321511583370..9b1d10ac33c15945d14ebd0d58c04d4fabe6127b 100644 (file)
@@ -457,7 +457,7 @@ static int dwc3_omap_probe(struct platform_device *pdev)
 
        struct dwc3_omap        *omap;
        struct device           *dev = &pdev->dev;
-       struct regulator        *vbus_reg = NULL;
+       struct regulator        *vbus_reg;
 
        int                     ret;
        int                     irq;
@@ -483,13 +483,9 @@ static int dwc3_omap_probe(struct platform_device *pdev)
        if (IS_ERR(base))
                return PTR_ERR(base);
 
-       if (of_property_read_bool(node, "vbus-supply")) {
-               vbus_reg = devm_regulator_get(dev, "vbus");
-               if (IS_ERR(vbus_reg)) {
-                       dev_err(dev, "vbus init failed\n");
-                       return PTR_ERR(vbus_reg);
-               }
-       }
+       vbus_reg = devm_regulator_get_optional(dev, "vbus");
+       if (IS_ERR(vbus_reg))
+               return dev_err_probe(dev, PTR_ERR(vbus_reg), "vbus init failed\n");
 
        omap->dev       = dev;
        omap->irq       = irq;