Re: [PATCH] usb: gadget: lpc32xx_udc: Port to new start/stop interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/17/2012 01:02 PM, Felipe Balbi wrote:
> On Fri, Aug 17, 2012 at 01:01:44PM +0200, Sebastian Andrzej Siewior wrote:
>> On 08/17/2012 12:51 PM, Felipe Balbi wrote:
>>>> Sounds reasonable?
>>>
>>> no it doesn't. Please remove that static global. Sorry but one of the
>>> goals with udc_start/udc_stop was really to get rid of all those
>>> nonsensical static globals.
>>
>> I wouldn't insist on it. If you look at pxa25x, " static struct
>> pxa25x_udc memory = {" they do the same thing. It is only a simple way
>> to onetime initialize variables.
> 
> fair enough. Though that's wrong too and should be changed. The whole
> idea of allowing multiple UDCs on the same kernel image is mostly to aid
> development. Specially on pre-silicon phase. We could have a bunch of
> PCIe FPGA boards and instantiate a different controller on each one and
> have the same kernel work with them all.

Yes, that's a good thing and I like to support it.

How about the following: Below, I show how the initialization of the
current controller is done (statically). Removing this struct
initialization completely would make the code much uglier, introducing
many individual assignments.

Would it be OK to kzalloc() on initialization to enable multiple UDCs
and then memcpy() from a statically prepared template as below? (Some
dynamic pointer adjustments necessary, of course.)

Thanks in advance,

Roland



static struct lpc32xx_udc controller = {
        .gadget = {
                .ops    = &lpc32xx_udc_ops,
                .ep0    = &controller.ep[0].ep,
                .name   = driver_name,
                .dev    = {
                        .init_name = "gadget",
                        .release = nop_release,
                }
        },
        .ep[0] = {
                .ep = {
                        .name   = "ep0",
                        .ops    = &lpc32xx_ep_ops,
                },
                .udc            = &controller,
                .maxpacket      = 64,
                .hwep_num_base  = 0,
                .hwep_num       = 0, /* Can be 0 or 1, has special
handling */
                .lep            = 0,
                .eptype         = EP_CTL_TYPE,
        },
        .ep[1] = {
                .ep = {
                        .name   = "ep1-int",
                        .ops    = &lpc32xx_ep_ops,
                },
                .udc            = &controller,
                .maxpacket      = 64,
                .hwep_num_base  = 2,
                .hwep_num       = 0, /* 2 or 3, will be set later */
                .lep            = 1,
                .eptype         = EP_INT_TYPE,
        },
        .ep[2] = {
                .ep = {
                        .name   = "ep2-bulk",
                        .ops    = &lpc32xx_ep_ops,
                },
                .udc            = &controller,
                .maxpacket      = 64,
                .hwep_num_base  = 4,
                .hwep_num       = 0, /* 4 or 5, will be set later */
                .lep            = 2,
                .eptype         = EP_BLK_TYPE,
        },
        .ep[3] = {
                .ep = {
                        .name   = "ep3-iso",
                        .ops    = &lpc32xx_ep_ops,
                },
                .udc            = &controller,
                .maxpacket      = 1023,
                .hwep_num_base  = 6,
                .hwep_num       = 0, /* 6 or 7, will be set later */
                .lep            = 3,
                .eptype         = EP_ISO_TYPE,
        },
        .ep[4] = {
                .ep = {
                        .name   = "ep4-int",
                        .ops    = &lpc32xx_ep_ops,
                },
                .udc            = &controller,
                .maxpacket      = 64,
                .hwep_num_base  = 8,
                .hwep_num       = 0, /* 8 or 9, will be set later */
                .lep            = 4,
                .eptype         = EP_INT_TYPE,
        },
        .ep[5] = {
                .ep = {
                        .name   = "ep5-bulk",
                        .ops    = &lpc32xx_ep_ops,
                },
                .udc            = &controller,
                .maxpacket      = 64,
                .hwep_num_base  = 10,
                .hwep_num       = 0, /* 10 or 11, will be set later */
                .lep            = 5,
                .eptype         = EP_BLK_TYPE,
        },
        .ep[6] = {
                .ep = {
                        .name   = "ep6-iso",
                        .ops    = &lpc32xx_ep_ops,
                },
                .udc            = &controller,
                .maxpacket      = 1023,
                .hwep_num_base  = 12,
                .hwep_num       = 0, /* 12 or 13, will be set later */
                .lep            = 6,
                .eptype         = EP_ISO_TYPE,
        },
        .ep[7] = {
                .ep = {
                        .name   = "ep7-int",
                        .ops    = &lpc32xx_ep_ops,
                },
                .udc            = &controller,
                .maxpacket      = 64,
                .hwep_num_base  = 14,
                .hwep_num       = 0,
                .lep            = 7,
                .eptype         = EP_INT_TYPE,
        },
        .ep[8] = {
                .ep = {
                        .name   = "ep8-bulk",
                        .ops    = &lpc32xx_ep_ops,
                },
                .udc            = &controller,
                .maxpacket      = 64,
                .hwep_num_base  = 16,
                .hwep_num       = 0,
                .lep            = 8,
                .eptype         = EP_BLK_TYPE,
        },
        .ep[9] = {
                .ep = {
                        .name   = "ep9-iso",
                        .ops    = &lpc32xx_ep_ops,
                },
                .udc            = &controller,
                .maxpacket      = 1023,
                .hwep_num_base  = 18,
                .hwep_num       = 0,
                .lep            = 9,
                .eptype         = EP_ISO_TYPE,
        },
        .ep[10] = {
                .ep = {
                        .name   = "ep10-int",
                        .ops    = &lpc32xx_ep_ops,
                },
                .udc            = &controller,
                .maxpacket      = 64,
                .hwep_num_base  = 20,
                .hwep_num       = 0,
                .lep            = 10,
                .eptype         = EP_INT_TYPE,
        },
        .ep[11] = {
                .ep = {
                        .name   = "ep11-bulk",
                        .ops    = &lpc32xx_ep_ops,
                },
                .udc            = &controller,
                .maxpacket      = 64,
                .hwep_num_base  = 22,
                .hwep_num       = 0,
                .lep            = 11,
                .eptype         = EP_BLK_TYPE,
        },
        .ep[12] = {
                .ep = {
                        .name   = "ep12-iso",
                        .ops    = &lpc32xx_ep_ops,
                },
                .udc            = &controller,
                .maxpacket      = 1023,
                .hwep_num_base  = 24,
                .hwep_num       = 0,
                .lep            = 12,
                .eptype         = EP_ISO_TYPE,
        },
        .ep[13] = {
                .ep = {
                        .name   = "ep13-int",
                        .ops    = &lpc32xx_ep_ops,
                },
                .udc            = &controller,
                .maxpacket      = 64,
                .hwep_num_base  = 26,
                .hwep_num       = 0,
                .lep            = 13,
                .eptype         = EP_INT_TYPE,
        },
        .ep[14] = {
                .ep = {
                        .name   = "ep14-bulk",
                        .ops    = &lpc32xx_ep_ops,
                },
                .udc            = &controller,
                .maxpacket      = 64,
                .hwep_num_base  = 28,
                .hwep_num       = 0,
                .lep            = 14,
                .eptype         = EP_BLK_TYPE,
        },
        .ep[15] = {
                .ep = {
                        .name   = "ep15-bulk",
                        .ops    = &lpc32xx_ep_ops,
                },
                .udc            = &controller,
                .maxpacket      = 1023,
                .hwep_num_base  = 30,
                .hwep_num       = 0,
                .lep            = 15,
                .eptype         = EP_BLK_TYPE,
        },
};
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux