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