usb: dwc3: omap: Use devm_regulator_get_optional()
Subsystems (3)
PATCH 1/1 usb: dwc3: omap: Use devm_regulator_get_optional()
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.
--- drivers/usb/dwc3/dwc3-omap.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/usb/dwc3/dwc3-omap.c +4 -8
@@ -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;
Signature · 1 line
2.45.2
Quoted 3 lines · Rob Herring (Arm)
The 'vbus-supply' regulator is optional, so use
devm_regulator_get_optional()instead of checking for property presence first.
Is it actually optional? The name suggests it's likely to be required...
Quoted 8 lines · Mark Brown
Quoted 3 lines · Rob Herring (Arm)
The 'vbus-supply' regulator is optional, so use
devm_regulator_get_optional()instead of checking for property presence first.Is it actually optional? The name suggests it's likely to be required...
That's what the binding says. From a quick scan, I only see this used for OMAP5. The preference is for this to be in the connector node as that is where Vbus is hooked up to typically.
Rob
Quoted 30 lines · Rob Herring (Arm)
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) <[email protected]>--- drivers/usb/dwc3/dwc3-omap.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)drivers/usb/dwc3/dwc3-omap.c +1
-1@@ -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);
drivers/usb/dwc3/dwc3-omap.c static int dwc3_omap_probe(struct platform_device *pdev) · line 488
Quoted 10 lines
drivers/usb/dwc3/dwc3-omap.c +3
-7-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" );
This is wrong because devm_regulator_get_optional() returns -ENODEV rather than NULL like all the other _get_optional() functions...
Rob