aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb.h
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2007-10-12 21:27:47 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2007-10-12 21:27:47 -0400
commitb981d8b3f5e008ff10d993be633ad00564fc22cd (patch)
treee292dc07b22308912cf6a58354a608b9e5e8e1fd /include/linux/usb.h
parentb11d2127c4893a7315d1e16273bc8560049fa3ca (diff)
parent2b9e0aae1d50e880c58d46788e5e3ebd89d75d62 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts: drivers/macintosh/adbhid.c
Diffstat (limited to 'include/linux/usb.h')
-rw-r--r--include/linux/usb.h81
1 files changed, 74 insertions, 7 deletions
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 7a60946df3b6..c5c8f169d3cf 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -52,6 +52,7 @@ struct ep_device;
52 * @ep_dev: ep_device for sysfs info 52 * @ep_dev: ep_device for sysfs info
53 * @extra: descriptors following this endpoint in the configuration 53 * @extra: descriptors following this endpoint in the configuration
54 * @extralen: how many bytes of "extra" are valid 54 * @extralen: how many bytes of "extra" are valid
55 * @enabled: URBs may be submitted to this endpoint
55 * 56 *
56 * USB requests are always queued to a given endpoint, identified by a 57 * USB requests are always queued to a given endpoint, identified by a
57 * descriptor within an active interface in a given USB configuration. 58 * descriptor within an active interface in a given USB configuration.
@@ -64,6 +65,7 @@ struct usb_host_endpoint {
64 65
65 unsigned char *extra; /* Extra descriptors */ 66 unsigned char *extra; /* Extra descriptors */
66 int extralen; 67 int extralen;
68 int enabled;
67}; 69};
68 70
69/* host-side wrapper for one interface setting's parsed descriptors */ 71/* host-side wrapper for one interface setting's parsed descriptors */
@@ -94,6 +96,7 @@ enum usb_interface_condition {
94 * endpoint configurations. They will be in no particular order. 96 * endpoint configurations. They will be in no particular order.
95 * @num_altsetting: number of altsettings defined. 97 * @num_altsetting: number of altsettings defined.
96 * @cur_altsetting: the current altsetting. 98 * @cur_altsetting: the current altsetting.
99 * @intf_assoc: interface association descriptor
97 * @driver: the USB driver that is bound to this interface. 100 * @driver: the USB driver that is bound to this interface.
98 * @minor: the minor number assigned to this interface, if this 101 * @minor: the minor number assigned to this interface, if this
99 * interface is bound to a driver that uses the USB major number. 102 * interface is bound to a driver that uses the USB major number.
@@ -213,6 +216,7 @@ struct usb_interface_cache {
213 * @desc: the device's configuration descriptor. 216 * @desc: the device's configuration descriptor.
214 * @string: pointer to the cached version of the iConfiguration string, if 217 * @string: pointer to the cached version of the iConfiguration string, if
215 * present for this configuration. 218 * present for this configuration.
219 * @intf_assoc: list of any interface association descriptors in this config
216 * @interface: array of pointers to usb_interface structures, one for each 220 * @interface: array of pointers to usb_interface structures, one for each
217 * interface in the configuration. The number of interfaces is stored 221 * interface in the configuration. The number of interfaces is stored
218 * in desc.bNumInterfaces. These pointers are valid only while the 222 * in desc.bNumInterfaces. These pointers are valid only while the
@@ -342,6 +346,11 @@ struct usb_tt;
342 * 346 *
343 * Usbcore drivers should not set usbdev->state directly. Instead use 347 * Usbcore drivers should not set usbdev->state directly. Instead use
344 * usb_set_device_state(). 348 * usb_set_device_state().
349 *
350 * @authorized: (user space) policy determines if we authorize this
351 * device to be used or not. By default, wired USB
352 * devices are authorized. WUSB devices are not, until we
353 * authorize them from user space. FIXME -- complete doc
345 */ 354 */
346struct usb_device { 355struct usb_device {
347 int devnum; /* Address on USB bus */ 356 int devnum; /* Address on USB bus */
@@ -374,8 +383,11 @@ struct usb_device {
374 u8 portnum; /* Parent port number (origin 1) */ 383 u8 portnum; /* Parent port number (origin 1) */
375 u8 level; /* Number of USB hub ancestors */ 384 u8 level; /* Number of USB hub ancestors */
376 385
386 unsigned can_submit:1; /* URBs may be submitted */
377 unsigned discon_suspended:1; /* Disconnected while suspended */ 387 unsigned discon_suspended:1; /* Disconnected while suspended */
378 unsigned have_langid:1; /* whether string_langid is valid */ 388 unsigned have_langid:1; /* whether string_langid is valid */
389 unsigned authorized:1; /* Policy has determined we can use it */
390 unsigned wusb:1; /* Device is Wireless USB */
379 int string_langid; /* language ID for strings */ 391 int string_langid; /* language ID for strings */
380 392
381 /* static strings from the device */ 393 /* static strings from the device */
@@ -403,6 +415,7 @@ struct usb_device {
403 415
404 int pm_usage_cnt; /* usage counter for autosuspend */ 416 int pm_usage_cnt; /* usage counter for autosuspend */
405 u32 quirks; /* quirks of the whole device */ 417 u32 quirks; /* quirks of the whole device */
418 atomic_t urbnum; /* number of URBs submitted for the whole device */
406 419
407#ifdef CONFIG_PM 420#ifdef CONFIG_PM
408 struct delayed_work autosuspend; /* for delayed autosuspends */ 421 struct delayed_work autosuspend; /* for delayed autosuspends */
@@ -417,6 +430,7 @@ struct usb_device {
417 unsigned persist_enabled:1; /* USB_PERSIST enabled for this dev */ 430 unsigned persist_enabled:1; /* USB_PERSIST enabled for this dev */
418 unsigned autosuspend_disabled:1; /* autosuspend and autoresume */ 431 unsigned autosuspend_disabled:1; /* autosuspend and autoresume */
419 unsigned autoresume_disabled:1; /* disabled by the user */ 432 unsigned autoresume_disabled:1; /* disabled by the user */
433 unsigned skip_sys_resume:1; /* skip the next system resume */
420#endif 434#endif
421}; 435};
422#define to_usb_device(d) container_of(d, struct usb_device, dev) 436#define to_usb_device(d) container_of(d, struct usb_device, dev)
@@ -553,6 +567,29 @@ static inline int usb_make_path (struct usb_device *dev, char *buf,
553/*-------------------------------------------------------------------------*/ 567/*-------------------------------------------------------------------------*/
554 568
555/** 569/**
570 * usb_endpoint_num - get the endpoint's number
571 * @epd: endpoint to be checked
572 *
573 * Returns @epd's number: 0 to 15.
574 */
575static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
576{
577 return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
578}
579
580/**
581 * usb_endpoint_type - get the endpoint's transfer type
582 * @epd: endpoint to be checked
583 *
584 * Returns one of USB_ENDPOINT_XFER_{CONTROL, ISOC, BULK, INT} according
585 * to @epd's transfer type.
586 */
587static inline int usb_endpoint_type(const struct usb_endpoint_descriptor *epd)
588{
589 return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
590}
591
592/**
556 * usb_endpoint_dir_in - check if the endpoint has IN direction 593 * usb_endpoint_dir_in - check if the endpoint has IN direction
557 * @epd: endpoint to be checked 594 * @epd: endpoint to be checked
558 * 595 *
@@ -994,6 +1031,8 @@ extern int usb_disabled(void);
994 1031
995/* 1032/*
996 * urb->transfer_flags: 1033 * urb->transfer_flags:
1034 *
1035 * Note: URB_DIR_IN/OUT is automatically set in usb_submit_urb().
997 */ 1036 */
998#define URB_SHORT_NOT_OK 0x0001 /* report short reads as errors */ 1037#define URB_SHORT_NOT_OK 0x0001 /* report short reads as errors */
999#define URB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame 1038#define URB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame
@@ -1006,6 +1045,10 @@ extern int usb_disabled(void);
1006 * needed */ 1045 * needed */
1007#define URB_FREE_BUFFER 0x0100 /* Free transfer buffer with the URB */ 1046#define URB_FREE_BUFFER 0x0100 /* Free transfer buffer with the URB */
1008 1047
1048#define URB_DIR_IN 0x0200 /* Transfer from device to host */
1049#define URB_DIR_OUT 0
1050#define URB_DIR_MASK URB_DIR_IN
1051
1009struct usb_iso_packet_descriptor { 1052struct usb_iso_packet_descriptor {
1010 unsigned int offset; 1053 unsigned int offset;
1011 unsigned int length; /* expected length */ 1054 unsigned int length; /* expected length */
@@ -1035,6 +1078,8 @@ typedef void (*usb_complete_t)(struct urb *);
1035 * @urb_list: For use by current owner of the URB. 1078 * @urb_list: For use by current owner of the URB.
1036 * @anchor_list: membership in the list of an anchor 1079 * @anchor_list: membership in the list of an anchor
1037 * @anchor: to anchor URBs to a common mooring 1080 * @anchor: to anchor URBs to a common mooring
1081 * @ep: Points to the endpoint's data structure. Will eventually
1082 * replace @pipe.
1038 * @pipe: Holds endpoint number, direction, type, and more. 1083 * @pipe: Holds endpoint number, direction, type, and more.
1039 * Create these values with the eight macros available; 1084 * Create these values with the eight macros available;
1040 * usb_{snd,rcv}TYPEpipe(dev,endpoint), where the TYPE is "ctrl" 1085 * usb_{snd,rcv}TYPEpipe(dev,endpoint), where the TYPE is "ctrl"
@@ -1199,10 +1244,10 @@ struct urb
1199{ 1244{
1200 /* private: usb core and host controller only fields in the urb */ 1245 /* private: usb core and host controller only fields in the urb */
1201 struct kref kref; /* reference count of the URB */ 1246 struct kref kref; /* reference count of the URB */
1202 spinlock_t lock; /* lock for the URB */
1203 void *hcpriv; /* private data for host controller */ 1247 void *hcpriv; /* private data for host controller */
1204 atomic_t use_count; /* concurrent submissions counter */ 1248 atomic_t use_count; /* concurrent submissions counter */
1205 u8 reject; /* submissions will fail */ 1249 u8 reject; /* submissions will fail */
1250 int unlinked; /* unlink error code */
1206 1251
1207 /* public: documented fields in the urb that can be used by drivers */ 1252 /* public: documented fields in the urb that can be used by drivers */
1208 struct list_head urb_list; /* list head for use by the urb's 1253 struct list_head urb_list; /* list head for use by the urb's
@@ -1210,6 +1255,7 @@ struct urb
1210 struct list_head anchor_list; /* the URB may be anchored by the driver */ 1255 struct list_head anchor_list; /* the URB may be anchored by the driver */
1211 struct usb_anchor *anchor; 1256 struct usb_anchor *anchor;
1212 struct usb_device *dev; /* (in) pointer to associated device */ 1257 struct usb_device *dev; /* (in) pointer to associated device */
1258 struct usb_host_endpoint *ep; /* (internal) pointer to endpoint struct */
1213 unsigned int pipe; /* (in) pipe information */ 1259 unsigned int pipe; /* (in) pipe information */
1214 int status; /* (return) non-ISO status */ 1260 int status; /* (return) non-ISO status */
1215 unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/ 1261 unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/
@@ -1255,7 +1301,6 @@ static inline void usb_fill_control_urb (struct urb *urb,
1255 usb_complete_t complete_fn, 1301 usb_complete_t complete_fn,
1256 void *context) 1302 void *context)
1257{ 1303{
1258 spin_lock_init(&urb->lock);
1259 urb->dev = dev; 1304 urb->dev = dev;
1260 urb->pipe = pipe; 1305 urb->pipe = pipe;
1261 urb->setup_packet = setup_packet; 1306 urb->setup_packet = setup_packet;
@@ -1286,7 +1331,6 @@ static inline void usb_fill_bulk_urb (struct urb *urb,
1286 usb_complete_t complete_fn, 1331 usb_complete_t complete_fn,
1287 void *context) 1332 void *context)
1288{ 1333{
1289 spin_lock_init(&urb->lock);
1290 urb->dev = dev; 1334 urb->dev = dev;
1291 urb->pipe = pipe; 1335 urb->pipe = pipe;
1292 urb->transfer_buffer = transfer_buffer; 1336 urb->transfer_buffer = transfer_buffer;
@@ -1322,7 +1366,6 @@ static inline void usb_fill_int_urb (struct urb *urb,
1322 void *context, 1366 void *context,
1323 int interval) 1367 int interval)
1324{ 1368{
1325 spin_lock_init(&urb->lock);
1326 urb->dev = dev; 1369 urb->dev = dev;
1327 urb->pipe = pipe; 1370 urb->pipe = pipe;
1328 urb->transfer_buffer = transfer_buffer; 1371 urb->transfer_buffer = transfer_buffer;
@@ -1350,6 +1393,30 @@ extern void usb_unanchor_urb(struct urb *urb);
1350extern int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor, 1393extern int usb_wait_anchor_empty_timeout(struct usb_anchor *anchor,
1351 unsigned int timeout); 1394 unsigned int timeout);
1352 1395
1396/**
1397 * usb_urb_dir_in - check if an URB describes an IN transfer
1398 * @urb: URB to be checked
1399 *
1400 * Returns 1 if @urb describes an IN transfer (device-to-host),
1401 * otherwise 0.
1402 */
1403static inline int usb_urb_dir_in(struct urb *urb)
1404{
1405 return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_IN;
1406}
1407
1408/**
1409 * usb_urb_dir_out - check if an URB describes an OUT transfer
1410 * @urb: URB to be checked
1411 *
1412 * Returns 1 if @urb describes an OUT transfer (host-to-device),
1413 * otherwise 0.
1414 */
1415static inline int usb_urb_dir_out(struct urb *urb)
1416{
1417 return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT;
1418}
1419
1353void *usb_buffer_alloc (struct usb_device *dev, size_t size, 1420void *usb_buffer_alloc (struct usb_device *dev, size_t size,
1354 gfp_t mem_flags, dma_addr_t *dma); 1421 gfp_t mem_flags, dma_addr_t *dma);
1355void usb_buffer_free (struct usb_device *dev, size_t size, 1422void usb_buffer_free (struct usb_device *dev, size_t size,
@@ -1362,13 +1429,13 @@ void usb_buffer_unmap (struct urb *urb);
1362#endif 1429#endif
1363 1430
1364struct scatterlist; 1431struct scatterlist;
1365int usb_buffer_map_sg(const struct usb_device *dev, unsigned pipe, 1432int usb_buffer_map_sg(const struct usb_device *dev, int is_in,
1366 struct scatterlist *sg, int nents); 1433 struct scatterlist *sg, int nents);
1367#if 0 1434#if 0
1368void usb_buffer_dmasync_sg(const struct usb_device *dev, unsigned pipe, 1435void usb_buffer_dmasync_sg(const struct usb_device *dev, int is_in,
1369 struct scatterlist *sg, int n_hw_ents); 1436 struct scatterlist *sg, int n_hw_ents);
1370#endif 1437#endif
1371void usb_buffer_unmap_sg(const struct usb_device *dev, unsigned pipe, 1438void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
1372 struct scatterlist *sg, int n_hw_ents); 1439 struct scatterlist *sg, int n_hw_ents);
1373 1440
1374/*-------------------------------------------------------------------* 1441/*-------------------------------------------------------------------*