Deleted Added
full compact
usb_template_modem.c (246122) usb_template_modem.c (246123)
1/* $FreeBSD: head/sys/dev/usb/template/usb_template_modem.c 246122 2013-01-30 15:26:04Z hselasky $ */
1/* $FreeBSD: head/sys/dev/usb/template/usb_template_modem.c 246123 2013-01-30 15:46:26Z hselasky $ */
2/*-
3 * Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.

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

47#include <sys/sx.h>
48#include <sys/unistd.h>
49#include <sys/callout.h>
50#include <sys/malloc.h>
51#include <sys/priv.h>
52
53#include <dev/usb/usb.h>
54#include <dev/usb/usbdi.h>
2/*-
3 * Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.

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

47#include <sys/sx.h>
48#include <sys/unistd.h>
49#include <sys/callout.h>
50#include <sys/malloc.h>
51#include <sys/priv.h>
52
53#include <dev/usb/usb.h>
54#include <dev/usb/usbdi.h>
55#include <dev/usb/usb_core.h>
55#include <dev/usb/usb_cdc.h>
56
57#include <dev/usb/template/usb_template.h>
58#endif /* USB_GLOBAL_INCLUDE_FILE */
59
60enum {
61 INDEX_LANG,
62 INDEX_MODEM,
63 INDEX_PRODUCT,
64 INDEX_MAX,
65};
66
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 INDEX_LANG,
63 INDEX_MODEM,
64 INDEX_PRODUCT,
65 INDEX_MAX,
66};
67
67#define STRING_LANG \
68 0x09, 0x04, /* American English */
69
70#define STRING_PRODUCT \
71 'M', 0, 'o', 0, 'd', 0, 'e', 0, 'm', 0, ' ', 0, \
72 'T', 0, 'e', 0, 's', 0, 't', 0, ' ', 0, \
73 'D', 0, 'e', 0, 'v', 0, 'i', 0, 'c', 0, 'e', 0,
74
75#define STRING_MODEM \
76 'M', 0, 'o', 0, 'd', 0, 'e', 0, 'm', 0, ' ', 0, \
77 'i', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0,
78
79/* make the real string descriptors */
80
68#define STRING_PRODUCT \
69 'M', 0, 'o', 0, 'd', 0, 'e', 0, 'm', 0, ' ', 0, \
70 'T', 0, 'e', 0, 's', 0, 't', 0, ' ', 0, \
71 'D', 0, 'e', 0, 'v', 0, 'i', 0, 'c', 0, 'e', 0,
72
73#define STRING_MODEM \
74 'M', 0, 'o', 0, 'd', 0, 'e', 0, 'm', 0, ' ', 0, \
75 'i', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0,
76
77/* make the real string descriptors */
78
81USB_MAKE_STRING_DESC(STRING_LANG, string_lang);
82USB_MAKE_STRING_DESC(STRING_MODEM, string_modem);
83USB_MAKE_STRING_DESC(STRING_PRODUCT, string_product);
84
85#define MODEM_IFACE_0 0
86#define MODEM_IFACE_1 1
87
88/* prototypes */
89

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

231 * Return values:
232 * NULL: Failure. No such string.
233 * Else: Success. Pointer to string descriptor is returned.
234 *------------------------------------------------------------------------*/
235static const void *
236modem_get_string_desc(uint16_t lang_id, uint8_t string_index)
237{
238 static const void *ptr[INDEX_MAX] = {
79USB_MAKE_STRING_DESC(STRING_MODEM, string_modem);
80USB_MAKE_STRING_DESC(STRING_PRODUCT, string_product);
81
82#define MODEM_IFACE_0 0
83#define MODEM_IFACE_1 1
84
85/* prototypes */
86

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

228 * Return values:
229 * NULL: Failure. No such string.
230 * Else: Success. Pointer to string descriptor is returned.
231 *------------------------------------------------------------------------*/
232static const void *
233modem_get_string_desc(uint16_t lang_id, uint8_t string_index)
234{
235 static const void *ptr[INDEX_MAX] = {
239 [INDEX_LANG] = &string_lang,
236 [INDEX_LANG] = &usb_string_lang_en,
240 [INDEX_MODEM] = &string_modem,
241 [INDEX_PRODUCT] = &string_product,
242 };
243
244 if (string_index == 0) {
237 [INDEX_MODEM] = &string_modem,
238 [INDEX_PRODUCT] = &string_product,
239 };
240
241 if (string_index == 0) {
245 return (&string_lang);
242 return (&usb_string_lang_en);
246 }
247 if (lang_id != 0x0409) {
248 return (NULL);
249 }
250 if (string_index < INDEX_MAX) {
251 return (ptr[string_index]);
252 }
253 return (NULL);
254}
243 }
244 if (lang_id != 0x0409) {
245 return (NULL);
246 }
247 if (string_index < INDEX_MAX) {
248 return (ptr[string_index]);
249 }
250 return (NULL);
251}