linux-bk/include/linux/usb.h
<<
>>
Prefs
   1#ifndef __LINUX_USB_H
   2#define __LINUX_USB_H
   3
   4#include <linux/mod_devicetable.h>
   5#include <linux/usb_ch9.h>
   6
   7#define USB_MAJOR                       180
   8
   9
  10#ifdef __KERNEL__
  11
  12#include <linux/config.h>
  13#include <linux/errno.h>        /* for -ENODEV */
  14#include <linux/delay.h>        /* for mdelay() */
  15#include <linux/interrupt.h>    /* for in_interrupt() */
  16#include <linux/list.h>         /* for struct list_head */
  17#include <linux/device.h>       /* for struct device */
  18#include <linux/fs.h>           /* for struct file_operations */
  19#include <linux/completion.h>   /* for struct completion */
  20#include <linux/sched.h>        /* for current && schedule_timeout */
  21
  22
  23static __inline__ void wait_ms(unsigned int ms)
  24{
  25        if(!in_interrupt()) {
  26                current->state = TASK_UNINTERRUPTIBLE;
  27                schedule_timeout(1 + ms * HZ / 1000);
  28        }
  29        else
  30                mdelay(ms);
  31}
  32
  33struct usb_device;
  34
  35/*-------------------------------------------------------------------------*/
  36
  37/*
  38 * Host-side wrappers for standard USB descriptors ... these are parsed
  39 * from the data provided by devices.  Parsing turns them from a flat
  40 * sequence of descriptors into a hierarchy:
  41 *
  42 *  - devices have one (usually) or more configs;
  43 *  - configs have one (often) or more interfaces;
  44 *  - interfaces have one (usually) or more settings;
  45 *  - each interface setting has zero or (usually) more endpoints.
  46 *
  47 * And there might be other descriptors mixed in with those.
  48 *
  49 * Devices may also have class-specific or vendor-specific descriptors.
  50 */
  51
  52/* host-side wrapper for parsed endpoint descriptors */
  53struct usb_host_endpoint {
  54        struct usb_endpoint_descriptor  desc;
  55
  56        unsigned char *extra;   /* Extra descriptors */
  57        int extralen;
  58};
  59
  60/* host-side wrapper for one interface setting's parsed descriptors */
  61struct usb_host_interface {
  62        struct usb_interface_descriptor desc;
  63
  64        /* array of desc.bNumEndpoint endpoints associated with this
  65         * interface setting.  these will be in no particular order.
  66         */
  67        struct usb_host_endpoint *endpoint;
  68
  69        unsigned char *extra;   /* Extra descriptors */
  70        int extralen;
  71};
  72
  73/**
  74 * struct usb_interface - what usb device drivers talk to
  75 * @altsetting: array of interface structures, one for each alternate
  76 *      setting that may be selected.  Each one includes a set of
  77 *      endpoint configurations.  They will be in no particular order.
  78 * @num_altsetting: number of altsettings defined.
  79 * @cur_altsetting: the current altsetting.
  80 * @driver: the USB driver that is bound to this interface.
  81 * @minor: the minor number assigned to this interface, if this
  82 *      interface is bound to a driver that uses the USB major number.
  83 *      If this interface does not use the USB major, this field should
  84 *      be unused.  The driver should set this value in the probe()
  85 *      function of the driver, after it has been assigned a minor
  86 *      number from the USB core by calling usb_register_dev().
  87 * @dev: driver model's view of this device
  88 * @class_dev: driver model's class view of this device.
  89 * @released: wait for the interface to be released when changing
  90 *      configurations.
  91 *
  92 * USB device drivers attach to interfaces on a physical device.  Each
  93 * interface encapsulates a single high level function, such as feeding
  94 * an audio stream to a speaker or reporting a change in a volume control.
  95 * Many USB devices only have one interface.  The protocol used to talk to
  96 * an interface's endpoints can be defined in a usb "class" specification,
  97 * or by a product's vendor.  The (default) control endpoint is part of
  98 * every interface, but is never listed among the interface's descriptors.
  99 *
 100 * The driver that is bound to the interface can use standard driver model
 101 * calls such as dev_get_drvdata() on the dev member of this structure.
 102 *
 103 * Each interface may have alternate settings.  The initial configuration
 104 * of a device sets altsetting 0, but the device driver can change
 105 * that setting using usb_set_interface().  Alternate settings are often
 106 * used to control the the use of periodic endpoints, such as by having
 107 * different endpoints use different amounts of reserved USB bandwidth.
 108 * All standards-conformant USB devices that use isochronous endpoints
 109 * will use them in non-default settings.
 110 *
 111 * The USB specification says that alternate setting numbers must run from
 112 * 0 to one less than the total number of alternate settings.  But some
 113 * devices manage to mess this up, and the structures aren't necessarily
 114 * stored in numerical order anyhow.  Use usb_altnum_to_altsetting() to
 115 * look up an alternate setting in the altsetting array based on its number.
 116 */
 117struct usb_interface {
 118        /* array of alternate settings for this interface,
 119         * stored in no particular order */
 120        struct usb_host_interface *altsetting;
 121
 122        struct usb_host_interface *cur_altsetting;      /* the currently
 123                                         * active alternate setting */
 124        unsigned num_altsetting;        /* number of alternate settings */
 125
 126        struct usb_driver *driver;      /* driver */
 127        int minor;                      /* minor number this interface is bound to */
 128        struct device dev;              /* interface specific device info */
 129        struct class_device *class_dev;
 130        struct completion *released;    /* wait for release */
 131};
 132#define to_usb_interface(d) container_of(d, struct usb_interface, dev)
 133#define interface_to_usbdev(intf) \
 134        container_of(intf->dev.parent, struct usb_device, dev)
 135
 136static inline void *usb_get_intfdata (struct usb_interface *intf)
 137{
 138        return dev_get_drvdata (&intf->dev);
 139}
 140
 141static inline void usb_set_intfdata (struct usb_interface *intf, void *data)
 142{
 143        dev_set_drvdata(&intf->dev, data);
 144}
 145
 146/* this maximum is arbitrary */
 147#define USB_MAXINTERFACES       32
 148
 149/**
 150 * struct usb_host_config - representation of a device's configuration
 151 * @desc: the device's configuration descriptor.
 152 * @interface: array of usb_interface structures, one for each interface
 153 *      in the configuration.  The number of interfaces is stored in
 154 *      desc.bNumInterfaces.
 155 * @extra: pointer to buffer containing all extra descriptors associated
 156 *      with this configuration (those preceding the first interface
 157 *      descriptor).
 158 * @extralen: length of the extra descriptors buffer.
 159 *
 160 * USB devices may have multiple configurations, but only one can be active
 161 * at any time.  Each encapsulates a different operational environment;
 162 * for example, a dual-speed device would have separate configurations for
 163 * full-speed and high-speed operation.  The number of configurations
 164 * available is stored in the device descriptor as bNumConfigurations.
 165 *
 166 * A configuration can contain multiple interfaces.  Each corresponds to
 167 * a different function of the USB device, and all are available whenever
 168 * the configuration is active.  The USB standard says that interfaces
 169 * are supposed to be numbered from 0 to desc.bNumInterfaces-1, but a lot
 170 * of devices get this wrong.  In addition, the interface array is not
 171 * guaranteed to be sorted in numerical order.  Use usb_ifnum_to_if() to
 172 * look up an interface entry based on its number.
 173 *
 174 * Device drivers should not attempt to activate configurations.  The choice
 175 * of which configuration to install is a policy decision based on such
 176 * considerations as available power, functionality provided, and the user's
 177 * desires (expressed through hotplug scripts).  However, drivers can call
 178 * usb_reset_configuration() to reinitialize the current configuration and
 179 * all its interfaces.
 180 */
 181struct usb_host_config {
 182        struct usb_config_descriptor    desc;
 183
 184        /* the interfaces associated with this configuration,
 185         * stored in no particular order */
 186        struct usb_interface *interface[USB_MAXINTERFACES];
 187
 188        unsigned char *extra;   /* Extra descriptors */
 189        int extralen;
 190};
 191
 192// FIXME remove; exported only for drivers/usb/misc/auserwald.c
 193// prefer usb_device->epnum[0..31]
 194extern struct usb_endpoint_descriptor *
 195        usb_epnum_to_ep_desc(struct usb_device *dev, unsigned epnum);
 196
 197int __usb_get_extra_descriptor(char *buffer, unsigned size,
 198        unsigned char type, void **ptr);
 199#define usb_get_extra_descriptor(ifpoint,type,ptr)\
 200        __usb_get_extra_descriptor((ifpoint)->extra,(ifpoint)->extralen,\
 201                type,(void**)ptr)
 202
 203/* -------------------------------------------------------------------------- */
 204
 205struct usb_operations;
 206
 207/* USB device number allocation bitmap */
 208struct usb_devmap {
 209        unsigned long devicemap[128 / (8*sizeof(unsigned long))];
 210};
 211
 212/*
 213 * Allocated per bus (tree of devices) we have:
 214 */
 215struct usb_bus {
 216        struct device *controller;      /* host/master side hardware */
 217        int busnum;                     /* Bus number (in order of reg) */
 218        char *bus_name;                 /* stable id (PCI slot_name etc) */
 219
 220        int devnum_next;                /* Next open device number in round-robin allocation */
 221
 222        struct usb_devmap devmap;       /* device address allocation map */
 223        struct usb_operations *op;      /* Operations (specific to the HC) */
 224        struct usb_device *root_hub;    /* Root hub */
 225        struct list_head bus_list;      /* list of busses */
 226        void *hcpriv;                   /* Host Controller private data */
 227
 228        int bandwidth_allocated;        /* on this bus: how much of the time
 229                                         * reserved for periodic (intr/iso)
 230                                         * requests is used, on average?
 231                                         * Units: microseconds/frame.
 232                                         * Limits: Full/low speed reserve 90%,
 233                                         * while high speed reserves 80%.
 234                                         */
 235        int bandwidth_int_reqs;         /* number of Interrupt requests */
 236        int bandwidth_isoc_reqs;        /* number of Isoc. requests */
 237
 238        struct dentry *usbfs_dentry;    /* usbfs dentry entry for the bus */
 239        struct dentry *usbdevfs_dentry; /* usbdevfs dentry entry for the bus */
 240
 241        struct class_device class_dev;  /* class device for this bus */
 242        void (*release)(struct usb_bus *bus);   /* function to destroy this bus's memory */
 243};
 244#define to_usb_bus(d) container_of(d, struct usb_bus, class_dev)
 245
 246
 247/* -------------------------------------------------------------------------- */
 248
 249/* This is arbitrary.
 250 * From USB 2.0 spec Table 11-13, offset 7, a hub can
 251 * have up to 255 ports. The most yet reported is 10.
 252 */
 253#define USB_MAXCHILDREN         (16)
 254
 255struct usb_tt;
 256
 257struct usb_device {
 258        int             devnum;         /* Address on USB bus */
 259        char            devpath [16];   /* Use in messages: /port/port/... */
 260        enum usb_device_state   state;  /* configured, not attached, etc */
 261        enum usb_device_speed   speed;  /* high/full/low (or error) */
 262
 263        struct usb_tt   *tt;            /* low/full speed dev, highspeed hub */
 264        int             ttport;         /* device port on that tt hub */
 265
 266        struct semaphore serialize;
 267
 268        unsigned int toggle[2];         /* one bit for each endpoint ([0] = IN, [1] = OUT) */
 269        unsigned int halted[2];         /* endpoint halts; one bit per endpoint # & direction; */
 270                                        /* [0] = IN, [1] = OUT */
 271        int epmaxpacketin[16];          /* INput endpoint specific maximums */
 272        int epmaxpacketout[16];         /* OUTput endpoint specific maximums */
 273
 274        struct usb_device *parent;      /* our hub, unless we're the root */
 275        struct usb_bus *bus;            /* Bus we're part of */
 276
 277        struct device dev;              /* Generic device interface */
 278
 279        struct usb_device_descriptor descriptor;/* Descriptor */
 280        struct usb_host_config *config; /* All of the configs */
 281        struct usb_host_config *actconfig;/* the active configuration */
 282
 283        char **rawdescriptors;          /* Raw descriptors for each config */
 284
 285        int have_langid;                /* whether string_langid is valid yet */
 286        int string_langid;              /* language ID for strings */
 287
 288        void *hcpriv;                   /* Host Controller private data */
 289        
 290        struct list_head filelist;
 291        struct dentry *usbfs_dentry;    /* usbfs dentry entry for the device */
 292        struct dentry *usbdevfs_dentry; /* usbdevfs dentry entry for the device */
 293
 294        /*
 295         * Child devices - these can be either new devices
 296         * (if this is a hub device), or different instances
 297         * of this same device.
 298         *
 299         * Each instance needs its own set of data structures.
 300         */
 301
 302        int maxchild;                   /* Number of ports if hub */
 303        struct usb_device *children[USB_MAXCHILDREN];
 304};
 305#define to_usb_device(d) container_of(d, struct usb_device, dev)
 306
 307extern struct usb_device *usb_get_dev(struct usb_device *dev);
 308extern void usb_put_dev(struct usb_device *dev);
 309
 310/* mostly for devices emulating SCSI over USB */
 311extern int usb_reset_device(struct usb_device *dev);
 312
 313extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id);
 314
 315/* for drivers using iso endpoints */
 316extern int usb_get_current_frame_number (struct usb_device *usb_dev);
 317
 318/* used these for multi-interface device registration */
 319extern int usb_driver_claim_interface(struct usb_driver *driver,
 320                        struct usb_interface *iface, void* priv);
 321extern int usb_interface_claimed(struct usb_interface *iface);
 322extern void usb_driver_release_interface(struct usb_driver *driver,
 323                        struct usb_interface *iface);
 324const struct usb_device_id *usb_match_id(struct usb_interface *interface,
 325                                         const struct usb_device_id *id);
 326
 327extern struct usb_interface *usb_find_interface(struct usb_driver *drv,
 328                int minor);
 329extern struct usb_interface *usb_ifnum_to_if(struct usb_device *dev,
 330                unsigned ifnum);
 331extern struct usb_host_interface *usb_altnum_to_altsetting(
 332                struct usb_interface *intf, unsigned int altnum);
 333
 334
 335/**
 336 * usb_make_path - returns stable device path in the usb tree
 337 * @dev: the device whose path is being constructed
 338 * @buf: where to put the string
 339 * @size: how big is "buf"?
 340 *
 341 * Returns length of the string (> 0) or negative if size was too small.
 342 *
 343 * This identifier is intended to be "stable", reflecting physical paths in
 344 * hardware such as physical bus addresses for host controllers or ports on
 345 * USB hubs.  That makes it stay the same until systems are physically
 346 * reconfigured, by re-cabling a tree of USB devices or by moving USB host
 347 * controllers.  Adding and removing devices, including virtual root hubs
 348 * in host controller driver modules, does not change these path identifers;
 349 * neither does rebooting or re-enumerating.  These are more useful identifiers
 350 * than changeable ("unstable") ones like bus numbers or device addresses.
 351 *
 352 * With a partial exception for devices connected to USB 2.0 root hubs, these
 353 * identifiers are also predictable.  So long as the device tree isn't changed,
 354 * plugging any USB device into a given hub port always gives it the same path.
 355 * Because of the use of "companion" controllers, devices connected to ports on
 356 * USB 2.0 root hubs (EHCI host controllers) will get one path ID if they are
 357 * high speed, and a different one if they are full or low speed.
 358 */
 359static inline int usb_make_path (struct usb_device *dev, char *buf, size_t size)
 360{
 361        int actual;
 362        actual = snprintf (buf, size, "usb-%s-%s", dev->bus->bus_name, dev->devpath);
 363        return (actual >= (int)size) ? -1 : actual;
 364}
 365
 366/*-------------------------------------------------------------------------*/
 367
 368#define USB_DEVICE_ID_MATCH_DEVICE              (USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT)
 369#define USB_DEVICE_ID_MATCH_DEV_RANGE           (USB_DEVICE_ID_MATCH_DEV_LO | USB_DEVICE_ID_MATCH_DEV_HI)
 370#define USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION  (USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_RANGE)
 371#define USB_DEVICE_ID_MATCH_DEV_INFO \
 372        (USB_DEVICE_ID_MATCH_DEV_CLASS | USB_DEVICE_ID_MATCH_DEV_SUBCLASS | USB_DEVICE_ID_MATCH_DEV_PROTOCOL)
 373#define USB_DEVICE_ID_MATCH_INT_INFO \
 374        (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS | USB_DEVICE_ID_MATCH_INT_PROTOCOL)
 375
 376/**
 377 * USB_DEVICE - macro used to describe a specific usb device
 378 * @vend: the 16 bit USB Vendor ID
 379 * @prod: the 16 bit USB Product ID
 380 *
 381 * This macro is used to create a struct usb_device_id that matches a
 382 * specific device.
 383 */
 384#define USB_DEVICE(vend,prod) \
 385        .match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = (vend), .idProduct = (prod)
 386/**
 387 * USB_DEVICE_VER - macro used to describe a specific usb device with a version range
 388 * @vend: the 16 bit USB Vendor ID
 389 * @prod: the 16 bit USB Product ID
 390 * @lo: the bcdDevice_lo value
 391 * @hi: the bcdDevice_hi value
 392 *
 393 * This macro is used to create a struct usb_device_id that matches a
 394 * specific device, with a version range.
 395 */
 396#define USB_DEVICE_VER(vend,prod,lo,hi) \
 397        .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION, .idVendor = (vend), .idProduct = (prod), .bcdDevice_lo = (lo), .bcdDevice_hi = (hi)
 398
 399/**
 400 * USB_DEVICE_INFO - macro used to describe a class of usb devices
 401 * @cl: bDeviceClass value
 402 * @sc: bDeviceSubClass value
 403 * @pr: bDeviceProtocol value
 404 *
 405 * This macro is used to create a struct usb_device_id that matches a
 406 * specific class of devices.
 407 */
 408#define USB_DEVICE_INFO(cl,sc,pr) \
 409        .match_flags = USB_DEVICE_ID_MATCH_DEV_INFO, .bDeviceClass = (cl), .bDeviceSubClass = (sc), .bDeviceProtocol = (pr)
 410
 411/**
 412 * USB_INTERFACE_INFO - macro used to describe a class of usb interfaces 
 413 * @cl: bInterfaceClass value
 414 * @sc: bInterfaceSubClass value
 415 * @pr: bInterfaceProtocol value
 416 *
 417 * This macro is used to create a struct usb_device_id that matches a
 418 * specific class of interfaces.
 419 */
 420#define USB_INTERFACE_INFO(cl,sc,pr) \
 421        .match_flags = USB_DEVICE_ID_MATCH_INT_INFO, .bInterfaceClass = (cl), .bInterfaceSubClass = (sc), .bInterfaceProtocol = (pr)
 422
 423/* -------------------------------------------------------------------------- */
 424
 425/**
 426 * struct usb_driver - identifies USB driver to usbcore
 427 * @owner: Pointer to the module owner of this driver; initialize
 428 *      it using THIS_MODULE.
 429 * @name: The driver name should be unique among USB drivers,
 430 *      and should normally be the same as the module name.
 431 * @probe: Called to see if the driver is willing to manage a particular
 432 *      interface on a device.  If it is, probe returns zero and uses
 433 *      dev_set_drvdata() to associate driver-specific data with the
 434 *      interface.  It may also use usb_set_interface() to specify the
 435 *      appropriate altsetting.  If unwilling to manage the interface,
 436 *      return a negative errno value.
 437 * @disconnect: Called when the interface is no longer accessible, usually
 438 *      because its device has been (or is being) disconnected or the
 439 *      driver module is being unloaded.
 440 * @ioctl: Used for drivers that want to talk to userspace through
 441 *      the "usbfs" filesystem.  This lets devices provide ways to
 442 *      expose information to user space regardless of where they
 443 *      do (or don't) show up otherwise in the filesystem.
 444 * @suspend: Called when the device is going to be suspended by the system.
 445 * @resume: Called when the device is being resumed by the system.
 446 * @id_table: USB drivers use ID table to support hotplugging.
 447 *      Export this with MODULE_DEVICE_TABLE(usb,...).  This must be set
 448 *      or your driver's probe function will never get called.
 449 * @driver: the driver model core driver structure.
 450 *
 451 * USB drivers must provide a name, probe() and disconnect() methods,
 452 * and an id_table.  Other driver fields are optional.
 453 *
 454 * The id_table is used in hotplugging.  It holds a set of descriptors,
 455 * and specialized data may be associated with each entry.  That table
 456 * is used by both user and kernel mode hotplugging support.
 457 *
 458 * The probe() and disconnect() methods are called in a context where
 459 * they can sleep, but they should avoid abusing the privilege.  Most
 460 * work to connect to a device should be done when the device is opened,
 461 * and undone at the last close.  The disconnect code needs to address
 462 * concurrency issues with respect to open() and close() methods, as
 463 * well as forcing all pending I/O requests to complete (by unlinking
 464 * them as necessary, and blocking until the unlinks complete).
 465 */
 466struct usb_driver {
 467        struct module *owner;
 468
 469        const char *name;
 470
 471        int (*probe) (struct usb_interface *intf,
 472                      const struct usb_device_id *id);
 473
 474        void (*disconnect) (struct usb_interface *intf);
 475
 476        int (*ioctl) (struct usb_interface *intf, unsigned int code, void *buf);
 477
 478        int (*suspend) (struct usb_interface *intf, u32 state);
 479        int (*resume) (struct usb_interface *intf);
 480
 481        const struct usb_device_id *id_table;
 482
 483        struct device_driver driver;
 484};
 485#define to_usb_driver(d) container_of(d, struct usb_driver, driver)
 486
 487extern struct bus_type usb_bus_type;
 488
 489/**
 490 * struct usb_class_driver - identifies a USB driver that wants to use the USB major number
 491 * @name: devfs name for this driver.  Will also be used by the driver
 492 *      class code to create a usb class device.
 493 * @fops: pointer to the struct file_operations of this driver.
 494 * @mode: the mode for the devfs file to be created for this driver.
 495 * @minor_base: the start of the minor range for this driver.
 496 *
 497 * This structure is used for the usb_register_dev() and
 498 * usb_unregister_dev() functions, to consolidate a number of the
 499 * parameters used for them.
 500 */
 501struct usb_class_driver {
 502        char *name;
 503        struct file_operations *fops;
 504        mode_t mode;
 505        int minor_base; 
 506};
 507
 508/*
 509 * use these in module_init()/module_exit()
 510 * and don't forget MODULE_DEVICE_TABLE(usb, ...)
 511 */
 512extern int usb_register(struct usb_driver *);
 513extern void usb_deregister(struct usb_driver *);
 514
 515extern int usb_register_dev(struct usb_interface *intf,
 516                            struct usb_class_driver *class_driver);
 517extern void usb_deregister_dev(struct usb_interface *intf,
 518                               struct usb_class_driver *class_driver);
 519
 520extern int usb_disabled(void);
 521
 522/* -------------------------------------------------------------------------- */
 523
 524/*
 525 * URB support, for asynchronous request completions
 526 */
 527
 528/*
 529 * urb->transfer_flags:
 530 */
 531#define URB_SHORT_NOT_OK        0x0001  /* report short reads as errors */
 532#define URB_ISO_ASAP            0x0002  /* iso-only, urb->start_frame ignored */
 533#define URB_NO_TRANSFER_DMA_MAP 0x0004  /* urb->transfer_dma valid on submit */
 534#define URB_NO_SETUP_DMA_MAP    0x0008  /* urb->setup_dma valid on submit */
 535#define URB_ASYNC_UNLINK        0x0010  /* usb_unlink_urb() returns asap */
 536#define URB_NO_FSBR             0x0020  /* UHCI-specific */
 537#define URB_ZERO_PACKET         0x0040  /* Finish bulk OUTs with short packet */
 538#define URB_NO_INTERRUPT        0x0080  /* HINT: no non-error interrupt needed */
 539
 540struct usb_iso_packet_descriptor {
 541        unsigned int offset;
 542        unsigned int length;            /* expected length */
 543        unsigned int actual_length;
 544        unsigned int status;
 545};
 546
 547struct urb;
 548struct pt_regs;
 549
 550typedef void (*usb_complete_t)(struct urb *, struct pt_regs *);
 551
 552/**
 553 * struct urb - USB Request Block
 554 * @urb_list: For use by current owner of the URB.
 555 * @pipe: Holds endpoint number, direction, type, and more.
 556 *      Create these values with the eight macros available;
 557 *      usb_{snd,rcv}TYPEpipe(dev,endpoint), where the TYPE is "ctrl"
 558 *      (control), "bulk", "int" (interrupt), or "iso" (isochronous).
 559 *      For example usb_sndbulkpipe() or usb_rcvintpipe().  Endpoint
 560 *      numbers range from zero to fifteen.  Note that "in" endpoint two
 561 *      is a different endpoint (and pipe) from "out" endpoint two.
 562 *      The current configuration controls the existence, type, and
 563 *      maximum packet size of any given endpoint.
 564 * @dev: Identifies the USB device to perform the request.
 565 * @status: This is read in non-iso completion functions to get the
 566 *      status of the particular request.  ISO requests only use it
 567 *      to tell whether the URB was unlinked; detailed status for
 568 *      each frame is in the fields of the iso_frame-desc.
 569 * @transfer_flags: A variety of flags may be used to affect how URB
 570 *      submission, unlinking, or operation are handled.  Different
 571 *      kinds of URB can use different flags.
 572 * @transfer_buffer:  This identifies the buffer to (or from) which
 573 *      the I/O request will be performed (unless URB_NO_TRANSFER_DMA_MAP
 574 *      is set).  This buffer must be suitable for DMA; allocate it with
 575 *      kmalloc() or equivalent.  For transfers to "in" endpoints, contents
 576 *      of this buffer will be modified.  This buffer is used for the data
 577 *      stage of control transfers.
 578 * @transfer_dma: When transfer_flags includes URB_NO_TRANSFER_DMA_MAP,
 579 *      the device driver is saying that it provided this DMA address,
 580 *      which the host controller driver should use in preference to the
 581 *      transfer_buffer.
 582 * @transfer_buffer_length: How big is transfer_buffer.  The transfer may
 583 *      be broken up into chunks according to the current maximum packet
 584 *      size for the endpoint, which is a function of the configuration
 585 *      and is encoded in the pipe.  When the length is zero, neither
 586 *      transfer_buffer nor transfer_dma is used.
 587 * @actual_length: This is read in non-iso completion functions, and
 588 *      it tells how many bytes (out of transfer_buffer_length) were
 589 *      transferred.  It will normally be the same as requested, unless
 590 *      either an error was reported or a short read was performed.
 591 *      The URB_SHORT_NOT_OK transfer flag may be used to make such
 592 *      short reads be reported as errors. 
 593 * @setup_packet: Only used for control transfers, this points to eight bytes
 594 *      of setup data.  Control transfers always start by sending this data
 595 *      to the device.  Then transfer_buffer is read or written, if needed.
 596 * @setup_dma: For control transfers with URB_NO_SETUP_DMA_MAP set, the
 597 *      device driver has provided this DMA address for the setup packet.
 598 *      The host controller driver should use this in preference to
 599 *      setup_packet.
 600 * @start_frame: Returns the initial frame for isochronous transfers.
 601 * @number_of_packets: Lists the number of ISO transfer buffers.
 602 * @interval: Specifies the polling interval for interrupt or isochronous
 603 *      transfers.  The units are frames (milliseconds) for for full and low
 604 *      speed devices, and microframes (1/8 millisecond) for highspeed ones.
 605 * @error_count: Returns the number of ISO transfers that reported errors.
 606 * @context: For use in completion functions.  This normally points to
 607 *      request-specific driver context.
 608 * @complete: Completion handler. This URB is passed as the parameter to the
 609 *      completion function.  The completion function may then do what
 610 *      it likes with the URB, including resubmitting or freeing it.
 611 * @iso_frame_desc: Used to provide arrays of ISO transfer buffers and to 
 612 *      collect the transfer status for each buffer.
 613 * @timeout: If set to zero, the urb will never timeout.  Otherwise this is
 614 *      the time in jiffies that this urb will timeout in.
 615 *
 616 * This structure identifies USB transfer requests.  URBs must be allocated by
 617 * calling usb_alloc_urb() and freed with a call to usb_free_urb().
 618 * Initialization may be done using various usb_fill_*_urb() functions.  URBs
 619 * are submitted using usb_submit_urb(), and pending requests may be canceled
 620 * using usb_unlink_urb().
 621 *
 622 * Data Transfer Buffers:
 623 *
 624 * Normally drivers provide I/O buffers allocated with kmalloc() or otherwise
 625 * taken from the general page pool.  That is provided by transfer_buffer
 626 * (control requests also use setup_packet), and host controller drivers
 627 * perform a dma mapping (and unmapping) for each buffer transferred.  Those
 628 * mapping operations can be expensive on some platforms (perhaps using a dma
 629 * bounce buffer or talking to an IOMMU),
 630 * although they're cheap on commodity x86 and ppc hardware.
 631 *
 632 * Alternatively, drivers may pass the URB_NO_xxx_DMA_MAP transfer flags,
 633 * which tell the host controller driver that no such mapping is needed since
 634 * the device driver is DMA-aware.  For example, a device driver might
 635 * allocate a DMA buffer with usb_buffer_alloc() or call usb_buffer_map().
 636 * When these transfer flags are provided, host controller drivers will
 637 * attempt to use the dma addresses found in the transfer_dma and/or
 638 * setup_dma fields rather than determining a dma address themselves.  (Note
 639 * that transfer_buffer and setup_packet must still be set because not all
 640 * host controllers use DMA, nor do virtual root hubs).
 641 *
 642 * Initialization:
 643 *
 644 * All URBs submitted must initialize dev, pipe,
 645 * transfer_flags (may be zero), complete, timeout (may be zero).
 646 * The URB_ASYNC_UNLINK transfer flag affects later invocations of
 647 * the usb_unlink_urb() routine.
 648 *
 649 * All URBs must also initialize 
 650 * transfer_buffer and transfer_buffer_length.  They may provide the
 651 * URB_SHORT_NOT_OK transfer flag, indicating that short reads are
 652 * to be treated as errors; that flag is invalid for write requests.
 653 *
 654 * Bulk URBs may
 655 * use the URB_ZERO_PACKET transfer flag, indicating that bulk OUT transfers
 656 * should always terminate with a short packet, even if it means adding an
 657 * extra zero length packet.
 658 *
 659 * Control URBs must provide a setup_packet.  The setup_packet and
 660 * transfer_buffer may each be mapped for DMA or not, independently of
 661 * the other.  The transfer_flags bits URB_NO_TRANSFER_DMA_MAP and
 662 * URB_NO_SETUP_DMA_MAP indicate which buffers have already been mapped.
 663 * URB_NO_SETUP_DMA_MAP is ignored for non-control URBs.
 664 *
 665 * Interrupt UBS must provide an interval, saying how often (in milliseconds
 666 * or, for highspeed devices, 125 microsecond units)
 667 * to poll for transfers.  After the URB has been submitted, the interval
 668 * field reflects how the transfer was actually scheduled.
 669 * The polling interval may be more frequent than requested.
 670 * For example, some controllers have a maximum interval of 32 microseconds,
 671 * while others support intervals of up to 1024 microseconds.
 672 * Isochronous URBs also have transfer intervals.  (Note that for isochronous
 673 * endpoints, as well as high speed interrupt endpoints, the encoding of
 674 * the transfer interval in the endpoint descriptor is logarithmic.
 675 * Device drivers must convert that value to linear units themselves.)
 676 *
 677 * Isochronous URBs normally use the URB_ISO_ASAP transfer flag, telling
 678 * the host controller to schedule the transfer as soon as bandwidth
 679 * utilization allows, and then set start_frame to reflect the actual frame
 680 * selected during submission.  Otherwise drivers must specify the start_frame
 681 * and handle the case where the transfer can't begin then.  However, drivers
 682 * won't know how bandwidth is currently allocated, and while they can
 683 * find the current frame using usb_get_current_frame_number () they can't
 684 * know the range for that frame number.  (Ranges for frame counter values
 685 * are HC-specific, and can go from 256 to 65536 frames from "now".)
 686 *
 687 * Isochronous URBs have a different data transfer model, in part because
 688 * the quality of service is only "best effort".  Callers provide specially
 689 * allocated URBs, with number_of_packets worth of iso_frame_desc structures
 690 * at the end.  Each such packet is an individual ISO transfer.  Isochronous
 691 * URBs are normally queued, submitted by drivers to arrange that
 692 * transfers are at least double buffered, and then explicitly resubmitted
 693 * in completion handlers, so
 694 * that data (such as audio or video) streams at as constant a rate as the
 695 * host controller scheduler can support.
 696 *
 697 * Completion Callbacks:
 698 *
 699 * The completion callback is made in_interrupt(), and one of the first
 700 * things that a completion handler should do is check the status field.
 701 * The status field is provided for all URBs.  It is used to report
 702 * unlinked URBs, and status for all non-ISO transfers.  It should not
 703 * be examined before the URB is returned to the completion handler.
 704 *
 705 * The context field is normally used to link URBs back to the relevant
 706 * driver or request state.
 707 *
 708 * When the completion callback is invoked for non-isochronous URBs, the
 709 * actual_length field tells how many bytes were transferred.  This field
 710 * is updated even when the URB terminated with an error or was unlinked.
 711 *
 712 * ISO transfer status is reported in the status and actual_length fields
 713 * of the iso_frame_desc array, and the number of errors is reported in
 714 * error_count.  Completion callbacks for ISO transfers will normally
 715 * (re)submit URBs to ensure a constant transfer rate.
 716 */
 717struct urb
 718{
 719        /* private, usb core and host controller only fields in the urb */
 720        spinlock_t lock;                /* lock for the URB */
 721        atomic_t count;                 /* reference count of the URB */
 722        void *hcpriv;                   /* private data for host controller */
 723        struct list_head urb_list;      /* list pointer to all active urbs */
 724        int bandwidth;                  /* bandwidth for INT/ISO request */
 725
 726        /* public, documented fields in the urb that can be used by drivers */
 727        struct usb_device *dev;         /* (in) pointer to associated device */
 728        unsigned int pipe;              /* (in) pipe information */
 729        int status;                     /* (return) non-ISO status */
 730        unsigned int transfer_flags;    /* (in) URB_SHORT_NOT_OK | ...*/
 731        void *transfer_buffer;          /* (in) associated data buffer */
 732        dma_addr_t transfer_dma;        /* (in) dma addr for transfer_buffer */
 733        int transfer_buffer_length;     /* (in) data buffer length */
 734        int actual_length;              /* (return) actual transfer length */
 735        unsigned char *setup_packet;    /* (in) setup packet (control only) */
 736        dma_addr_t setup_dma;           /* (in) dma addr for setup_packet */
 737        int start_frame;                /* (modify) start frame (ISO) */
 738        int number_of_packets;          /* (in) number of ISO packets */
 739        int interval;                   /* (modify) transfer interval (INT/ISO) */
 740        int error_count;                /* (return) number of ISO errors */
 741        int timeout;                    /* (in) timeout, in jiffies */
 742        void *context;                  /* (in) context for completion */
 743        usb_complete_t complete;        /* (in) completion routine */
 744        struct usb_iso_packet_descriptor iso_frame_desc[0];     /* (in) ISO ONLY */
 745};
 746
 747/* -------------------------------------------------------------------------- */
 748
 749/**
 750 * usb_fill_control_urb - initializes a control urb
 751 * @urb: pointer to the urb to initialize.
 752 * @dev: pointer to the struct usb_device for this urb.
 753 * @pipe: the endpoint pipe
 754 * @setup_packet: pointer to the setup_packet buffer
 755 * @transfer_buffer: pointer to the transfer buffer
 756 * @buffer_length: length of the transfer buffer
 757 * @complete: pointer to the usb_complete_t function
 758 * @context: what to set the urb context to.
 759 *
 760 * Initializes a control urb with the proper information needed to submit
 761 * it to a device.
 762 */
 763static inline void usb_fill_control_urb (struct urb *urb,
 764                                         struct usb_device *dev,
 765                                         unsigned int pipe,
 766                                         unsigned char *setup_packet,
 767                                         void *transfer_buffer,
 768                                         int buffer_length,
 769                                         usb_complete_t complete,
 770                                         void *context)
 771{
 772        spin_lock_init(&urb->lock);
 773        urb->dev = dev;
 774        urb->pipe = pipe;
 775        urb->setup_packet = setup_packet;
 776        urb->transfer_buffer = transfer_buffer;
 777        urb->transfer_buffer_length = buffer_length;
 778        urb->complete = complete;
 779        urb->context = context;
 780}
 781
 782/**
 783 * usb_fill_bulk_urb - macro to help initialize a bulk urb
 784 * @urb: pointer to the urb to initialize.
 785 * @dev: pointer to the struct usb_device for this urb.
 786 * @pipe: the endpoint pipe
 787 * @transfer_buffer: pointer to the transfer buffer
 788 * @buffer_length: length of the transfer buffer
 789 * @complete: pointer to the usb_complete_t function
 790 * @context: what to set the urb context to.
 791 *
 792 * Initializes a bulk urb with the proper information needed to submit it
 793 * to a device.
 794 */
 795static inline void usb_fill_bulk_urb (struct urb *urb,
 796                                      struct usb_device *dev,
 797                                      unsigned int pipe,
 798                                      void *transfer_buffer,
 799                                      int buffer_length,
 800                                      usb_complete_t complete,
 801                                      void *context)
 802{
 803        spin_lock_init(&urb->lock);
 804        urb->dev = dev;
 805        urb->pipe = pipe;
 806        urb->transfer_buffer = transfer_buffer;
 807        urb->transfer_buffer_length = buffer_length;
 808        urb->complete = complete;
 809        urb->context = context;
 810}
 811
 812/**
 813 * usb_fill_int_urb - macro to help initialize a interrupt urb
 814 * @urb: pointer to the urb to initialize.
 815 * @dev: pointer to the struct usb_device for this urb.
 816 * @pipe: the endpoint pipe
 817 * @transfer_buffer: pointer to the transfer buffer
 818 * @buffer_length: length of the transfer buffer
 819 * @complete: pointer to the usb_complete_t function
 820 * @context: what to set the urb context to.
 821 * @interval: what to set the urb interval to, encoded like
 822 *      the endpoint descriptor's bInterval value.
 823 *
 824 * Initializes a interrupt urb with the proper information needed to submit
 825 * it to a device.
 826 * Note that high speed interrupt endpoints use a logarithmic encoding of
 827 * the endpoint interval, and express polling intervals in microframes
 828 * (eight per millisecond) rather than in frames (one per millisecond).
 829 */
 830static inline void usb_fill_int_urb (struct urb *urb,
 831                                     struct usb_device *dev,
 832                                     unsigned int pipe,
 833                                     void *transfer_buffer,
 834                                     int buffer_length,
 835                                     usb_complete_t complete,
 836                                     void *context,
 837                                     int interval)
 838{
 839        spin_lock_init(&urb->lock);
 840        urb->dev = dev;
 841        urb->pipe = pipe;
 842        urb->transfer_buffer = transfer_buffer;
 843        urb->transfer_buffer_length = buffer_length;
 844        urb->complete = complete;
 845        urb->context = context;
 846        if (dev->speed == USB_SPEED_HIGH)
 847                urb->interval = 1 << (interval - 1);
 848        else
 849                urb->interval = interval;
 850        urb->start_frame = -1;
 851}
 852
 853extern void usb_init_urb(struct urb *urb);
 854extern struct urb *usb_alloc_urb(int iso_packets, int mem_flags);
 855extern void usb_free_urb(struct urb *urb);
 856#define usb_put_urb usb_free_urb
 857extern struct urb *usb_get_urb(struct urb *urb);
 858extern int usb_submit_urb(struct urb *urb, int mem_flags);
 859extern int usb_unlink_urb(struct urb *urb);
 860
 861#define HAVE_USB_BUFFERS
 862void *usb_buffer_alloc (struct usb_device *dev, size_t size,
 863        int mem_flags, dma_addr_t *dma);
 864void usb_buffer_free (struct usb_device *dev, size_t size,
 865        void *addr, dma_addr_t dma);
 866
 867struct urb *usb_buffer_map (struct urb *urb);
 868#if 0
 869void usb_buffer_dmasync (struct urb *urb);
 870#endif
 871void usb_buffer_unmap (struct urb *urb);
 872
 873struct scatterlist;
 874int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe,
 875                struct scatterlist *sg, int nents);
 876#if 0
 877void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe,
 878                struct scatterlist *sg, int n_hw_ents);
 879#endif
 880void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe,
 881                struct scatterlist *sg, int n_hw_ents);
 882
 883/*-------------------------------------------------------------------*
 884 *                         SYNCHRONOUS CALL SUPPORT                  *
 885 *-------------------------------------------------------------------*/
 886
 887extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
 888        __u8 request, __u8 requesttype, __u16 value, __u16 index,
 889        void *data, __u16 size, int timeout);
 890extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
 891        void *data, int len, int *actual_length,
 892        int timeout);
 893
 894/* wrappers around usb_control_msg() for the most common standard requests */
 895extern int usb_get_descriptor(struct usb_device *dev, unsigned char desctype,
 896        unsigned char descindex, void *buf, int size);
 897extern int usb_get_status(struct usb_device *dev,
 898        int type, int target, void *data);
 899extern int usb_get_string(struct usb_device *dev,
 900        unsigned short langid, unsigned char index, void *buf, int size);
 901extern int usb_string(struct usb_device *dev, int index,
 902        char *buf, size_t size);
 903
 904/* wrappers that also update important state inside usbcore */
 905extern int usb_clear_halt(struct usb_device *dev, int pipe);
 906extern int usb_reset_configuration(struct usb_device *dev);
 907extern int usb_set_configuration(struct usb_device *dev, int configuration);
 908extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate);
 909
 910/*
 911 * timeouts, in seconds, used for sending/receiving control messages
 912 * they typically complete within a few frames (msec) after they're issued
 913 * USB identifies 5 second timeouts, maybe more in a few cases, and a few
 914 * slow devices (like some MGE Ellipse UPSes) actually push that limit.
 915 */
 916#define USB_CTRL_GET_TIMEOUT    5
 917#define USB_CTRL_SET_TIMEOUT    5
 918
 919
 920/**
 921 * struct usb_sg_request - support for scatter/gather I/O
 922 * @status: zero indicates success, else negative errno
 923 * @bytes: counts bytes transferred.
 924 *
 925 * These requests are initialized using usb_sg_init(), and then are used
 926 * as request handles passed to usb_sg_wait() or usb_sg_cancel().  Most
 927 * members of the request object aren't for driver access.
 928 *
 929 * The status and bytecount values are valid only after usb_sg_wait()
 930 * returns.  If the status is zero, then the bytecount matches the total
 931 * from the request.
 932 *
 933 * After an error completion, drivers may need to clear a halt condition
 934 * on the endpoint.
 935 */
 936struct usb_sg_request {
 937        int                     status;
 938        size_t                  bytes;
 939
 940        /* 
 941         * members below are private to usbcore,
 942         * and are not provided for driver access!
 943         */
 944        spinlock_t              lock;
 945
 946        struct usb_device       *dev;
 947        int                     pipe;
 948        struct scatterlist      *sg;
 949        int                     nents;
 950
 951        int                     entries;
 952        struct urb              **urbs;
 953
 954        int                     count;
 955        struct completion       complete;
 956};
 957
 958int usb_sg_init (
 959        struct usb_sg_request   *io,
 960        struct usb_device       *dev,
 961        unsigned                pipe, 
 962        unsigned                period,
 963        struct scatterlist      *sg,
 964        int                     nents,
 965        size_t                  length,
 966        int                     mem_flags
 967);
 968void usb_sg_cancel (struct usb_sg_request *io);
 969void usb_sg_wait (struct usb_sg_request *io);
 970
 971
 972/* -------------------------------------------------------------------------- */
 973
 974/*
 975 * Calling this entity a "pipe" is glorifying it. A USB pipe
 976 * is something embarrassingly simple: it basically consists
 977 * of the following information:
 978 *  - device number (7 bits)
 979 *  - endpoint number (4 bits)
 980 *  - current Data0/1 state (1 bit) [Historical; now gone]
 981 *  - direction (1 bit)
 982 *  - speed (1 bit) [Historical and specific to USB 1.1; now gone.]
 983 *  - max packet size (2 bits: 8, 16, 32 or 64) [Historical; now gone.]
 984 *  - pipe type (2 bits: control, interrupt, bulk, isochronous)
 985 *
 986 * That's 18 bits. Really. Nothing more. And the USB people have
 987 * documented these eighteen bits as some kind of glorious
 988 * virtual data structure.
 989 *
 990 * Let's not fall in that trap. We'll just encode it as a simple
 991 * unsigned int. The encoding is:
 992 *
 993 *  - max size:         bits 0-1        [Historical; now gone.]
 994 *  - direction:        bit 7           (0 = Host-to-Device [Out],
 995 *                                       1 = Device-to-Host [In] ...
 996 *                                      like endpoint bEndpointAddress)
 997 *  - device:           bits 8-14       ... bit positions known to uhci-hcd
 998 *  - endpoint:         bits 15-18      ... bit positions known to uhci-hcd
 999 *  - Data0/1:          bit 19          [Historical; now gone. ]
1000 *  - lowspeed:         bit 26          [Historical; now gone. ]
1001 *  - pipe type:        bits 30-31      (00 = isochronous, 01 = interrupt,
1002 *                                       10 = control, 11 = bulk)
1003 *
1004 * Why? Because it's arbitrary, and whatever encoding we select is really
1005 * up to us. This one happens to share a lot of bit positions with the UHCI
1006 * specification, so that much of the uhci driver can just mask the bits
1007 * appropriately.
1008 */
1009
1010/* NOTE:  these are not the standard USB_ENDPOINT_XFER_* values!! */
1011#define PIPE_ISOCHRONOUS                0
1012#define PIPE_INTERRUPT                  1
1013#define PIPE_CONTROL                    2
1014#define PIPE_BULK                       3
1015
1016#define usb_maxpacket(dev, pipe, out)   (out \
1017                                ? (dev)->epmaxpacketout[usb_pipeendpoint(pipe)] \
1018                                : (dev)->epmaxpacketin [usb_pipeendpoint(pipe)] )
1019
1020#define usb_pipein(pipe)        ((pipe) & USB_DIR_IN)
1021#define usb_pipeout(pipe)       (!usb_pipein(pipe))
1022#define usb_pipedevice(pipe)    (((pipe) >> 8) & 0x7f)
1023#define usb_pipeendpoint(pipe)  (((pipe) >> 15) & 0xf)
1024#define usb_pipetype(pipe)      (((pipe) >> 30) & 3)
1025#define usb_pipeisoc(pipe)      (usb_pipetype((pipe)) == PIPE_ISOCHRONOUS)
1026#define usb_pipeint(pipe)       (usb_pipetype((pipe)) == PIPE_INTERRUPT)
1027#define usb_pipecontrol(pipe)   (usb_pipetype((pipe)) == PIPE_CONTROL)
1028#define usb_pipebulk(pipe)      (usb_pipetype((pipe)) == PIPE_BULK)
1029
1030/* The D0/D1 toggle bits ... USE WITH CAUTION (they're almost hcd-internal) */
1031#define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> (ep)) & 1)
1032#define usb_dotoggle(dev, ep, out)  ((dev)->toggle[out] ^= (1 << (ep)))
1033#define usb_settoggle(dev, ep, out, bit) ((dev)->toggle[out] = ((dev)->toggle[out] & ~(1 << (ep))) | ((bit) << (ep)))
1034
1035/* Endpoint halt control/status ... likewise USE WITH CAUTION */
1036#define usb_endpoint_running(dev, ep, out) ((dev)->halted[out] &= ~(1 << (ep)))
1037#define usb_endpoint_halted(dev, ep, out) ((dev)->halted[out] & (1 << (ep)))
1038
1039
1040static inline unsigned int __create_pipe(struct usb_device *dev, unsigned int endpoint)
1041{
1042        return (dev->devnum << 8) | (endpoint << 15);
1043}
1044
1045/* Create various pipes... */
1046#define usb_sndctrlpipe(dev,endpoint)   ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint))
1047#define usb_rcvctrlpipe(dev,endpoint)   ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN)
1048#define usb_sndisocpipe(dev,endpoint)   ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint))
1049#define usb_rcvisocpipe(dev,endpoint)   ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN)
1050#define usb_sndbulkpipe(dev,endpoint)   ((PIPE_BULK << 30) | __create_pipe(dev,endpoint))
1051#define usb_rcvbulkpipe(dev,endpoint)   ((PIPE_BULK << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN)
1052#define usb_sndintpipe(dev,endpoint)    ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint))
1053#define usb_rcvintpipe(dev,endpoint)    ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN)
1054
1055/* -------------------------------------------------------------------------- */
1056
1057#ifdef DEBUG
1058#define dbg(format, arg...) printk(KERN_DEBUG "%s: " format "\n" , __FILE__ , ## arg)
1059#else
1060#define dbg(format, arg...) do {} while (0)
1061#endif
1062
1063#define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , __FILE__ , ## arg)
1064#define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , __FILE__ , ## arg)
1065#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , __FILE__ , ## arg)
1066
1067
1068#endif  /* __KERNEL__ */
1069
1070#endif
1071
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.