Skip to content

Commit 033cc63

Browse files
committed
usb: gadget: udc: atmel: simplify endpoint allocation
Simplify the endpoint allocation and cleanup the code. Signed-off-by: Cristian Birsan <cristian.birsan@microchip.com>
1 parent 6d1a60b commit 033cc63

2 files changed

Lines changed: 8 additions & 14 deletions

File tree

drivers/usb/gadget/udc/atmel_usba_udc.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,6 @@ static struct usb_ep *atmel_usba_match_ep(struct usb_gadget *gadget,
10961096

10971097
ep->ept_cfg |= USBA_BF(BK_NUMBER, ep->nr_banks);
10981098

1099-
ep->udc->configured_ep++;
11001099
}
11011100

11021101
return _ep;
@@ -1789,7 +1788,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
17891788

17901789
if (status & USBA_END_OF_RESET) {
17911790
struct usba_ep *ep0, *ep;
1792-
int i, n;
1791+
int i;
17931792

17941793
usba_writel(udc, INT_CLR,
17951794
USBA_END_OF_RESET|USBA_END_OF_RESUME
@@ -1837,13 +1836,14 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
18371836
"ODD: EP0 configuration is invalid!\n");
18381837

18391838
/* Preallocate other endpoints */
1840-
n = fifo_mode ? udc->num_ep : udc->configured_ep;
1841-
for (i = 1; i < n; i++) {
1839+
for (i = 1; i < udc->num_ep; i++) {
18421840
ep = &udc->usba_ep[i];
1843-
usba_ep_writel(ep, CFG, ep->ept_cfg);
1844-
if (!(usba_ep_readl(ep, CFG) & USBA_EPT_MAPPED))
1845-
dev_err(&udc->pdev->dev,
1846-
"ODD: EP%d configuration is invalid!\n", i);
1841+
if (ep->ep.claimed) {
1842+
usba_ep_writel(ep, CFG, ep->ept_cfg);
1843+
if (!(usba_ep_readl(ep, CFG) & USBA_EPT_MAPPED))
1844+
dev_err(&udc->pdev->dev,
1845+
"ODD: EP%d configuration is invalid!\n", i);
1846+
}
18471847
}
18481848
}
18491849

@@ -2010,10 +2010,6 @@ static int atmel_usba_stop(struct usb_gadget *gadget)
20102010
if (udc->vbus_pin)
20112011
disable_irq(gpiod_to_irq(udc->vbus_pin));
20122012

2013-
if (fifo_mode == 0)
2014-
udc->configured_ep = 1;
2015-
2016-
udc->suspended = false;
20172013
usba_stop(udc);
20182014

20192015
udc->driver = NULL;
@@ -2095,7 +2091,6 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev,
20952091
pp = NULL;
20962092
while ((pp = of_get_next_child(np, pp)))
20972093
udc->num_ep++;
2098-
udc->configured_ep = 1;
20992094
} else {
21002095
udc->num_ep = usba_config_fifo_table(udc);
21012096
}

drivers/usb/gadget/udc/atmel_usba_udc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ struct usba_udc {
324324
int irq;
325325
struct gpio_desc *vbus_pin;
326326
int num_ep;
327-
int configured_ep;
328327
struct usba_fifo_cfg *fifo_cfg;
329328
struct clk *pclk;
330329
struct clk *hclk;

0 commit comments

Comments
 (0)