mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Denis Orlov <denorl2009@gmail.com>
To: barebox@lists.infradead.org
Cc: Denis Orlov <denorl2009@gmail.com>
Subject: [PATCH 2/2] usb: host: ehci: reorder code in ehci_probe()
Date: Tue,  1 Mar 2022 12:14:23 +0300	[thread overview]
Message-ID: <20220301091423.19871-2-denorl2009@gmail.com> (raw)
In-Reply-To: <20220301091423.19871-1-denorl2009@gmail.com>

Currently, after successful memory region requests the driver
initialization could still fail, leaving those regions allocated. By
reordering the code those requests can be placed later, after the
possibly failing calls.

Signed-off-by: Denis Orlov <denorl2009@gmail.com>
---
 drivers/usb/host/ehci-hcd.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index facfb3a95b..068504557b 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1421,20 +1421,6 @@ static int ehci_probe(struct device_d *dev)
 		 */
 		data.flags = EHCI_HAS_TT;
 
-	iores = dev_request_mem_resource(dev, 0);
-	if (IS_ERR(iores))
-		return PTR_ERR(iores);
-	data.hccr = IOMEM(iores->start);
-
-	if (dev->num_resources > 1) {
-		iores = dev_request_mem_resource(dev, 1);
-		if (IS_ERR(iores))
-			return PTR_ERR(iores);
-		data.hcor = IOMEM(iores->start);
-	}
-	else
-		data.hcor = NULL;
-
 	usb2_generic_phy = phy_optional_get(dev, "usb");
 	if (IS_ERR(usb2_generic_phy))
 		return PTR_ERR(usb2_generic_phy);
@@ -1456,6 +1442,20 @@ static int ehci_probe(struct device_d *dev)
 	if (ret)
 		return ret;
 
+	iores = dev_request_mem_resource(dev, 0);
+	if (IS_ERR(iores))
+		return PTR_ERR(iores);
+	data.hccr = IOMEM(iores->start);
+
+	if (dev->num_resources > 1) {
+		iores = dev_request_mem_resource(dev, 1);
+		if (IS_ERR(iores))
+			return PTR_ERR(iores);
+		data.hcor = IOMEM(iores->start);
+	}
+	else
+		data.hcor = NULL;
+
 	ehci = ehci_register(dev, &data);
 	if (IS_ERR(ehci))
 		return PTR_ERR(ehci);
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  reply	other threads:[~2022-03-01  9:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-01  9:14 [PATCH 1/2] usb: host: ehci: add GENERIC_PHY dependency to Kconfig Denis Orlov
2022-03-01  9:14 ` Denis Orlov [this message]
2022-03-03  9:55 ` Sascha Hauer

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=20220301091423.19871-2-denorl2009@gmail.com \
    --to=denorl2009@gmail.com \
    --cc=barebox@lists.infradead.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