aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb/composite.h
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /include/linux/usb/composite.h
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'include/linux/usb/composite.h')
-rw-r--r--include/linux/usb/composite.h58
1 files changed, 37 insertions, 21 deletions
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 617068134ae8..b78cba466d3d 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -37,6 +37,14 @@
37#include <linux/usb/ch9.h> 37#include <linux/usb/ch9.h>
38#include <linux/usb/gadget.h> 38#include <linux/usb/gadget.h>
39 39
40/*
41 * USB function drivers should return USB_GADGET_DELAYED_STATUS if they
42 * wish to delay the data/status stages of the control transfer till they
43 * are ready. The control transfer will then be kept from completing till
44 * all the function drivers that requested for USB_GADGET_DELAYED_STAUS
45 * invoke usb_composite_setup_continue().
46 */
47#define USB_GADGET_DELAYED_STATUS 0x7fff /* Impossibly large value */
40 48
41struct usb_configuration; 49struct usb_configuration;
42 50
@@ -161,8 +169,6 @@ ep_choose(struct usb_gadget *g, struct usb_endpoint_descriptor *hs,
161 * and by language IDs provided in control requests. 169 * and by language IDs provided in control requests.
162 * @descriptors: Table of descriptors preceding all function descriptors. 170 * @descriptors: Table of descriptors preceding all function descriptors.
163 * Examples include OTG and vendor-specific descriptors. 171 * Examples include OTG and vendor-specific descriptors.
164 * @bind: Called from @usb_add_config() to allocate resources unique to this
165 * configuration and to call @usb_add_function() for each function used.
166 * @unbind: Reverses @bind; called as a side effect of unregistering the 172 * @unbind: Reverses @bind; called as a side effect of unregistering the
167 * driver which added this configuration. 173 * driver which added this configuration.
168 * @setup: Used to delegate control requests that aren't handled by standard 174 * @setup: Used to delegate control requests that aren't handled by standard
@@ -190,7 +196,7 @@ ep_choose(struct usb_gadget *g, struct usb_endpoint_descriptor *hs,
190 * @bind() method is then used to initialize all the functions and then 196 * @bind() method is then used to initialize all the functions and then
191 * call @usb_add_function() for them. 197 * call @usb_add_function() for them.
192 * 198 *
193 * Those functions would normally be independant of each other, but that's 199 * Those functions would normally be independent of each other, but that's
194 * not mandatory. CDC WMC devices are an example where functions often 200 * not mandatory. CDC WMC devices are an example where functions often
195 * depend on other functions, with some functions subsidiary to others. 201 * depend on other functions, with some functions subsidiary to others.
196 * Such interdependency may be managed in any way, so long as all of the 202 * Such interdependency may be managed in any way, so long as all of the
@@ -207,8 +213,7 @@ struct usb_configuration {
207 * we can't restructure things to avoid mismatching... 213 * we can't restructure things to avoid mismatching...
208 */ 214 */
209 215
210 /* configuration management: bind/unbind */ 216 /* configuration management: unbind/setup */
211 int (*bind)(struct usb_configuration *);
212 void (*unbind)(struct usb_configuration *); 217 void (*unbind)(struct usb_configuration *);
213 int (*setup)(struct usb_configuration *, 218 int (*setup)(struct usb_configuration *,
214 const struct usb_ctrlrequest *); 219 const struct usb_ctrlrequest *);
@@ -232,20 +237,24 @@ struct usb_configuration {
232}; 237};
233 238
234int usb_add_config(struct usb_composite_dev *, 239int usb_add_config(struct usb_composite_dev *,
235 struct usb_configuration *); 240 struct usb_configuration *,
241 int (*)(struct usb_configuration *));
236 242
237/** 243/**
238 * struct usb_composite_driver - groups configurations into a gadget 244 * struct usb_composite_driver - groups configurations into a gadget
239 * @name: For diagnostics, identifies the driver. 245 * @name: For diagnostics, identifies the driver.
246 * @iProduct: Used as iProduct override if @dev->iProduct is not set.
247 * If NULL value of @name is taken.
248 * @iManufacturer: Used as iManufacturer override if @dev->iManufacturer is
249 * not set. If NULL a default "<system> <release> with <udc>" value
250 * will be used.
240 * @dev: Template descriptor for the device, including default device 251 * @dev: Template descriptor for the device, including default device
241 * identifiers. 252 * identifiers.
242 * @strings: tables of strings, keyed by identifiers assigned during bind() 253 * @strings: tables of strings, keyed by identifiers assigned during bind()
243 * and language IDs provided in control requests 254 * and language IDs provided in control requests
244 * @bind: (REQUIRED) Used to allocate resources that are shared across the 255 * @needs_serial: set to 1 if the gadget needs userspace to provide
245 * whole device, such as string IDs, and add its configurations using 256 * a serial number. If one is not provided, warning will be printed.
246 * @usb_add_config(). This may fail by returning a negative errno 257 * @unbind: Reverses bind; called as a side effect of unregistering
247 * value; it should return zero on successful initialization.
248 * @unbind: Reverses @bind(); called as a side effect of unregistering
249 * this driver. 258 * this driver.
250 * @disconnect: optional driver disconnect method 259 * @disconnect: optional driver disconnect method
251 * @suspend: Notifies when the host stops sending USB traffic, 260 * @suspend: Notifies when the host stops sending USB traffic,
@@ -256,7 +265,7 @@ int usb_add_config(struct usb_composite_dev *,
256 * Devices default to reporting self powered operation. Devices which rely 265 * Devices default to reporting self powered operation. Devices which rely
257 * on bus powered operation should report this in their @bind() method. 266 * on bus powered operation should report this in their @bind() method.
258 * 267 *
259 * Before returning from @bind, various fields in the template descriptor 268 * Before returning from bind, various fields in the template descriptor
260 * may be overridden. These include the idVendor/idProduct/bcdDevice values 269 * may be overridden. These include the idVendor/idProduct/bcdDevice values
261 * normally to bind the appropriate host side driver, and the three strings 270 * normally to bind the appropriate host side driver, and the three strings
262 * (iManufacturer, iProduct, iSerialNumber) normally used to provide user 271 * (iManufacturer, iProduct, iSerialNumber) normally used to provide user
@@ -266,15 +275,12 @@ int usb_add_config(struct usb_composite_dev *,
266 */ 275 */
267struct usb_composite_driver { 276struct usb_composite_driver {
268 const char *name; 277 const char *name;
278 const char *iProduct;
279 const char *iManufacturer;
269 const struct usb_device_descriptor *dev; 280 const struct usb_device_descriptor *dev;
270 struct usb_gadget_strings **strings; 281 struct usb_gadget_strings **strings;
282 unsigned needs_serial:1;
271 283
272 /* REVISIT: bind() functions can be marked __init, which
273 * makes trouble for section mismatch analysis. See if
274 * we can't restructure things to avoid mismatching...
275 */
276
277 int (*bind)(struct usb_composite_dev *);
278 int (*unbind)(struct usb_composite_dev *); 284 int (*unbind)(struct usb_composite_dev *);
279 285
280 void (*disconnect)(struct usb_composite_dev *); 286 void (*disconnect)(struct usb_composite_dev *);
@@ -284,8 +290,10 @@ struct usb_composite_driver {
284 void (*resume)(struct usb_composite_dev *); 290 void (*resume)(struct usb_composite_dev *);
285}; 291};
286 292
287extern int usb_composite_register(struct usb_composite_driver *); 293extern int usb_composite_probe(struct usb_composite_driver *driver,
288extern void usb_composite_unregister(struct usb_composite_driver *); 294 int (*bind)(struct usb_composite_dev *cdev));
295extern void usb_composite_unregister(struct usb_composite_driver *driver);
296extern void usb_composite_setup_continue(struct usb_composite_dev *cdev);
289 297
290 298
291/** 299/**
@@ -334,13 +342,21 @@ struct usb_composite_dev {
334 struct list_head configs; 342 struct list_head configs;
335 struct usb_composite_driver *driver; 343 struct usb_composite_driver *driver;
336 u8 next_string_id; 344 u8 next_string_id;
345 u8 manufacturer_override;
346 u8 product_override;
347 u8 serial_override;
337 348
338 /* the gadget driver won't enable the data pullup 349 /* the gadget driver won't enable the data pullup
339 * while the deactivation count is nonzero. 350 * while the deactivation count is nonzero.
340 */ 351 */
341 unsigned deactivations; 352 unsigned deactivations;
342 353
343 /* protects at least deactivation count */ 354 /* the composite driver won't complete the control transfer's
355 * data/status stages till delayed_status is zero.
356 */
357 int delayed_status;
358
359 /* protects deactivations and delayed_status counts*/
344 spinlock_t lock; 360 spinlock_t lock;
345}; 361};
346 362