usb: gadget: udc: atmel: simplify endpoint allocation

Simplify the endpoint allocation and cleanup the code.

Signed-off-by: Cristian Birsan <cristian.birsan@microchip.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
This commit is contained in:
Cristian Birsan 2020-07-23 21:48:59 +03:00 committed by Felipe Balbi
parent 96f314987a
commit 033b8966e9
2 changed files with 8 additions and 14 deletions

View File

@ -1091,8 +1091,6 @@ found_ep:
USBA_BF(EPT_SIZE, fls(ep->fifo_size - 1) - 3);
ep->ept_cfg |= USBA_BF(BK_NUMBER, ep->nr_banks);
ep->udc->configured_ep++;
}
return _ep;
@ -1786,7 +1784,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
if (status & USBA_END_OF_RESET) {
struct usba_ep *ep0, *ep;
int i, n;
int i;
usba_writel(udc, INT_CLR,
USBA_END_OF_RESET|USBA_END_OF_RESUME
@ -1834,13 +1832,14 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
"ODD: EP0 configuration is invalid!\n");
/* Preallocate other endpoints */
n = fifo_mode ? udc->num_ep : udc->configured_ep;
for (i = 1; i < n; i++) {
for (i = 1; i < udc->num_ep; i++) {
ep = &udc->usba_ep[i];
usba_ep_writel(ep, CFG, ep->ept_cfg);
if (!(usba_ep_readl(ep, CFG) & USBA_EPT_MAPPED))
dev_err(&udc->pdev->dev,
"ODD: EP%d configuration is invalid!\n", i);
if (ep->ep.claimed) {
usba_ep_writel(ep, CFG, ep->ept_cfg);
if (!(usba_ep_readl(ep, CFG) & USBA_EPT_MAPPED))
dev_err(&udc->pdev->dev,
"ODD: EP%d configuration is invalid!\n", i);
}
}
}
@ -2025,9 +2024,6 @@ static int atmel_usba_stop(struct usb_gadget *gadget)
if (udc->vbus_pin)
disable_irq(gpiod_to_irq(udc->vbus_pin));
if (fifo_mode == 0)
udc->configured_ep = 1;
udc->suspended = false;
usba_stop(udc);
@ -2154,7 +2150,6 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev,
if (fifo_mode == 0) {
udc->num_ep = udc_config->num_ep;
udc->configured_ep = 1;
} else {
udc->num_ep = usba_config_fifo_table(udc);
}

View File

@ -336,7 +336,6 @@ struct usba_udc {
int irq;
struct gpio_desc *vbus_pin;
int num_ep;
int configured_ep;
struct usba_fifo_cfg *fifo_cfg;
struct clk *pclk;
struct clk *hclk;