mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jules Maselbas <jmaselbas@kalray.eu>
To: barebox@lists.infradead.org
Cc: Jules Maselbas <jmaselbas@kalray.eu>
Subject: [PATCH 3/4] usb: dwc2: Fix mode check in dwc2_get_dr_mode
Date: Wed,  9 Dec 2020 15:55:46 +0100	[thread overview]
Message-ID: <20201209145547.22655-3-jmaselbas@kalray.eu> (raw)
In-Reply-To: <20201209145547.22655-1-jmaselbas@kalray.eu>

In Linux, configs CONFIG_USB_DWC2_HOST and CONFIG_USB_DWC2_GADGET
are respectively for host only and gadget only support, they are
mutually exclusive. However this is not the case in barebox, they
are independent options.

Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
 drivers/usb/dwc2/core.c | 14 ++++++--------
 drivers/usb/dwc2/dwc2.c |  2 ++
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index a61acf553..808d80585 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -654,18 +654,16 @@ int dwc2_get_dr_mode(struct dwc2 *dwc2)
 
 	if (dwc2_hw_is_device(dwc2)) {
 		dwc2_dbg(dwc2, "Controller is device only\n");
-		if (IS_ENABLED(CONFIG_USB_DWC2_HOST)) {
-			dwc2_err(dwc2,
-				"Controller does not support host mode.\n");
-			return -EINVAL;
+		if (!IS_ENABLED(CONFIG_USB_DWC2_GADGET)) {
+			dwc2_err(dwc2, "gadget mode support not compiled in!\n");
+			return -ENOTSUPP;
 		}
 		mode = USB_DR_MODE_PERIPHERAL;
 	} else if (dwc2_hw_is_host(dwc2)) {
 		dwc2_dbg(dwc2, "Controller is host only\n");
-		if (IS_ENABLED(CONFIG_USB_DWC2_GADGET)) {
-			dwc2_err(dwc2,
-				"Controller does not support device mode.\n");
-			return -EINVAL;
+		if (!IS_ENABLED(CONFIG_USB_DWC2_HOST)) {
+			dwc2_err(dwc2, "host mode support not compiled in!\n");
+			return -ENOTSUPP;
 		}
 		mode = USB_DR_MODE_HOST;
 	} else {
diff --git a/drivers/usb/dwc2/dwc2.c b/drivers/usb/dwc2/dwc2.c
index ae144698c..120890105 100644
--- a/drivers/usb/dwc2/dwc2.c
+++ b/drivers/usb/dwc2/dwc2.c
@@ -77,6 +77,8 @@ static int dwc2_probe(struct device_d *dev)
 	dwc2_get_hwparams(dwc2);
 
 	ret = dwc2_get_dr_mode(dwc2);
+	if (ret)
+		goto error;
 
 	dwc2_set_default_params(dwc2);
 
-- 
2.17.1



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

  parent reply	other threads:[~2020-12-09 14:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-09 14:55 [PATCH 1/4] usb: dwc2: Add support for optional usb phy Jules Maselbas
2020-12-09 14:55 ` [PATCH 2/4] usb: dwc2: Move static function prototypes into core.c Jules Maselbas
2020-12-10 10:05   ` Sascha Hauer
2020-12-10 10:18     ` Jules Maselbas
2020-12-09 14:55 ` Jules Maselbas [this message]
2020-12-09 14:55 ` [PATCH 4/4] usb: dwc2: Rename dwc2_core_snpsid to dwc2_check_core_version Jules Maselbas
2020-12-09 19:14 ` [PATCH 1/4] usb: dwc2: Add support for optional usb phy Michael Grzeschik

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=20201209145547.22655-3-jmaselbas@kalray.eu \
    --to=jmaselbas@kalray.eu \
    --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