@@ -231,7 +231,7 @@ pub fn validate_controller(T: type) void {
231231/// Responds to host requests and dispatches to the appropriate drivers.
232232/// When this type is build (at comptime), it builds descriptor and handler tables based on the
233233/// provided config.
234- pub fn DeviceController (config : Config , driver_args : config .DriverArgs ()) type {
234+ pub fn DeviceController (comptime config : Config , comptime driver_args : config .DriverArgs ()) type {
235235 std .debug .assert (config .configurations .len == 1 );
236236
237237 return struct {
@@ -347,11 +347,9 @@ pub fn DeviceController(config: Config, driver_args: config.DriverArgs()) type {
347347 field_attrs [drv_id ] = .{ .default_value_ptr = & descriptors };
348348 }
349349
350- // Finally, bind the handler functions based on the data collected above.
351- const Tuple = std .meta .Tuple ;
352350 // Create a tuple with the appropriate types
353- const ep_handlers_types : [2 ]type = .{ Tuple (& ep_handler_types [0 ]), Tuple (& ep_handler_types [1 ]) };
354- var ep_handlers : Tuple (& ep_handlers_types ) = undefined ;
351+ const ep_handlers_types : [2 ]type = .{ @ Tuple (& ep_handler_types [0 ]), @ Tuple (& ep_handler_types [1 ]) };
352+ var ep_handlers : @ Tuple (& ep_handlers_types ) = undefined ;
355353 // Iterate over all IN and OUT endpoints and bind the handler for any that are set.
356354 for (& ep_handler_types , & ep_handler_names , & ep_handler_drivers , 0.. ) | htypes , hnames , hdrivers , dir | {
357355 for (& htypes , & hnames , & hdrivers , 0.. ) | T , name , drv_id , ep | {
@@ -363,25 +361,34 @@ pub fn DeviceController(config: Config, driver_args: config.DriverArgs()) type {
363361 const DriverConfig = @Struct (.@"extern" , null , & field_names , & field_types , & field_attrs );
364362 const idx_in = @intFromEnum (types .Dir .In );
365363 const idx_out = @intFromEnum (types .Dir .Out );
364+
365+ const ConfigDescriptor = extern struct {
366+ first : descriptor.Configuration ,
367+ drv : DriverConfig ,
368+ };
369+ const Handlers_EP = struct {
370+ In : ep_handlers_types [idx_in ],
371+ Out : ep_handlers_types [idx_out ],
372+ };
366373 break :blk .{
367374 .device_descriptor = desc_device ,
368- .config_descriptor = extern struct {
369- first : descriptor.Configuration = .{
375+ .config_descriptor = ConfigDescriptor {
376+ . first = .{
370377 .total_length = .from (size ),
371378 .num_interfaces = alloc .next_itf_num ,
372379 .configuration_value = 1 ,
373380 .configuration_s = configuration_s ,
374381 .attributes = config0 .attributes ,
375382 .max_current = .from_ma (config0 .max_current_ma ),
376383 },
377- drv : DriverConfig = .{},
378- }{} ,
384+ . drv = .{},
385+ },
379386 .string_descriptors = alloc .string_descriptors (config .language ),
380387 .handlers_itf = itf_handlers ,
381- .handlers_ep = struct {
382- In : ep_handlers_types [ idx_in ] = ep_handlers [idx_in ],
383- Out : ep_handlers_types [ idx_out ] = ep_handlers [idx_out ],
384- }{} ,
388+ .handlers_ep = Handlers_EP {
389+ . In = ep_handlers [idx_in ],
390+ . Out = ep_handlers [idx_out ],
391+ },
385392 .drivers_ep = ep_handler_drivers ,
386393 .DriverAlloc = @Struct (
387394 .auto ,
0 commit comments