public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: dwc3: omap: Use devm_regulator_get_optional()
@ 2024-12-31 16:44 Rob Herring (Arm)
  2025-01-06 12:49 ` Mark Brown
  2025-01-09 16:45 ` Rob Herring
  0 siblings, 2 replies; 4+ messages in thread
From: Rob Herring (Arm) @ 2024-12-31 16:44 UTC (permalink / raw)
  To: Thinh Nguyen, Greg Kroah-Hartman, Liam Girdwood, Mark Brown
  Cc: linux-usb, linux-omap, linux-kernel

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>
---
 drivers/usb/dwc3/dwc3-omap.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index b261c46124c6..9b1d10ac33c1 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -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;
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: dwc3: omap: Use devm_regulator_get_optional()
  2024-12-31 16:44 [PATCH] usb: dwc3: omap: Use devm_regulator_get_optional() Rob Herring (Arm)
@ 2025-01-06 12:49 ` Mark Brown
  2025-01-06 21:37   ` Rob Herring
  2025-01-09 16:45 ` Rob Herring
  1 sibling, 1 reply; 4+ messages in thread
From: Mark Brown @ 2025-01-06 12:49 UTC (permalink / raw)
  To: Rob Herring (Arm)
  Cc: Thinh Nguyen, Greg Kroah-Hartman, Liam Girdwood, linux-usb,
	linux-omap, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 275 bytes --]

On Tue, Dec 31, 2024 at 10:44:56AM -0600, Rob Herring (Arm) wrote:
> 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...

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: dwc3: omap: Use devm_regulator_get_optional()
  2025-01-06 12:49 ` Mark Brown
@ 2025-01-06 21:37   ` Rob Herring
  0 siblings, 0 replies; 4+ messages in thread
From: Rob Herring @ 2025-01-06 21:37 UTC (permalink / raw)
  To: Mark Brown
  Cc: Thinh Nguyen, Greg Kroah-Hartman, Liam Girdwood, linux-usb,
	linux-omap, linux-kernel

On Mon, Jan 6, 2025 at 6:49 AM Mark Brown <broonie@kernel.org> wrote:
>
> On Tue, Dec 31, 2024 at 10:44:56AM -0600, Rob Herring (Arm) wrote:
> > 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: dwc3: omap: Use devm_regulator_get_optional()
  2024-12-31 16:44 [PATCH] usb: dwc3: omap: Use devm_regulator_get_optional() Rob Herring (Arm)
  2025-01-06 12:49 ` Mark Brown
@ 2025-01-09 16:45 ` Rob Herring
  1 sibling, 0 replies; 4+ messages in thread
From: Rob Herring @ 2025-01-09 16:45 UTC (permalink / raw)
  To: Thinh Nguyen, Greg Kroah-Hartman, Liam Girdwood, Mark Brown
  Cc: linux-usb, linux-omap, linux-kernel

On Tue, Dec 31, 2024 at 10:45 AM Rob Herring (Arm) <robh@kernel.org> wrote:
>
> 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>
> ---
>  drivers/usb/dwc3/dwc3-omap.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
> index b261c46124c6..9b1d10ac33c1 100644
> --- a/drivers/usb/dwc3/dwc3-omap.c
> +++ b/drivers/usb/dwc3/dwc3-omap.c
> @@ -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");

This is wrong because devm_regulator_get_optional() returns -ENODEV
rather than NULL like all the other _get_optional() functions...

Rob

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-01-09 16:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-31 16:44 [PATCH] usb: dwc3: omap: Use devm_regulator_get_optional() Rob Herring (Arm)
2025-01-06 12:49 ` Mark Brown
2025-01-06 21:37   ` Rob Herring
2025-01-09 16:45 ` Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox