usb: consistently use named structure initializers

This commit is contained in:
Harald Welte
2017-03-06 09:55:37 +01:00
parent 912b183b29
commit 495a67da7d

View File

@@ -74,7 +74,7 @@ typedef struct _SIMTraceDriverConfigurationDescriptorSniffer {
static const SIMTraceDriverConfigurationDescriptorSniffer static const SIMTraceDriverConfigurationDescriptorSniffer
configurationDescriptorSniffer = { configurationDescriptorSniffer = {
/* Standard configuration descriptor */ /* Standard configuration descriptor */
{ .configuration = {
.bLength = sizeof(USBConfigurationDescriptor), .bLength = sizeof(USBConfigurationDescriptor),
.bDescriptorType = USBGenericDescriptor_CONFIGURATION, .bDescriptorType = USBGenericDescriptor_CONFIGURATION,
.wTotalLength = sizeof(SIMTraceDriverConfigurationDescriptorSniffer), .wTotalLength = sizeof(SIMTraceDriverConfigurationDescriptorSniffer),
@@ -85,7 +85,7 @@ static const SIMTraceDriverConfigurationDescriptorSniffer
.bMaxPower = USBConfigurationDescriptor_POWER(100), .bMaxPower = USBConfigurationDescriptor_POWER(100),
}, },
/* Communication class interface standard descriptor */ /* Communication class interface standard descriptor */
{ .sniffer = {
.bLength = sizeof(USBInterfaceDescriptor), .bLength = sizeof(USBInterfaceDescriptor),
.bDescriptorType = USBGenericDescriptor_INTERFACE, .bDescriptorType = USBGenericDescriptor_INTERFACE,
.bInterfaceNumber = 0, .bInterfaceNumber = 0,
@@ -97,7 +97,7 @@ static const SIMTraceDriverConfigurationDescriptorSniffer
.iInterface = SNIFFER_CONF_STR, .iInterface = SNIFFER_CONF_STR,
}, },
/* Bulk-OUT endpoint standard descriptor */ /* Bulk-OUT endpoint standard descriptor */
{ .sniffer_dataOut = {
.bLength = sizeof(USBEndpointDescriptor), .bLength = sizeof(USBEndpointDescriptor),
.bDescriptorType = USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS( .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
@@ -110,7 +110,7 @@ static const SIMTraceDriverConfigurationDescriptorSniffer
.bInterval = 0, .bInterval = 0,
}, },
/* Bulk-IN endpoint descriptor */ /* Bulk-IN endpoint descriptor */
{ .sniffer_dataIn = {
.bLength = sizeof(USBEndpointDescriptor), .bLength = sizeof(USBEndpointDescriptor),
.bDescriptorType = USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS( .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
@@ -123,7 +123,7 @@ static const SIMTraceDriverConfigurationDescriptorSniffer
.bInterval = 0, .bInterval = 0,
}, },
// Notification endpoint descriptor // Notification endpoint descriptor
{ .sniffer_interruptIn = {
.bLength = sizeof(USBEndpointDescriptor), .bLength = sizeof(USBEndpointDescriptor),
.bDescriptorType = USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS( .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
@@ -258,111 +258,117 @@ typedef struct _SIMTraceDriverConfigurationDescriptorPhone {
static const SIMTraceDriverConfigurationDescriptorPhone static const SIMTraceDriverConfigurationDescriptorPhone
configurationDescriptorPhone = { configurationDescriptorPhone = {
/* Standard configuration descriptor */ /* Standard configuration descriptor */
{ .configuration = {
sizeof(USBConfigurationDescriptor), .bLength = sizeof(USBConfigurationDescriptor),
USBGenericDescriptor_CONFIGURATION, .bDescriptorType = USBGenericDescriptor_CONFIGURATION,
sizeof(SIMTraceDriverConfigurationDescriptorPhone), .wTotalLength = sizeof(SIMTraceDriverConfigurationDescriptorPhone),
#ifdef CARDEMU_SECOND_UART #ifdef CARDEMU_SECOND_UART
2+DFURT_NUM_IF, .bNumInterfaces = 2+DFURT_NUM_IF,
#else #else
1+DFURT_NUM_IF, /* There is one interface in this configuration */ .bNumInterefaces = 1+DFURT_NUM_IF,
#endif #endif
CFG_NUM_PHONE, /* configuration number */ .bConfigurationValue = CFG_NUM_PHONE,
PHONE_CONF_STR, /* string descriptor for this configuration */ .iConfiguration = PHONE_CONF_STR,
USBD_BMATTRIBUTES, .bmAttributes = USBD_BMATTRIBUTES,
USBConfigurationDescriptor_POWER(100) .bMaxPower = USBConfigurationDescriptor_POWER(100)
}, },
/* Communication class interface standard descriptor */ /* Communication class interface standard descriptor */
{ .phone = {
sizeof(USBInterfaceDescriptor), .bLength = sizeof(USBInterfaceDescriptor),
USBGenericDescriptor_INTERFACE, .bDescriptorType = USBGenericDescriptor_INTERFACE,
0, /* This is interface #0 */ .bInterfaceNumber = 0,
0, /* This is alternate setting #0 for this interface */ .bAlternateSetting = 0,
3, /* Number of endpoints */ .bNumEndpoints = 3,
0xff, /* Descriptor Class: Vendor specific */ .bInterfaceClass = 0xff,
0, /* No subclass */ .bInterfaceSubClass = 0,
0, /* No l */ .bInterfaceProtocol = 0,
CARDEM_USIM1_INTF_STR .iInterface = CARDEM_USIM1_INTF_STR,
}, },
/* Bulk-OUT endpoint standard descriptor */ /* Bulk-OUT endpoint standard descriptor */
{ .phone_dataOut = {
sizeof(USBEndpointDescriptor), .bLength = sizeof(USBEndpointDescriptor),
USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
PHONE_DATAOUT), USBEndpointDescriptor_OUT,
USBEndpointDescriptor_BULK, PHONE_DATAOUT),
MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_DATAOUT), .bmAttributes = USBEndpointDescriptor_BULK,
USBEndpointDescriptor_MAXBULKSIZE_FS), .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_DATAOUT),
0 /* Must be 0 for full-speed bulk endpoints */ USBEndpointDescriptor_MAXBULKSIZE_FS),
.bInterval = 0 /* Must be 0 for full-speed bulk endpoints */
}, },
/* Bulk-IN endpoint descriptor */ /* Bulk-IN endpoint descriptor */
{ .phone_dataIn = {
sizeof(USBEndpointDescriptor), .bLength = sizeof(USBEndpointDescriptor),
USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
PHONE_DATAIN), USBEndpointDescriptor_IN,
USBEndpointDescriptor_BULK, PHONE_DATAIN),
MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_DATAIN), .bmAttributes = USBEndpointDescriptor_BULK,
USBEndpointDescriptor_MAXBULKSIZE_FS), .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_DATAIN),
0 /* Must be 0 for full-speed bulk endpoints */ USBEndpointDescriptor_MAXBULKSIZE_FS),
.bInterval = 0 /* Must be 0 for full-speed bulk endpoints */
}, },
/* Notification endpoint descriptor */ /* Notification endpoint descriptor */
{ .phone_interruptIn = {
sizeof(USBEndpointDescriptor), .bLength = sizeof(USBEndpointDescriptor),
USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
PHONE_INT), USBEndpointDescriptor_IN,
USBEndpointDescriptor_INTERRUPT, PHONE_INT),
MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_INT), .bmAttributes = USBEndpointDescriptor_INTERRUPT,
USBEndpointDescriptor_MAXINTERRUPTSIZE_FS), .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_INT),
0x10 USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
.bInterval = 0x10
}, },
#ifdef CARDEMU_SECOND_UART #ifdef CARDEMU_SECOND_UART
/* Communication class interface standard descriptor */ /* Communication class interface standard descriptor */
{ .usim2 = {
sizeof(USBInterfaceDescriptor), .bLength = sizeof(USBInterfaceDescriptor),
USBGenericDescriptor_INTERFACE, .bDescriptorType = USBGenericDescriptor_INTERFACE,
1, /* This is interface #1 */ .bInterfaceNumber = 1,
0, /* This is alternate setting #0 for this interface */ .bAlternateSetting = 0,
3, /* Number of endpoints */ .bNumEndpoints = 3,
0xff, /* Descriptor Class: Vendor specific */ .bInterfaceClass = 0xff,
0, /* No subclass */ .bInterfaceSubClass = 0,
0, /* No l */ .bInterfaceProtocol = 0,
CARDEM_USIM2_INTF_STR .iInterface = CARDEM_USIM2_INTF_STR,
}, },
/* Bulk-OUT endpoint standard descriptor */ /* Bulk-OUT endpoint standard descriptor */
{ .usim2_dataOut = {
sizeof(USBEndpointDescriptor), .bLength = sizeof(USBEndpointDescriptor),
USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
CARDEM_USIM2_DATAOUT), USBEndpointDescriptor_OUT,
USBEndpointDescriptor_BULK, CARDEM_USIM2_DATAOUT),
MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(CARDEM_USIM2_DATAOUT), .bmAttributes = USBEndpointDescriptor_BULK,
USBEndpointDescriptor_MAXBULKSIZE_FS), .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(CARDEM_USIM2_DATAOUT),
0 /* Must be 0 for full-speed bulk endpoints */ USBEndpointDescriptor_MAXBULKSIZE_FS),
.bInterval = 0 /* Must be 0 for full-speed bulk endpoints */
} }
, ,
/* Bulk-IN endpoint descriptor */ /* Bulk-IN endpoint descriptor */
{ .usim2_dataIn = {
sizeof(USBEndpointDescriptor), .bLength = sizeof(USBEndpointDescriptor),
USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
CARDEM_USIM2_DATAIN), USBEndpointDescriptor_IN,
USBEndpointDescriptor_BULK, CARDEM_USIM2_DATAIN),
MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(CARDEM_USIM2_DATAIN), .bmAttributes = USBEndpointDescriptor_BULK,
USBEndpointDescriptor_MAXBULKSIZE_FS), .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(CARDEM_USIM2_DATAIN),
0 /* Must be 0 for full-speed bulk endpoints */ USBEndpointDescriptor_MAXBULKSIZE_FS),
.bInterval = 0 /* Must be 0 for full-speed bulk endpoints */
}, },
/* Notification endpoint descriptor */ /* Notification endpoint descriptor */
{ .usim2_interruptIn = {
sizeof(USBEndpointDescriptor), .bLength = sizeof(USBEndpointDescriptor),
USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
CARDEM_USIM2_INT), USBEndpointDescriptor_IN,
USBEndpointDescriptor_INTERRUPT, CARDEM_USIM2_INT),
MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(CARDEM_USIM2_INT), .bmAttributes = USBEndpointDescriptor_INTERRUPT,
USBEndpointDescriptor_MAXINTERRUPTSIZE_FS), .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(CARDEM_USIM2_INT),
0x10 USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
.bInterval = 0x10,
}, },
DFURT_IF_DESCRIPTOR(2, 0), DFURT_IF_DESCRIPTOR(2, 0),
#else #else
@@ -397,20 +403,20 @@ typedef struct _SIMTraceDriverConfigurationDescriptorMITM {
static const SIMTraceDriverConfigurationDescriptorMITM static const SIMTraceDriverConfigurationDescriptorMITM
configurationDescriptorMITM = { configurationDescriptorMITM = {
/* Standard configuration descriptor */ /* Standard configuration descriptor */
{ .configuration = {
sizeof(USBConfigurationDescriptor), .bLength = sizeof(USBConfigurationDescriptor),
USBGenericDescriptor_CONFIGURATION, .bDescriptorType = USBGenericDescriptor_CONFIGURATION,
sizeof(SIMTraceDriverConfigurationDescriptorMITM), .wTotalLength = sizeof(SIMTraceDriverConfigurationDescriptorMITM),
2+DFURT_NUM_IF, /* There are two interfaces in this configuration */ .bNumInterfaces = 2+DFURT_NUM_IF,
CFG_NUM_MITM, /* configuration number */ .bConfigurationValue = CFG_NUM_MITM,
MITM_CONF_STR, /* string descriptor for this configuration */ .iConfiguration = MITM_CONF_STR,
USBD_BMATTRIBUTES, .bmAttributes = USBD_BMATTRIBUTES,
USBConfigurationDescriptor_POWER(100) .bMaxPower = USBConfigurationDescriptor_POWER(100),
}, },
// CCID interface descriptor // CCID interface descriptor
// Table 4.3-1 Interface Descriptor // Table 4.3-1 Interface Descriptor
// Interface descriptor // Interface descriptor
{ .simcard = {
.bLength = sizeof(USBInterfaceDescriptor), .bLength = sizeof(USBInterfaceDescriptor),
.bDescriptorType = USBGenericDescriptor_INTERFACE, .bDescriptorType = USBGenericDescriptor_INTERFACE,
.bInterfaceNumber = 0, .bInterfaceNumber = 0,
@@ -421,7 +427,7 @@ static const SIMTraceDriverConfigurationDescriptorMITM
.bInterfaceProtocol = 0, .bInterfaceProtocol = 0,
.iInterface = CCID_CONF_STR, .iInterface = CCID_CONF_STR,
}, },
{ .ccid = {
.bLength = sizeof(CCIDDescriptor), .bLength = sizeof(CCIDDescriptor),
.bDescriptorType = CCID_DECRIPTOR_TYPE, .bDescriptorType = CCID_DECRIPTOR_TYPE,
.bcdCCID = CCID1_10, // CCID version .bcdCCID = CCID1_10, // CCID version
@@ -450,7 +456,7 @@ static const SIMTraceDriverConfigurationDescriptorMITM
.bMaxCCIDBusySlots = 1, .bMaxCCIDBusySlots = 1,
}, },
// Bulk-OUT endpoint descriptor // Bulk-OUT endpoint descriptor
{ .simcard_dataOut = {
.bLength = sizeof(USBEndpointDescriptor), .bLength = sizeof(USBEndpointDescriptor),
.bDescriptorType = USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = .bEndpointAddress =
@@ -463,7 +469,7 @@ static const SIMTraceDriverConfigurationDescriptorMITM
.bInterval = 0x00, .bInterval = 0x00,
}, },
// Bulk-IN endpoint descriptor // Bulk-IN endpoint descriptor
{ .simcard_dataIn = {
.bLength = sizeof(USBEndpointDescriptor), .bLength = sizeof(USBEndpointDescriptor),
.bDescriptorType = USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = .bEndpointAddress =
@@ -476,7 +482,7 @@ static const SIMTraceDriverConfigurationDescriptorMITM
.bInterval = 0x00, .bInterval = 0x00,
}, },
// Notification endpoint descriptor // Notification endpoint descriptor
{ .simcard_interruptIn = {
.bLength = sizeof(USBEndpointDescriptor), .bLength = sizeof(USBEndpointDescriptor),
.bDescriptorType = USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = .bEndpointAddress =
@@ -490,51 +496,53 @@ static const SIMTraceDriverConfigurationDescriptorMITM
}, },
/* Communication class interface standard descriptor */ /* Communication class interface standard descriptor */
{ .phone = {
sizeof(USBInterfaceDescriptor), .bLength = sizeof(USBInterfaceDescriptor),
USBGenericDescriptor_INTERFACE, .bDescriptorType = USBGenericDescriptor_INTERFACE,
1, /* This is interface #1 */ .bInterfaceNumber = 1,
0, /* This is alternate setting #0 for this interface */ .bAlternateSetting = 0,
3, /* Number of endpoints */ .bNumEndpoints = 3,
0xff, .bInterfaceClass = 0xff,
0, .bInterfaceSubClass = 0,
0, .bInterfaceProtocol = 0,
PHONE_CONF_STR, /* string descriptor for this interface */ .iInterface = PHONE_CONF_STR,
} },
,
/* Bulk-OUT endpoint standard descriptor */ /* Bulk-OUT endpoint standard descriptor */
{ .phone_dataOut = {
sizeof(USBEndpointDescriptor), .bLength = sizeof(USBEndpointDescriptor),
USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
PHONE_DATAOUT), USBEndpointDescriptor_OUT,
USBEndpointDescriptor_BULK, PHONE_DATAOUT),
MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_DATAOUT), .bmAttributes = USBEndpointDescriptor_BULK,
USBEndpointDescriptor_MAXBULKSIZE_FS), .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_DATAOUT),
0 /* Must be 0 for full-speed bulk endpoints */ USBEndpointDescriptor_MAXBULKSIZE_FS),
} .bInterval = 0, /* Must be 0 for full-speed bulk endpoints */
, },
/* Bulk-IN endpoint descriptor */ /* Bulk-IN endpoint descriptor */
{ .phone_dataIn = {
sizeof(USBEndpointDescriptor), .bLength = sizeof(USBEndpointDescriptor),
USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
PHONE_DATAIN), USBEndpointDescriptor_IN,
USBEndpointDescriptor_BULK, PHONE_DATAIN),
MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_DATAIN), .bmAttributes = USBEndpointDescriptor_BULK,
USBEndpointDescriptor_MAXBULKSIZE_FS), .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_DATAIN),
0 /* Must be 0 for full-speed bulk endpoints */ USBEndpointDescriptor_MAXBULKSIZE_FS),
} .bInterval = 0, /* Must be 0 for full-speed bulk endpoints */
, },
/* Notification endpoint descriptor */ /* Notification endpoint descriptor */
{ {
sizeof(USBEndpointDescriptor), .bLength = sizeof(USBEndpointDescriptor),
USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, PHONE_INT), .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_INTERRUPT, USBEndpointDescriptor_IN,
MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_INT), PHONE_INT),
USBEndpointDescriptor_MAXINTERRUPTSIZE_FS), .bmAttributes = USBEndpointDescriptor_INTERRUPT,
0x10}, .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_INT),
USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
.bInterval = 0x10
},
DFURT_IF_DESCRIPTOR(2, 0), DFURT_IF_DESCRIPTOR(2, 0),
}; };
#endif /* HAVE_CARDEM */ #endif /* HAVE_CARDEM */