diff options
author | Michael Grzeschik <m.grzeschik@pengutronix.de> | 2020-12-17 12:07:30 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-01-06 11:00:32 +0100 |
commit | e3fba99f5b5ce398b6a0f6afe12d4ab660bfcc2c (patch) | |
tree | cabbd14e9cd2f19f732088b88d39b380aa2f3554 | |
parent | 8e256e6664ba9b979bbbce353856ee826e6a66ff (diff) | |
download | barebox-e3fba99f5b5ce398b6a0f6afe12d4ab660bfcc2c.tar.gz barebox-e3fba99f5b5ce398b6a0f6afe12d4ab660bfcc2c.tar.xz |
usb: dwc2: update the dr_mode on set_mode callback
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>
Tested-by: Jules Maselbas <jmaselbas@kalray.eu>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | drivers/usb/dwc2/dwc2.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/usb/dwc2/dwc2.c b/drivers/usb/dwc2/dwc2.c index 0f011e08a6..e1a3117925 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; } |