mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Michael Grzeschik <m.grzeschik@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH v2 4/5] usb: dwc2: update the dr_mode on set_mode callback
Date: Thu, 17 Dec 2020 12:07:30 +0100	[thread overview]
Message-ID: <20201217110731.14914-5-m.grzeschik@pengutronix.de> (raw)
In-Reply-To: <20201217110731.14914-1-m.grzeschik@pengutronix.de>

The dwc2 dr_mode can be configured with otg.mode in otg mode. Currently
the mode will not be set with the users decision. This patch fixes this
by overwriting the mode with the one set by set_mode callback.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
 drivers/usb/dwc2/dwc2.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/dwc2/dwc2.c b/drivers/usb/dwc2/dwc2.c
index 6f5127fc3b..65b92b542e 100644
--- a/drivers/usb/dwc2/dwc2.c
+++ b/drivers/usb/dwc2/dwc2.c
@@ -20,6 +20,9 @@ static int dwc2_set_mode(void *ctx, enum usb_dr_mode mode)
 {
 	struct dwc2 *dwc2 = ctx;
 	int ret = -ENODEV;
+	int oldmode = dwc2->dr_mode;
+
+	dwc2->dr_mode = mode;
 
 	if (mode == USB_DR_MODE_HOST || mode == USB_DR_MODE_OTG) {
 		if (IS_ENABLED(CONFIG_USB_DWC2_HOST))
@@ -34,6 +37,9 @@ static int dwc2_set_mode(void *ctx, enum usb_dr_mode mode)
 			dwc2_err(dwc2, "Peripheral support not available\n");
 	}
 
+	if (ret)
+		dwc2->dr_mode = oldmode;
+
 	return ret;
 }
 
-- 
2.29.2


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

  parent reply	other threads:[~2020-12-17 11:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-17 11:07 [PATCH v2 0/5] dwc2: improve gadget support Michael Grzeschik
2020-12-17 11:07 ` [PATCH v2 1/5] usb: dwc2: cleanup on error for deferred probing Michael Grzeschik
2020-12-17 11:07 ` [PATCH v2 2/5] usb: dwc2: add clk dependency for probe via oftree Michael Grzeschik
2021-01-06  8:57   ` Sascha Hauer
2021-01-06  9:42   ` [PATCH] fixup! " Michael Grzeschik
2020-12-17 11:07 ` [PATCH v2 3/5] usb: dwc2: add reset controller " Michael Grzeschik
2020-12-17 11:07 ` Michael Grzeschik [this message]
2020-12-17 11:07 ` [PATCH v2 5/5] usb: dwc2: add support to force gadget mode Michael Grzeschik
2020-12-17 11:39 ` [PATCH v2 0/5] dwc2: improve gadget support Jules Maselbas
2021-01-06 10:00 ` 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=20201217110731.14914-5-m.grzeschik@pengutronix.de \
    --to=m.grzeschik@pengutronix.de \
    --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