diff options
author | Marek Vasut <marex@denx.de> | 2013-07-10 03:16:30 +0200 |
---|---|---|
committer | Marek Vasut <marex@denx.de> | 2013-07-29 23:01:31 +0200 |
commit | 2ea4b44832eee9a85167bd2a54a7b603618d80b0 (patch) | |
tree | c976a16d532e91bf39e4f2dee510efccb5dc1855 /drivers/usb/gadget | |
parent | 532d846f891f31e2582428d7572b98103e3ec268 (diff) | |
download | u-boot-imx-2ea4b44832eee9a85167bd2a54a7b603618d80b0.zip u-boot-imx-2ea4b44832eee9a85167bd2a54a7b603618d80b0.tar.gz u-boot-imx-2ea4b44832eee9a85167bd2a54a7b603618d80b0.tar.bz2 |
usb: mv_udc: Clean up the EP initialization
Move the constant values that are programmed into mv_ep.ep into
separate static const structure so they can be memcpy()'d when
the initialization happens.
Moveover, we only every init NUM_ENDPOINTS, not 2 * NUM_ENDPOINTS,
so fix this bug as well.
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Lei Wen <leiwen@marvell.com>
Cc: Otavio Salvador <otavio@ossystems.com.br>
Cc: Stefano Babic <sbabic@denx.de>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r-- | drivers/usb/gadget/mv_udc.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/drivers/usb/gadget/mv_udc.c b/drivers/usb/gadget/mv_udc.c index a667cf9..8dd776b 100644 --- a/drivers/usb/gadget/mv_udc.c +++ b/drivers/usb/gadget/mv_udc.c @@ -83,6 +83,20 @@ static struct usb_ep_ops mv_ep_ops = { .free_request = mv_ep_free_request, }; +/* Init values for USB endpoints. */ +static const struct usb_ep mv_ep_init[2] = { + [0] = { /* EP 0 */ + .maxpacket = 64, + .name = "ep0", + .ops = &mv_ep_ops, + }, + [1] = { /* EP 1..n */ + .maxpacket = 512, + .name = "ep-", + .ops = &mv_ep_ops, + }, +}; + static struct mv_drv controller = { .gadget = { .name = "mv_udc", @@ -435,21 +449,21 @@ static int mvudc_probe(void) } INIT_LIST_HEAD(&controller.gadget.ep_list); - controller.gadget.ep0 = &controller.ep[0].ep; - controller.ep[0].ep.maxpacket = 64; - controller.ep[0].ep.name = "ep0"; + + /* Init EP 0 */ + memcpy(&controller.ep[0].ep, &mv_ep_init[0], sizeof(*mv_ep_init)); controller.ep[0].desc = &ep0_in_desc; + controller.gadget.ep0 = &controller.ep[0].ep; INIT_LIST_HEAD(&controller.gadget.ep0->ep_list); - for (i = 0; i < 2 * NUM_ENDPOINTS; i++) { - if (i != 0) { - controller.ep[i].ep.maxpacket = 512; - controller.ep[i].ep.name = "ep-"; - list_add_tail(&controller.ep[i].ep.ep_list, - &controller.gadget.ep_list); - controller.ep[i].desc = NULL; - } - controller.ep[i].ep.ops = &mv_ep_ops; + + /* Init EP 1..n */ + for (i = 1; i < NUM_ENDPOINTS; i++) { + memcpy(&controller.ep[i].ep, &mv_ep_init[1], + sizeof(*mv_ep_init)); + list_add_tail(&controller.ep[i].ep.ep_list, + &controller.gadget.ep_list); } + return 0; } |