From: Felipe Balbi <balbi@kernel.org>
To: Stefan Agner <stefan@agner.ch>
Cc: gregkh@linuxfoundation.org, fabio.estevam@nxp.com,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Stefan Agner <stefan@agner.ch>, Mark Brown <broonie@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: phy: generic: request regulator optionally
Date: Tue, 06 Sep 2016 10:45:19 +0300 [thread overview]
Message-ID: <87mvjlmpyo.fsf@linux.intel.com> (raw)
In-Reply-To: <20160904040416.22163-1-stefan@agner.ch>
[-- Attachment #1: Type: text/plain, Size: 1858 bytes --]
Mark,
Stefan Agner <stefan@agner.ch> writes:
> 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);
does this look okay from a regulator API perspective?
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 800 bytes --]
next prev parent reply other threads:[~2016-09-06 7:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-04 4:04 [PATCH] usb: phy: generic: request regulator optionally Stefan Agner
2016-09-06 7:45 ` Felipe Balbi [this message]
2016-09-06 8:22 ` Mark Brown
2016-09-06 18:01 ` Stefan Agner
2016-09-07 7:25 ` Roger Quadros
2016-09-07 8:03 ` Felipe Balbi
2016-09-07 18:53 ` Mark Brown
2016-09-07 20:32 ` Stefan Agner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mvjlmpyo.fsf@linux.intel.com \
--to=balbi@kernel.org \
--cc=broonie@kernel.org \
--cc=fabio.estevam@nxp.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stefan@agner.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).