Provide one global language string descriptor for

american english instead of giving each module its
own.

Submitted by:	Christoph Mallon
This commit is contained in:
Hans Petter Selasky 2013-01-30 15:46:26 +00:00
parent d2b99310b1
commit 23ab08715c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=246123
16 changed files with 48 additions and 78 deletions

View File

@ -1740,9 +1740,6 @@ static const struct usb_hub_descriptor_min at91dci_hubd = {
.DeviceRemovable = {0}, /* port is removable */
};
#define STRING_LANG \
0x09, 0x04, /* American English */
#define STRING_VENDOR \
'A', 0, 'T', 0, 'M', 0, 'E', 0, 'L', 0
@ -1751,7 +1748,6 @@ static const struct usb_hub_descriptor_min at91dci_hubd = {
'o', 0, 'o', 0, 't', 0, ' ', 0, 'H', 0, \
'U', 0, 'B', 0,
USB_MAKE_STRING_DESC(STRING_LANG, at91dci_langtab);
USB_MAKE_STRING_DESC(STRING_VENDOR, at91dci_vendor);
USB_MAKE_STRING_DESC(STRING_PRODUCT, at91dci_product);
@ -1953,8 +1949,8 @@ at91dci_roothub_exec(struct usb_device *udev,
case UDESC_STRING:
switch (value & 0xff) {
case 0: /* Language table */
len = sizeof(at91dci_langtab);
ptr = (const void *)&at91dci_langtab;
len = sizeof(usb_string_lang_en);
ptr = (const void *)&usb_string_lang_en;
goto tr_valid;
case 1: /* Vendor */

View File

@ -1565,9 +1565,6 @@ static const struct usb_hub_descriptor_min atmegadci_hubd = {
.DeviceRemovable = {0}, /* port is removable */
};
#define STRING_LANG \
0x09, 0x04, /* American English */
#define STRING_VENDOR \
'A', 0, 'T', 0, 'M', 0, 'E', 0, 'G', 0, 'A', 0
@ -1576,7 +1573,6 @@ static const struct usb_hub_descriptor_min atmegadci_hubd = {
'o', 0, 'o', 0, 't', 0, ' ', 0, 'H', 0, \
'U', 0, 'B', 0,
USB_MAKE_STRING_DESC(STRING_LANG, atmegadci_langtab);
USB_MAKE_STRING_DESC(STRING_VENDOR, atmegadci_vendor);
USB_MAKE_STRING_DESC(STRING_PRODUCT, atmegadci_product);
@ -1779,8 +1775,8 @@ atmegadci_roothub_exec(struct usb_device *udev,
case UDESC_STRING:
switch (value & 0xff) {
case 0: /* Language table */
len = sizeof(atmegadci_langtab);
ptr = (const void *)&atmegadci_langtab;
len = sizeof(usb_string_lang_en);
ptr = (const void *)&usb_string_lang_en;
goto tr_valid;
case 1: /* Vendor */

View File

@ -1505,9 +1505,6 @@ static const struct usb_hub_descriptor_min avr32dci_hubd = {
.DeviceRemovable = {0}, /* port is removable */
};
#define STRING_LANG \
0x09, 0x04, /* American English */
#define STRING_VENDOR \
'A', 0, 'V', 0, 'R', 0, '3', 0, '2', 0
@ -1516,7 +1513,6 @@ static const struct usb_hub_descriptor_min avr32dci_hubd = {
'o', 0, 'o', 0, 't', 0, ' ', 0, 'H', 0, \
'U', 0, 'B', 0,
USB_MAKE_STRING_DESC(STRING_LANG, avr32dci_langtab);
USB_MAKE_STRING_DESC(STRING_VENDOR, avr32dci_vendor);
USB_MAKE_STRING_DESC(STRING_PRODUCT, avr32dci_product);
@ -1719,8 +1715,8 @@ avr32dci_roothub_exec(struct usb_device *udev,
case UDESC_STRING:
switch (value & 0xff) {
case 0: /* Language table */
len = sizeof(avr32dci_langtab);
ptr = (const void *)&avr32dci_langtab;
len = sizeof(usb_string_lang_en);
ptr = (const void *)&usb_string_lang_en;
goto tr_valid;
case 1: /* Vendor */

View File

@ -3491,9 +3491,6 @@ static const struct usb_hub_descriptor_min dwc_otg_hubd = {
.DeviceRemovable = {0}, /* port is removable */
};
#define STRING_LANG \
0x09, 0x04, /* American English */
#define STRING_VENDOR \
'D', 0, 'W', 0, 'C', 0, 'O', 0, 'T', 0, 'G', 0
@ -3502,7 +3499,6 @@ static const struct usb_hub_descriptor_min dwc_otg_hubd = {
'o', 0, 'o', 0, 't', 0, ' ', 0, 'H', 0, \
'U', 0, 'B', 0,
USB_MAKE_STRING_DESC(STRING_LANG, dwc_otg_langtab);
USB_MAKE_STRING_DESC(STRING_VENDOR, dwc_otg_vendor);
USB_MAKE_STRING_DESC(STRING_PRODUCT, dwc_otg_product);
@ -3704,8 +3700,8 @@ dwc_otg_roothub_exec(struct usb_device *udev,
case UDESC_STRING:
switch (value & 0xff) {
case 0: /* Language table */
len = sizeof(dwc_otg_langtab);
ptr = (const void *)&dwc_otg_langtab;
len = sizeof(usb_string_lang_en);
ptr = (const void *)&usb_string_lang_en;
goto tr_valid;
case 1: /* Vendor */

View File

@ -2211,9 +2211,6 @@ static const struct usb_hub_descriptor_min musbotg_hubd = {
.DeviceRemovable = {0}, /* port is removable */
};
#define STRING_LANG \
0x09, 0x04, /* American English */
#define STRING_VENDOR \
'M', 0, 'e', 0, 'n', 0, 't', 0, 'o', 0, 'r', 0, ' ', 0, \
'G', 0, 'r', 0, 'a', 0, 'p', 0, 'h', 0, 'i', 0, 'c', 0, 's', 0
@ -2223,7 +2220,6 @@ static const struct usb_hub_descriptor_min musbotg_hubd = {
'o', 0, 'o', 0, 't', 0, ' ', 0, 'H', 0, \
'U', 0, 'B', 0,
USB_MAKE_STRING_DESC(STRING_LANG, musbotg_langtab);
USB_MAKE_STRING_DESC(STRING_VENDOR, musbotg_vendor);
USB_MAKE_STRING_DESC(STRING_PRODUCT, musbotg_product);
@ -2425,8 +2421,8 @@ musbotg_roothub_exec(struct usb_device *udev,
case UDESC_STRING:
switch (value & 0xff) {
case 0: /* Language table */
len = sizeof(musbotg_langtab);
ptr = (const void *)&musbotg_langtab;
len = sizeof(usb_string_lang_en);
ptr = (const void *)&usb_string_lang_en;
goto tr_valid;
case 1: /* Vendor */

View File

@ -1808,9 +1808,6 @@ static const struct usb_hub_descriptor_min uss820dci_hubd = {
.DeviceRemovable = {0}, /* port is removable */
};
#define STRING_LANG \
0x09, 0x04, /* American English */
#define STRING_VENDOR \
'A', 0, 'G', 0, 'E', 0, 'R', 0, 'E', 0
@ -1819,7 +1816,6 @@ static const struct usb_hub_descriptor_min uss820dci_hubd = {
'o', 0, 'o', 0, 't', 0, ' ', 0, 'H', 0, \
'U', 0, 'B', 0,
USB_MAKE_STRING_DESC(STRING_LANG, uss820dci_langtab);
USB_MAKE_STRING_DESC(STRING_VENDOR, uss820dci_vendor);
USB_MAKE_STRING_DESC(STRING_PRODUCT, uss820dci_product);
@ -2021,8 +2017,8 @@ uss820dci_roothub_exec(struct usb_device *udev,
case UDESC_STRING:
switch (value & 0xff) {
case 0: /* Language table */
len = sizeof(uss820dci_langtab);
ptr = (const void *)&uss820dci_langtab;
len = sizeof(usb_string_lang_en);
ptr = (const void *)&usb_string_lang_en;
goto tr_valid;
case 1: /* Vendor */

View File

@ -52,6 +52,7 @@
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_cdc.h>
#include <dev/usb/template/usb_template.h>
@ -66,9 +67,6 @@ enum {
INDEX_AUDIO_MAX,
};
#define STRING_LANG \
0x09, 0x04, /* American English */
#define STRING_AUDIO_PRODUCT \
'A', 0, 'u', 0, 'd', 0, 'i', 0, 'o', 0, ' ', 0, \
'T', 0, 'e', 0, 's', 0, 't', 0, ' ', 0, \
@ -89,7 +87,6 @@ enum {
/* make the real string descriptors */
USB_MAKE_STRING_DESC(STRING_LANG, string_lang);
USB_MAKE_STRING_DESC(STRING_AUDIO_MIXER, string_audio_mixer);
USB_MAKE_STRING_DESC(STRING_AUDIO_RECORD, string_audio_record);
USB_MAKE_STRING_DESC(STRING_AUDIO_PLAYBACK, string_audio_playback);
@ -387,7 +384,7 @@ static const void *
audio_get_string_desc(uint16_t lang_id, uint8_t string_index)
{
static const void *ptr[INDEX_AUDIO_MAX] = {
[INDEX_AUDIO_LANG] = &string_lang,
[INDEX_AUDIO_LANG] = &usb_string_lang_en,
[INDEX_AUDIO_MIXER] = &string_audio_mixer,
[INDEX_AUDIO_RECORD] = &string_audio_record,
[INDEX_AUDIO_PLAYBACK] = &string_audio_playback,
@ -395,7 +392,7 @@ audio_get_string_desc(uint16_t lang_id, uint8_t string_index)
};
if (string_index == 0) {
return (&string_lang);
return (&usb_string_lang_en);
}
if (lang_id != 0x0409) {
return (NULL);

View File

@ -53,6 +53,7 @@
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_cdc.h>
#include <dev/usb/template/usb_template.h>
@ -70,9 +71,6 @@ enum {
STRING_ETH_MAX,
};
#define STRING_LANG \
0x09, 0x04, /* American English */
#define STRING_MAC \
'2', 0, 'A', 0, '2', 0, '3', 0, \
'4', 0, '5', 0, '6', 0, '7', 0, \
@ -124,7 +122,6 @@ enum {
/* make the real string descriptors */
USB_MAKE_STRING_DESC(STRING_LANG, string_lang);
USB_MAKE_STRING_DESC(STRING_MAC, string_mac);
USB_MAKE_STRING_DESC(STRING_ETH_CONTROL, string_eth_control);
USB_MAKE_STRING_DESC(STRING_ETH_DATA, string_eth_data);
@ -288,7 +285,7 @@ static const void *
eth_get_string_desc(uint16_t lang_id, uint8_t string_index)
{
static const void *ptr[STRING_ETH_MAX] = {
[STRING_LANG_INDEX] = &string_lang,
[STRING_LANG_INDEX] = &usb_string_lang_en,
[STRING_MAC_INDEX] = &string_mac,
[STRING_ETH_CONTROL_INDEX] = &string_eth_control,
[STRING_ETH_DATA_INDEX] = &string_eth_data,
@ -299,7 +296,7 @@ eth_get_string_desc(uint16_t lang_id, uint8_t string_index)
};
if (string_index == 0) {
return (&string_lang);
return (&usb_string_lang_en);
}
if (lang_id != 0x0409) {
return (NULL);

View File

@ -52,6 +52,7 @@
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_cdc.h>
#include <dev/usb/template/usb_template.h>
@ -64,9 +65,6 @@ enum {
INDEX_MAX,
};
#define STRING_LANG \
0x09, 0x04, /* American English */
#define STRING_PRODUCT \
'K', 0, 'e', 0, 'y', 0, 'b', 0, 'o', 0, 'a', 0, 'r', 0, 'd', 0, ' ', 0, \
'T', 0, 'e', 0, 's', 0, 't', 0, ' ', 0, \
@ -78,7 +76,6 @@ enum {
/* make the real string descriptors */
USB_MAKE_STRING_DESC(STRING_LANG, string_lang);
USB_MAKE_STRING_DESC(STRING_KEYBOARD, string_keyboard);
USB_MAKE_STRING_DESC(STRING_PRODUCT, string_product);
@ -208,13 +205,13 @@ static const void *
keyboard_get_string_desc(uint16_t lang_id, uint8_t string_index)
{
static const void *ptr[INDEX_MAX] = {
[INDEX_LANG] = &string_lang,
[INDEX_LANG] = &usb_string_lang_en,
[INDEX_KEYBOARD] = &string_keyboard,
[INDEX_PRODUCT] = &string_product,
};
if (string_index == 0) {
return (&string_lang);
return (&usb_string_lang_en);
}
if (lang_id != 0x0409) {
return (NULL);

View File

@ -52,6 +52,7 @@
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_cdc.h>
#include <dev/usb/template/usb_template.h>
@ -64,9 +65,6 @@ enum {
INDEX_MAX,
};
#define STRING_LANG \
0x09, 0x04, /* American English */
#define STRING_PRODUCT \
'M', 0, 'o', 0, 'd', 0, 'e', 0, 'm', 0, ' ', 0, \
'T', 0, 'e', 0, 's', 0, 't', 0, ' ', 0, \
@ -78,7 +76,6 @@ enum {
/* make the real string descriptors */
USB_MAKE_STRING_DESC(STRING_LANG, string_lang);
USB_MAKE_STRING_DESC(STRING_MODEM, string_modem);
USB_MAKE_STRING_DESC(STRING_PRODUCT, string_product);
@ -236,13 +233,13 @@ static const void *
modem_get_string_desc(uint16_t lang_id, uint8_t string_index)
{
static const void *ptr[INDEX_MAX] = {
[INDEX_LANG] = &string_lang,
[INDEX_LANG] = &usb_string_lang_en,
[INDEX_MODEM] = &string_modem,
[INDEX_PRODUCT] = &string_product,
};
if (string_index == 0) {
return (&string_lang);
return (&usb_string_lang_en);
}
if (lang_id != 0x0409) {
return (NULL);

View File

@ -52,6 +52,7 @@
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_cdc.h>
#include <dev/usb/template/usb_template.h>
@ -64,9 +65,6 @@ enum {
INDEX_MAX,
};
#define STRING_LANG \
0x09, 0x04, /* American English */
#define STRING_PRODUCT \
'M', 0, 'o', 0, 'u', 0, 's', 0, 'e', 0, ' ', 0, \
'T', 0, 'e', 0, 's', 0, 't', 0, ' ', 0, \
@ -78,7 +76,6 @@ enum {
/* make the real string descriptors */
USB_MAKE_STRING_DESC(STRING_LANG, string_lang);
USB_MAKE_STRING_DESC(STRING_MOUSE, string_mouse);
USB_MAKE_STRING_DESC(STRING_PRODUCT, string_product);
@ -206,13 +203,13 @@ static const void *
mouse_get_string_desc(uint16_t lang_id, uint8_t string_index)
{
static const void *ptr[INDEX_MAX] = {
[INDEX_LANG] = &string_lang,
[INDEX_LANG] = &usb_string_lang_en,
[INDEX_MOUSE] = &string_mouse,
[INDEX_PRODUCT] = &string_product,
};
if (string_index == 0) {
return (&string_lang);
return (&usb_string_lang_en);
}
if (lang_id != 0x0409) {
return (NULL);

View File

@ -53,6 +53,7 @@
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/template/usb_template.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
@ -67,9 +68,6 @@ enum {
STRING_MSC_MAX,
};
#define STRING_LANG \
0x09, 0x04, /* American English */
#define STRING_MSC_DATA \
'U', 0, 'S', 0, 'B', 0, ' ', 0, \
'M', 0, 'a', 0, 's', 0, 's', 0, \
@ -105,7 +103,6 @@ enum {
/* make the real string descriptors */
USB_MAKE_STRING_DESC(STRING_LANG, string_lang);
USB_MAKE_STRING_DESC(STRING_MSC_DATA, string_msc_data);
USB_MAKE_STRING_DESC(STRING_MSC_CONFIG, string_msc_config);
USB_MAKE_STRING_DESC(STRING_MSC_VENDOR, string_msc_vendor);
@ -197,7 +194,7 @@ static const void *
msc_get_string_desc(uint16_t lang_id, uint8_t string_index)
{
static const void *ptr[STRING_MSC_MAX] = {
[STRING_LANG_INDEX] = &string_lang,
[STRING_LANG_INDEX] = &usb_string_lang_en,
[STRING_MSC_DATA_INDEX] = &string_msc_data,
[STRING_MSC_CONFIG_INDEX] = &string_msc_config,
[STRING_MSC_VENDOR_INDEX] = &string_msc_vendor,
@ -206,7 +203,7 @@ msc_get_string_desc(uint16_t lang_id, uint8_t string_index)
};
if (string_index == 0) {
return (&string_lang);
return (&usb_string_lang_en);
}
if (lang_id != 0x0409) {
return (NULL);

View File

@ -60,6 +60,8 @@
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/template/usb_template.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
@ -75,9 +77,6 @@ enum {
STRING_MTP_MAX,
};
#define STRING_LANG \
0x09, 0x04, /* American English */
#define STRING_MTP_DATA \
'U', 0, 'S', 0, 'B', 0, ' ', 0, \
'M', 0, 'T', 0, 'P', 0, \
@ -109,7 +108,6 @@ enum {
/* make the real string descriptors */
USB_MAKE_STRING_DESC(STRING_LANG, string_lang);
USB_MAKE_STRING_DESC(STRING_MTP_DATA, string_mtp_data);
USB_MAKE_STRING_DESC(STRING_MTP_CONFIG, string_mtp_config);
USB_MAKE_STRING_DESC(STRING_MTP_VENDOR, string_mtp_vendor);
@ -246,7 +244,7 @@ static const void *
mtp_get_string_desc(uint16_t lang_id, uint8_t string_index)
{
static const void *ptr[STRING_MTP_MAX] = {
[STRING_LANG_INDEX] = &string_lang,
[STRING_LANG_INDEX] = &usb_string_lang_en,
[STRING_MTP_DATA_INDEX] = &string_mtp_data,
[STRING_MTP_CONFIG_INDEX] = &string_mtp_config,
[STRING_MTP_VENDOR_INDEX] = &string_mtp_vendor,
@ -268,7 +266,7 @@ mtp_get_string_desc(uint16_t lang_id, uint8_t string_index)
return (dummy_desc);
}
if (string_index == 0) {
return (&string_lang);
return (&usb_string_lang_en);
}
if (lang_id != 0x0409) {
return (NULL);

View File

@ -577,6 +577,13 @@ static const struct name name = { \
.bData = { m }, \
}
struct usb_string_lang {
uByte bLength;
uByte bDescriptorType;
uByte bData[2];
} __packed;
typedef struct usb_string_lang usb_string_lang_t;
struct usb_hub_descriptor {
uByte bDescLength;
uByte bDescriptorType;

View File

@ -56,6 +56,11 @@
#include <dev/usb/usbdi.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
const struct usb_string_lang usb_string_lang_en = {
sizeof(usb_string_lang_en), UDESC_STRING,
{ 0x09, 0x04 } /* American English */
};
MALLOC_DEFINE(M_USB, "USB", "USB");
MALLOC_DEFINE(M_USBDEV, "USBdev", "USB device");
MALLOC_DEFINE(M_USBHC, "USBHC", "USB host controller");

View File

@ -69,6 +69,7 @@ struct usb_page;
struct usb_page_cache;
struct usb_xfer;
struct usb_xfer_root;
struct usb_string_lang;
/* typedefs */
@ -174,6 +175,7 @@ struct usb_xfer {
/* external variables */
extern struct mtx usb_ref_lock;
extern const struct usb_string_lang usb_string_lang_en;
/* typedefs */