Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1475844

[PATCH] usb: phy: generic: request regulator optionally

From Stefan Agner <stefan@agner.ch>
Newsgroups linux.kernel
Subject [PATCH] usb: phy: generic: request regulator optionally
Date 2016-09-04 06:30 +0200
Message-ID <sdxea-6cu-3@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


According to the device tree bindings the vcc-supply is optional.
So far the driver did request the regulator using devm_regulator_get
which creates a dummy regulator for convenience. Since we can have
the supply unconnected, we should make use of the optional variant
of the regulator call which does not return a dummy regulator but
-ENODEV. The driver already has checks in case the regulator is an
error pointer.

Note that with this change the behavior is slightly different in
case devm_regulator_get_optional returns -EPROBE_DEFER: The driver
returns -EPROBE_DEFER even if needs_vcc is set false. This is the
correct behavior, since even if the regulator is optional, it might
get initialized later...

Signed-off-by: Stefan Agner <stefan@agner.ch>
---
This gets rid of warnings such as this (seen on i.MX 7):
30800000.aips-bus:usbphynop1 supply vcc not found, using dummy regulator

--
Stefan

 drivers/usb/phy/phy-generic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index 980c9de..38ceadc 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c
@@ -275,12 +275,12 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop,
 		}
 	}
 
-	nop->vcc = devm_regulator_get(dev, "vcc");
+	nop->vcc = devm_regulator_get_optional(dev, "vcc");
 	if (IS_ERR(nop->vcc)) {
 		dev_dbg(dev, "Error getting vcc regulator: %ld\n",
 					PTR_ERR(nop->vcc));
-		if (needs_vcc)
-			return -EPROBE_DEFER;
+		if (needs_vcc || PTR_ERR(nop->vcc) == -EPROBE_DEFER)
+			return PTR_ERR(nop->vcc);
 	}
 
 	nop->dev		= dev;
-- 
2.9.0

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] usb: phy: generic: request regulator optionally Stefan Agner <stefan@agner.ch> - 2016-09-04 06:30 +0200
  Re: [PATCH] usb: phy: generic: request regulator optionally Felipe Balbi <balbi@kernel.org> - 2016-09-06 09:50 +0200
    Re: [PATCH] usb: phy: generic: request regulator optionally Mark Brown <broonie@kernel.org> - 2016-09-06 10:30 +0200
      Re: [PATCH] usb: phy: generic: request regulator optionally Stefan Agner <stefan@agner.ch> - 2016-09-06 20:10 +0200
        Re: [PATCH] usb: phy: generic: request regulator optionally Roger Quadros <rogerq@ti.com> - 2016-09-07 09:30 +0200
          Re: [PATCH] usb: phy: generic: request regulator optionally Felipe Balbi <balbi@kernel.org> - 2016-09-07 10:10 +0200
        Re: [PATCH] usb: phy: generic: request regulator optionally Mark Brown <broonie@kernel.org> - 2016-09-07 21:00 +0200
          Re: [PATCH] usb: phy: generic: request regulator optionally Stefan Agner <stefan@agner.ch> - 2016-09-07 22:50 +0200

csiph-web