diff options
author | John Youn <John.Youn@synopsys.com> | 2016-02-19 17:31:01 -0800 |
---|---|---|
committer | Felipe Balbi <balbi@kernel.org> | 2016-03-04 15:14:38 +0200 |
commit | 77966eb85e6d988a6daaf8ac14ac33026ceb3ab7 (patch) | |
tree | 139debb24a0669ad9d416b9f98ae3c5cf48c2d42 /drivers/usb/dwc3/core.c | |
parent | 5266a7603faa036f6707623ba76f054349050c85 (diff) | |
download | blackbird-obmc-linux-77966eb85e6d988a6daaf8ac14ac33026ceb3ab7.tar.gz blackbird-obmc-linux-77966eb85e6d988a6daaf8ac14ac33026ceb3ab7.zip |
usb: dwc3: Validate the maximum_speed parameter
Check that dwc->maximum_speed is set to a valid value. Also add an error
when we use it later if we encounter an invalid value.
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
Diffstat (limited to 'drivers/usb/dwc3/core.c')
-rw-r--r-- | drivers/usb/dwc3/core.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 001c755c83c0..17fd81447c9f 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1012,8 +1012,20 @@ static int dwc3_probe(struct platform_device *pdev) goto err1; } - /* default to superspeed if no maximum_speed passed */ - if (dwc->maximum_speed == USB_SPEED_UNKNOWN) { + /* Check the maximum_speed parameter */ + switch (dwc->maximum_speed) { + case USB_SPEED_LOW: + case USB_SPEED_FULL: + case USB_SPEED_HIGH: + case USB_SPEED_SUPER: + case USB_SPEED_SUPER_PLUS: + break; + default: + dev_err(dev, "invalid maximum_speed parameter %d\n", + dwc->maximum_speed); + /* fall through */ + case USB_SPEED_UNKNOWN: + /* default to superspeed */ dwc->maximum_speed = USB_SPEED_SUPER; /* @@ -1023,6 +1035,8 @@ static int dwc3_probe(struct platform_device *pdev) (DWC3_GHWPARAMS3_SSPHY_IFC(dwc->hwparams.hwparams3) == DWC3_GHWPARAMS3_SSPHY_IFC_GEN2)) dwc->maximum_speed = USB_SPEED_SUPER_PLUS; + + break; } /* Adjust Frame Length */ |