Deleted Added
full compact
usb_template_cdce.c (246122) usb_template_cdce.c (246123)
1/* $FreeBSD: head/sys/dev/usb/template/usb_template_cdce.c 246122 2013-01-30 15:26:04Z hselasky $ */
1/* $FreeBSD: head/sys/dev/usb/template/usb_template_cdce.c 246123 2013-01-30 15:46:26Z hselasky $ */
2/*-
3 * Copyright (c) 2007 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) 2007 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#include <dev/usb/usb_cdc.h>
57
58#include <dev/usb/template/usb_template.h>
59#endif /* USB_GLOBAL_INCLUDE_FILE */
60
61enum {
62 STRING_LANG_INDEX,
63 STRING_MAC_INDEX,
64 STRING_ETH_CONTROL_INDEX,
65 STRING_ETH_DATA_INDEX,
66 STRING_ETH_CONFIG_INDEX,
67 STRING_ETH_VENDOR_INDEX,
68 STRING_ETH_PRODUCT_INDEX,
69 STRING_ETH_SERIAL_INDEX,
70 STRING_ETH_MAX,
71};
72
57#include <dev/usb/usb_cdc.h>
58
59#include <dev/usb/template/usb_template.h>
60#endif /* USB_GLOBAL_INCLUDE_FILE */
61
62enum {
63 STRING_LANG_INDEX,
64 STRING_MAC_INDEX,
65 STRING_ETH_CONTROL_INDEX,
66 STRING_ETH_DATA_INDEX,
67 STRING_ETH_CONFIG_INDEX,
68 STRING_ETH_VENDOR_INDEX,
69 STRING_ETH_PRODUCT_INDEX,
70 STRING_ETH_SERIAL_INDEX,
71 STRING_ETH_MAX,
72};
73
73#define STRING_LANG \
74 0x09, 0x04, /* American English */
75
76#define STRING_MAC \
77 '2', 0, 'A', 0, '2', 0, '3', 0, \
78 '4', 0, '5', 0, '6', 0, '7', 0, \
79 '8', 0, '9', 0, 'A', 0, 'B', 0,
80
81#define STRING_ETH_CONTROL \
82 'U', 0, 'S', 0, 'B', 0, ' ', 0, \
83 'E', 0, 't', 0, 'h', 0, 'e', 0, \

--- 35 unchanged lines hidden (view full) ---

119#define STRING_ETH_SERIAL \
120 'D', 0, 'e', 0, 'c', 0, 'e', 0, \
121 'm', 0, 'b', 0, 'e', 0, 'r', 0, \
122 ' ', 0, '2', 0, '0', 0, '0', 0, \
123 '7', 0,
124
125/* make the real string descriptors */
126
74#define STRING_MAC \
75 '2', 0, 'A', 0, '2', 0, '3', 0, \
76 '4', 0, '5', 0, '6', 0, '7', 0, \
77 '8', 0, '9', 0, 'A', 0, 'B', 0,
78
79#define STRING_ETH_CONTROL \
80 'U', 0, 'S', 0, 'B', 0, ' ', 0, \
81 'E', 0, 't', 0, 'h', 0, 'e', 0, \

--- 35 unchanged lines hidden (view full) ---

117#define STRING_ETH_SERIAL \
118 'D', 0, 'e', 0, 'c', 0, 'e', 0, \
119 'm', 0, 'b', 0, 'e', 0, 'r', 0, \
120 ' ', 0, '2', 0, '0', 0, '0', 0, \
121 '7', 0,
122
123/* make the real string descriptors */
124
127USB_MAKE_STRING_DESC(STRING_LANG, string_lang);
128USB_MAKE_STRING_DESC(STRING_MAC, string_mac);
129USB_MAKE_STRING_DESC(STRING_ETH_CONTROL, string_eth_control);
130USB_MAKE_STRING_DESC(STRING_ETH_DATA, string_eth_data);
131USB_MAKE_STRING_DESC(STRING_ETH_CONFIG, string_eth_config);
132USB_MAKE_STRING_DESC(STRING_ETH_VENDOR, string_eth_vendor);
133USB_MAKE_STRING_DESC(STRING_ETH_PRODUCT, string_eth_product);
134USB_MAKE_STRING_DESC(STRING_ETH_SERIAL, string_eth_serial);
135

--- 147 unchanged lines hidden (view full) ---

283 * Return values:
284 * NULL: Failure. No such string.
285 * Else: Success. Pointer to string descriptor is returned.
286 *------------------------------------------------------------------------*/
287static const void *
288eth_get_string_desc(uint16_t lang_id, uint8_t string_index)
289{
290 static const void *ptr[STRING_ETH_MAX] = {
125USB_MAKE_STRING_DESC(STRING_MAC, string_mac);
126USB_MAKE_STRING_DESC(STRING_ETH_CONTROL, string_eth_control);
127USB_MAKE_STRING_DESC(STRING_ETH_DATA, string_eth_data);
128USB_MAKE_STRING_DESC(STRING_ETH_CONFIG, string_eth_config);
129USB_MAKE_STRING_DESC(STRING_ETH_VENDOR, string_eth_vendor);
130USB_MAKE_STRING_DESC(STRING_ETH_PRODUCT, string_eth_product);
131USB_MAKE_STRING_DESC(STRING_ETH_SERIAL, string_eth_serial);
132

--- 147 unchanged lines hidden (view full) ---

280 * Return values:
281 * NULL: Failure. No such string.
282 * Else: Success. Pointer to string descriptor is returned.
283 *------------------------------------------------------------------------*/
284static const void *
285eth_get_string_desc(uint16_t lang_id, uint8_t string_index)
286{
287 static const void *ptr[STRING_ETH_MAX] = {
291 [STRING_LANG_INDEX] = &string_lang,
288 [STRING_LANG_INDEX] = &usb_string_lang_en,
292 [STRING_MAC_INDEX] = &string_mac,
293 [STRING_ETH_CONTROL_INDEX] = &string_eth_control,
294 [STRING_ETH_DATA_INDEX] = &string_eth_data,
295 [STRING_ETH_CONFIG_INDEX] = &string_eth_config,
296 [STRING_ETH_VENDOR_INDEX] = &string_eth_vendor,
297 [STRING_ETH_PRODUCT_INDEX] = &string_eth_product,
298 [STRING_ETH_SERIAL_INDEX] = &string_eth_serial,
299 };
300
301 if (string_index == 0) {
289 [STRING_MAC_INDEX] = &string_mac,
290 [STRING_ETH_CONTROL_INDEX] = &string_eth_control,
291 [STRING_ETH_DATA_INDEX] = &string_eth_data,
292 [STRING_ETH_CONFIG_INDEX] = &string_eth_config,
293 [STRING_ETH_VENDOR_INDEX] = &string_eth_vendor,
294 [STRING_ETH_PRODUCT_INDEX] = &string_eth_product,
295 [STRING_ETH_SERIAL_INDEX] = &string_eth_serial,
296 };
297
298 if (string_index == 0) {
302 return (&string_lang);
299 return (&usb_string_lang_en);
303 }
304 if (lang_id != 0x0409) {
305 return (NULL);
306 }
307 if (string_index < STRING_ETH_MAX) {
308 return (ptr[string_index]);
309 }
310 return (NULL);
311}
300 }
301 if (lang_id != 0x0409) {
302 return (NULL);
303 }
304 if (string_index < STRING_ETH_MAX) {
305 return (ptr[string_index]);
306 }
307 return (NULL);
308}