From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Felipe Balbi <balbi@kernel.org>,
linux-usb@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH v1] usb: dwc3: Simplify with dev_err_probe()
Date: Wed, 25 Nov 2020 18:24:02 +0200 [thread overview]
Message-ID: <20201125162402.GA4077@smile.fi.intel.com> (raw)
In-Reply-To: <20201020083815.89275-1-andriy.shevchenko@linux.intel.com>
On Tue, Oct 20, 2020 at 11:38:15AM +0300, Andy Shevchenko wrote:
> Common pattern of handling deferred probe can be simplified with
> dev_err_probe(). Less code and the error value gets printed.
Felipe, any comments?
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/usb/dwc3/core.c | 44 +++++++++++------------------------------
> 1 file changed, 11 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index bdf0925da6b6..8787dff5342e 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -1126,11 +1126,8 @@ static int dwc3_core_get_phy(struct dwc3 *dwc)
> ret = PTR_ERR(dwc->usb2_phy);
> if (ret == -ENXIO || ret == -ENODEV) {
> dwc->usb2_phy = NULL;
> - } else if (ret == -EPROBE_DEFER) {
> - return ret;
> } else {
> - dev_err(dev, "no usb2 phy configured\n");
> - return ret;
> + return dev_err_probe(dev, ret, "no usb2 phy configured\n");
> }
> }
>
> @@ -1138,11 +1135,8 @@ static int dwc3_core_get_phy(struct dwc3 *dwc)
> ret = PTR_ERR(dwc->usb3_phy);
> if (ret == -ENXIO || ret == -ENODEV) {
> dwc->usb3_phy = NULL;
> - } else if (ret == -EPROBE_DEFER) {
> - return ret;
> } else {
> - dev_err(dev, "no usb3 phy configured\n");
> - return ret;
> + return dev_err_probe(dev, ret, "no usb3 phy configured\n");
> }
> }
>
> @@ -1151,11 +1145,8 @@ static int dwc3_core_get_phy(struct dwc3 *dwc)
> ret = PTR_ERR(dwc->usb2_generic_phy);
> if (ret == -ENOSYS || ret == -ENODEV) {
> dwc->usb2_generic_phy = NULL;
> - } else if (ret == -EPROBE_DEFER) {
> - return ret;
> } else {
> - dev_err(dev, "no usb2 phy configured\n");
> - return ret;
> + return dev_err_probe(dev, ret, "no usb2 phy configured\n");
> }
> }
>
> @@ -1164,11 +1155,8 @@ static int dwc3_core_get_phy(struct dwc3 *dwc)
> ret = PTR_ERR(dwc->usb3_generic_phy);
> if (ret == -ENOSYS || ret == -ENODEV) {
> dwc->usb3_generic_phy = NULL;
> - } else if (ret == -EPROBE_DEFER) {
> - return ret;
> } else {
> - dev_err(dev, "no usb3 phy configured\n");
> - return ret;
> + return dev_err_probe(dev, ret, "no usb3 phy configured\n");
> }
> }
>
> @@ -1190,11 +1178,8 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
> phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_DEVICE);
>
> ret = dwc3_gadget_init(dwc);
> - if (ret) {
> - if (ret != -EPROBE_DEFER)
> - dev_err(dev, "failed to initialize gadget\n");
> - return ret;
> - }
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to initialize gadget\n");
> break;
> case USB_DR_MODE_HOST:
> dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_HOST);
> @@ -1205,20 +1190,14 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
> phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_HOST);
>
> ret = dwc3_host_init(dwc);
> - if (ret) {
> - if (ret != -EPROBE_DEFER)
> - dev_err(dev, "failed to initialize host\n");
> - return ret;
> - }
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to initialize host\n");
> break;
> case USB_DR_MODE_OTG:
> INIT_WORK(&dwc->drd_work, __dwc3_set_mode);
> ret = dwc3_drd_init(dwc);
> - if (ret) {
> - if (ret != -EPROBE_DEFER)
> - dev_err(dev, "failed to initialize dual-role\n");
> - return ret;
> - }
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to initialize dual-role\n");
> break;
> default:
> dev_err(dev, "Unsupported mode of operation %d\n", dwc->dr_mode);
> @@ -1555,8 +1534,7 @@ static int dwc3_probe(struct platform_device *pdev)
>
> ret = dwc3_core_init(dwc);
> if (ret) {
> - if (ret != -EPROBE_DEFER)
> - dev_err(dev, "failed to initialize core: %d\n", ret);
> + dev_err_probe(dev, ret, "failed to initialize core\n");
> goto err4;
> }
>
> --
> 2.28.0
>
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2020-11-25 16:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-20 8:38 [PATCH v1] usb: dwc3: Simplify with dev_err_probe() Andy Shevchenko
2020-11-25 16:24 ` Andy Shevchenko [this message]
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=20201125162402.GA4077@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
/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).