drivers: udc_dwc2: Do not enable inactive endpoint
Fail TxFIFO write if the endpoint is not activated, because there is essentially no fifo assigned. Writing to not activated endpoint is possible, but it does tend to corrupt fifo number 0 which is used for control transfers. USB stack should not really be attempting to write to endpoints that have not been activated (ep_enable called). Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
This commit is contained in:
parent
c3daf6f220
commit
0b242dea42
1 changed files with 9 additions and 0 deletions
|
@ -409,6 +409,15 @@ static int dwc2_tx_fifo_write(const struct device *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
diepctl = sys_read32(diepctl_reg);
|
diepctl = sys_read32(diepctl_reg);
|
||||||
|
if (!(diepctl & USB_DWC2_DEPCTL_USBACTEP)) {
|
||||||
|
/* Do not attempt to write data on inactive endpoint, because
|
||||||
|
* no fifo is assigned to inactive endpoint and therefore it is
|
||||||
|
* possible that the write will corrupt other endpoint fifo.
|
||||||
|
*/
|
||||||
|
irq_unlock(key);
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
if (is_iso) {
|
if (is_iso) {
|
||||||
if (priv->sof_num & 1) {
|
if (priv->sof_num & 1) {
|
||||||
diepctl |= USB_DWC2_DEPCTL_SETODDFR;
|
diepctl |= USB_DWC2_DEPCTL_SETODDFR;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue