usb_template_msc.c (246122) | usb_template_msc.c (246123) |
---|---|
1/* $FreeBSD: head/sys/dev/usb/template/usb_template_msc.c 246122 2013-01-30 15:26:04Z hselasky $ */ | 1/* $FreeBSD: head/sys/dev/usb/template/usb_template_msc.c 246123 2013-01-30 15:46:26Z hselasky $ */ |
2/*- 3 * Copyright (c) 2008 Hans Petter Selasky <hselasky@FreeBSD.org> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright --- 38 unchanged lines hidden (view full) --- 48#include <sys/sx.h> 49#include <sys/unistd.h> 50#include <sys/callout.h> 51#include <sys/malloc.h> 52#include <sys/priv.h> 53 54#include <dev/usb/usb.h> 55#include <dev/usb/usbdi.h> | 2/*- 3 * Copyright (c) 2008 Hans Petter Selasky <hselasky@FreeBSD.org> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright --- 38 unchanged lines hidden (view full) --- 48#include <sys/sx.h> 49#include <sys/unistd.h> 50#include <sys/callout.h> 51#include <sys/malloc.h> 52#include <sys/priv.h> 53 54#include <dev/usb/usb.h> 55#include <dev/usb/usbdi.h> |
56#include <dev/usb/usb_core.h> |
|
56 57#include <dev/usb/template/usb_template.h> 58#endif /* USB_GLOBAL_INCLUDE_FILE */ 59 60enum { 61 STRING_LANG_INDEX, 62 STRING_MSC_DATA_INDEX, 63 STRING_MSC_CONFIG_INDEX, 64 STRING_MSC_VENDOR_INDEX, 65 STRING_MSC_PRODUCT_INDEX, 66 STRING_MSC_SERIAL_INDEX, 67 STRING_MSC_MAX, 68}; 69 | 57 58#include <dev/usb/template/usb_template.h> 59#endif /* USB_GLOBAL_INCLUDE_FILE */ 60 61enum { 62 STRING_LANG_INDEX, 63 STRING_MSC_DATA_INDEX, 64 STRING_MSC_CONFIG_INDEX, 65 STRING_MSC_VENDOR_INDEX, 66 STRING_MSC_PRODUCT_INDEX, 67 STRING_MSC_SERIAL_INDEX, 68 STRING_MSC_MAX, 69}; 70 |
70#define STRING_LANG \ 71 0x09, 0x04, /* American English */ 72 | |
73#define STRING_MSC_DATA \ 74 'U', 0, 'S', 0, 'B', 0, ' ', 0, \ 75 'M', 0, 'a', 0, 's', 0, 's', 0, \ 76 ' ', 0, 'S', 0, 't', 0, 'o', 0, \ 77 'r', 0, 'a', 0, 'g', 0, 'e', 0, \ 78 ' ', 0, 'I', 0, 'n', 0, 't', 0, \ 79 'e', 0, 'r', 0, 'f', 0, 'a', 0, \ 80 'c', 0, 'e', 0, --- 19 unchanged lines hidden (view full) --- 100 101#define STRING_MSC_SERIAL \ 102 'M', 0, 'a', 0, 'r', 0, 'c', 0, \ 103 'h', 0, ' ', 0, '2', 0, '0', 0, \ 104 '0', 0, '8', 0, 105 106/* make the real string descriptors */ 107 | 71#define STRING_MSC_DATA \ 72 'U', 0, 'S', 0, 'B', 0, ' ', 0, \ 73 'M', 0, 'a', 0, 's', 0, 's', 0, \ 74 ' ', 0, 'S', 0, 't', 0, 'o', 0, \ 75 'r', 0, 'a', 0, 'g', 0, 'e', 0, \ 76 ' ', 0, 'I', 0, 'n', 0, 't', 0, \ 77 'e', 0, 'r', 0, 'f', 0, 'a', 0, \ 78 'c', 0, 'e', 0, --- 19 unchanged lines hidden (view full) --- 98 99#define STRING_MSC_SERIAL \ 100 'M', 0, 'a', 0, 'r', 0, 'c', 0, \ 101 'h', 0, ' ', 0, '2', 0, '0', 0, \ 102 '0', 0, '8', 0, 103 104/* make the real string descriptors */ 105 |
108USB_MAKE_STRING_DESC(STRING_LANG, string_lang); | |
109USB_MAKE_STRING_DESC(STRING_MSC_DATA, string_msc_data); 110USB_MAKE_STRING_DESC(STRING_MSC_CONFIG, string_msc_config); 111USB_MAKE_STRING_DESC(STRING_MSC_VENDOR, string_msc_vendor); 112USB_MAKE_STRING_DESC(STRING_MSC_PRODUCT, string_msc_product); 113USB_MAKE_STRING_DESC(STRING_MSC_SERIAL, string_msc_serial); 114 115/* prototypes */ 116 --- 75 unchanged lines hidden (view full) --- 192 * Return values: 193 * NULL: Failure. No such string. 194 * Else: Success. Pointer to string descriptor is returned. 195 *------------------------------------------------------------------------*/ 196static const void * 197msc_get_string_desc(uint16_t lang_id, uint8_t string_index) 198{ 199 static const void *ptr[STRING_MSC_MAX] = { | 106USB_MAKE_STRING_DESC(STRING_MSC_DATA, string_msc_data); 107USB_MAKE_STRING_DESC(STRING_MSC_CONFIG, string_msc_config); 108USB_MAKE_STRING_DESC(STRING_MSC_VENDOR, string_msc_vendor); 109USB_MAKE_STRING_DESC(STRING_MSC_PRODUCT, string_msc_product); 110USB_MAKE_STRING_DESC(STRING_MSC_SERIAL, string_msc_serial); 111 112/* prototypes */ 113 --- 75 unchanged lines hidden (view full) --- 189 * Return values: 190 * NULL: Failure. No such string. 191 * Else: Success. Pointer to string descriptor is returned. 192 *------------------------------------------------------------------------*/ 193static const void * 194msc_get_string_desc(uint16_t lang_id, uint8_t string_index) 195{ 196 static const void *ptr[STRING_MSC_MAX] = { |
200 [STRING_LANG_INDEX] = &string_lang, | 197 [STRING_LANG_INDEX] = &usb_string_lang_en, |
201 [STRING_MSC_DATA_INDEX] = &string_msc_data, 202 [STRING_MSC_CONFIG_INDEX] = &string_msc_config, 203 [STRING_MSC_VENDOR_INDEX] = &string_msc_vendor, 204 [STRING_MSC_PRODUCT_INDEX] = &string_msc_product, 205 [STRING_MSC_SERIAL_INDEX] = &string_msc_serial, 206 }; 207 208 if (string_index == 0) { | 198 [STRING_MSC_DATA_INDEX] = &string_msc_data, 199 [STRING_MSC_CONFIG_INDEX] = &string_msc_config, 200 [STRING_MSC_VENDOR_INDEX] = &string_msc_vendor, 201 [STRING_MSC_PRODUCT_INDEX] = &string_msc_product, 202 [STRING_MSC_SERIAL_INDEX] = &string_msc_serial, 203 }; 204 205 if (string_index == 0) { |
209 return (&string_lang); | 206 return (&usb_string_lang_en); |
210 } 211 if (lang_id != 0x0409) { 212 return (NULL); 213 } 214 if (string_index < STRING_MSC_MAX) { 215 return (ptr[string_index]); 216 } 217 return (NULL); 218} | 207 } 208 if (lang_id != 0x0409) { 209 return (NULL); 210 } 211 if (string_index < STRING_MSC_MAX) { 212 return (ptr[string_index]); 213 } 214 return (NULL); 215} |