Commit 7d822283 authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

[PATCH] misc usbcore cleanups

Another cleanup patch:

   - removes more usbcore-internal symbols from sight of device drivers
       * some are only for the uhci driver
       * most are shared just a bit more widely
   - DEVNUM_ROUND_ROBIN is no longer an internal option
   - usb_root_hub_string() gone, per the FIXME
   - various kerneldoc fixes and updates
   - uses legal value (en-us) for root hub strings
   - hub driver only shows port fixed/removable for compound devices
parent faabca68
...@@ -289,7 +289,7 @@ static int rh_string ( ...@@ -289,7 +289,7 @@ static int rh_string (
// language ids // language ids
if (id == 0) { if (id == 0) {
*data++ = 4; *data++ = 3; /* 4 bytes string data */ *data++ = 4; *data++ = 3; /* 4 bytes string data */
*data++ = 0; *data++ = 0; /* some language id */ *data++ = 0x09; *data++ = 0x04; /* MSFT-speak for "en-us" */
return 4; return 4;
// serial number // serial number
...@@ -585,9 +585,7 @@ void usb_bus_init (struct usb_bus *bus) ...@@ -585,9 +585,7 @@ void usb_bus_init (struct usb_bus *bus)
{ {
memset (&bus->devmap, 0, sizeof(struct usb_devmap)); memset (&bus->devmap, 0, sizeof(struct usb_devmap));
#ifdef DEVNUM_ROUND_ROBIN
bus->devnum_next = 1; bus->devnum_next = 1;
#endif /* DEVNUM_ROUND_ROBIN */
bus->root_hub = NULL; bus->root_hub = NULL;
bus->hcpriv = NULL; bus->hcpriv = NULL;
...@@ -738,10 +736,10 @@ EXPORT_SYMBOL (usb_register_root_hub); ...@@ -738,10 +736,10 @@ EXPORT_SYMBOL (usb_register_root_hub);
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
/** /**
* usb_calc_bus_time: approximate periodic transaction time in nanoseconds * usb_calc_bus_time - approximate periodic transaction time in nanoseconds
* @speed: from dev->speed; USB_SPEED_{LOW,FULL,HIGH} * @speed: from dev->speed; USB_SPEED_{LOW,FULL,HIGH}
* @is_input: true iff the transaction sends data to the host * @is_input: true iff the transaction sends data to the host
* @is_isoc: true for isochronous transactions, false for interrupt ones * @isoc: true for isochronous transactions, false for interrupt ones
* @bytecount: how many bytes in the transaction. * @bytecount: how many bytes in the transaction.
* *
* Returns approximate bus time in nanoseconds for a periodic transaction. * Returns approximate bus time in nanoseconds for a periodic transaction.
...@@ -1286,8 +1284,8 @@ EXPORT_SYMBOL (usb_hcd_operations); ...@@ -1286,8 +1284,8 @@ EXPORT_SYMBOL (usb_hcd_operations);
* This hands the URB from HCD to its USB device driver, using its * This hands the URB from HCD to its USB device driver, using its
* completion function. The HCD has freed all per-urb resources * completion function. The HCD has freed all per-urb resources
* (and is done using urb->hcpriv). It also released all HCD locks; * (and is done using urb->hcpriv). It also released all HCD locks;
* the device driver won't cause deadlocks if it resubmits this URB, * the device driver won't cause problems if it frees, modifies,
* and won't confuse things by modifying and resubmitting this one. * or resubmits this URB.
* Bandwidth and other resources will be deallocated. * Bandwidth and other resources will be deallocated.
* *
* HCDs must not use this for periodic URBs that are still scheduled * HCDs must not use this for periodic URBs that are still scheduled
......
...@@ -19,6 +19,31 @@ ...@@ -19,6 +19,31 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
/* This file contains declarations of usbcore internals that are mostly
* used or exposed by Host Controller Drivers.
*/
/*
* USB Packet IDs (PIDs)
*/
#define USB_PID_UNDEF_0 0xf0
#define USB_PID_OUT 0xe1
#define USB_PID_ACK 0xd2
#define USB_PID_DATA0 0xc3
#define USB_PID_PING 0xb4 /* USB 2.0 */
#define USB_PID_SOF 0xa5
#define USB_PID_NYET 0x96 /* USB 2.0 */
#define USB_PID_DATA2 0x87 /* USB 2.0 */
#define USB_PID_SPLIT 0x78 /* USB 2.0 */
#define USB_PID_IN 0x69
#define USB_PID_NAK 0x5a
#define USB_PID_DATA1 0x4b
#define USB_PID_PREAMBLE 0x3c /* Token mode */
#define USB_PID_ERR 0x3c /* USB 2.0: handshake mode */
#define USB_PID_SETUP 0x2d
#define USB_PID_STALL 0x1e
#define USB_PID_MDATA 0x0f /* USB 2.0 */
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
/* /*
...@@ -234,13 +259,11 @@ extern int usb_new_device(struct usb_device *dev); ...@@ -234,13 +259,11 @@ extern int usb_new_device(struct usb_device *dev);
extern void usb_connect(struct usb_device *dev); extern void usb_connect(struct usb_device *dev);
extern void usb_disconnect(struct usb_device **); extern void usb_disconnect(struct usb_device **);
#ifndef _LINUX_HUB_H
/* exported to hub driver ONLY to support usb_reset_device () */ /* exported to hub driver ONLY to support usb_reset_device () */
extern int usb_get_configuration(struct usb_device *dev); extern int usb_get_configuration(struct usb_device *dev);
extern void usb_set_maxpacket(struct usb_device *dev); extern void usb_set_maxpacket(struct usb_device *dev);
extern void usb_destroy_configuration(struct usb_device *dev); extern void usb_destroy_configuration(struct usb_device *dev);
extern int usb_set_address(struct usb_device *dev); extern int usb_set_address(struct usb_device *dev);
#endif /* _LINUX_HUB_H */
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -354,10 +377,48 @@ extern struct usb_interface *usb_ifnum_to_if (struct usb_device *dev, ...@@ -354,10 +377,48 @@ extern struct usb_interface *usb_ifnum_to_if (struct usb_device *dev,
extern int usb_find_interface_driver (struct usb_device *dev, extern int usb_find_interface_driver (struct usb_device *dev,
struct usb_interface *interface); struct usb_interface *interface);
#define usb_endpoint_halt(dev, ep, out) ((dev)->halted[out] |= (1 << (ep)))
#define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN))
/* for probe/disconnect with correct module usage counting */ /* for probe/disconnect with correct module usage counting */
void *usb_bind_driver(struct usb_driver *driver, struct usb_interface *intf); void *usb_bind_driver(struct usb_driver *driver, struct usb_interface *intf);
void usb_unbind_driver(struct usb_device *device, struct usb_interface *intf); void usb_unbind_driver(struct usb_device *device, struct usb_interface *intf);
extern struct list_head usb_driver_list;
/*
* USB device fs stuff
*/
#ifdef CONFIG_USB_DEVICEFS
/*
* these are expected to be called from the USB core/hub thread
* with the kernel lock held
*/
extern void usbfs_add_bus(struct usb_bus *bus);
extern void usbfs_remove_bus(struct usb_bus *bus);
extern void usbfs_add_device(struct usb_device *dev);
extern void usbfs_remove_device(struct usb_device *dev);
extern void usbfs_update_special (void);
extern int usbfs_init(void);
extern void usbfs_cleanup(void);
#else /* CONFIG_USB_DEVICEFS */
static inline void usbfs_add_bus(struct usb_bus *bus) {}
static inline void usbfs_remove_bus(struct usb_bus *bus) {}
static inline void usbfs_add_device(struct usb_device *dev) {}
static inline void usbfs_remove_device(struct usb_device *dev) {}
static inline void usbfs_update_special (void) {}
static inline int usbfs_init(void) { return 0; }
static inline void usbfs_cleanup(void) { }
#endif /* CONFIG_USB_DEVICEFS */
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
/* hub.h ... DeviceRemovable in 2.4.2-ac11, gone in 2.4.10 */ /* hub.h ... DeviceRemovable in 2.4.2-ac11, gone in 2.4.10 */
......
...@@ -261,9 +261,8 @@ static int usb_hub_configure(struct usb_hub *hub, ...@@ -261,9 +261,8 @@ static int usb_hub_configure(struct usb_hub *hub,
{ {
struct usb_device *dev = hub->dev; struct usb_device *dev = hub->dev;
struct usb_hub_status hubstatus; struct usb_hub_status hubstatus;
char portstr[USB_MAXCHILDREN + 1];
unsigned int pipe; unsigned int pipe;
int i, maxp, ret; int maxp, ret;
hub->descriptor = kmalloc(sizeof(*hub->descriptor), GFP_KERNEL); hub->descriptor = kmalloc(sizeof(*hub->descriptor), GFP_KERNEL);
if (!hub->descriptor) { if (!hub->descriptor) {
...@@ -294,9 +293,17 @@ static int usb_hub_configure(struct usb_hub *hub, ...@@ -294,9 +293,17 @@ static int usb_hub_configure(struct usb_hub *hub,
le16_to_cpus(&hub->descriptor->wHubCharacteristics); le16_to_cpus(&hub->descriptor->wHubCharacteristics);
if (hub->descriptor->wHubCharacteristics & HUB_CHAR_COMPOUND) if (hub->descriptor->wHubCharacteristics & HUB_CHAR_COMPOUND) {
dbg("part of a compound device"); int i;
else char portstr [USB_MAXCHILDREN + 1];
for (i = 0; i < dev->maxchild; i++)
portstr[i] = hub->descriptor->DeviceRemovable
[((i + 1) / 8)] & (1 << ((i + 1) % 8))
? 'F' : 'R';
portstr[dev->maxchild] = 0;
dbg("compound device; port removable status: %s", portstr);
} else
dbg("standalone hub"); dbg("standalone hub");
switch (hub->descriptor->wHubCharacteristics & HUB_CHAR_LPSM) { switch (hub->descriptor->wHubCharacteristics & HUB_CHAR_LPSM) {
...@@ -371,14 +378,6 @@ static int usb_hub_configure(struct usb_hub *hub, ...@@ -371,14 +378,6 @@ static int usb_hub_configure(struct usb_hub *hub,
dbg("hub controller current requirement: %dmA", dbg("hub controller current requirement: %dmA",
hub->descriptor->bHubContrCurrent); hub->descriptor->bHubContrCurrent);
for (i = 0; i < dev->maxchild; i++)
portstr[i] = hub->descriptor->DeviceRemovable
[((i + 1) / 8)] & (1 << ((i + 1) % 8))
? 'F' : 'R';
portstr[dev->maxchild] = 0;
dbg("port removable status: %s", portstr);
ret = usb_get_hub_status(dev, &hubstatus); ret = usb_get_hub_status(dev, &hubstatus);
if (ret < 0) { if (ret < 0) {
err("Unable to get hub status (err = %d)", ret); err("Unable to get hub status (err = %d)", ret);
......
...@@ -88,15 +88,17 @@ struct urb * usb_get_urb(struct urb *urb) ...@@ -88,15 +88,17 @@ struct urb * usb_get_urb(struct urb *urb)
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
/** /**
* usb_submit_urb - asynchronously issue a transfer request for an endpoint * usb_submit_urb - issue an asynchronous transfer request for an endpoint
* @urb: pointer to the urb describing the request * @urb: pointer to the urb describing the request
* @mem_flags: the type of memory to allocate, see kmalloc() for a list * @mem_flags: the type of memory to allocate, see kmalloc() for a list
* of valid options for this. * of valid options for this.
* *
* This submits a transfer request, and transfers control of the URB * This submits a transfer request, and transfers control of the URB
* describing that request to the USB subsystem. Request completion will * describing that request to the USB subsystem. Request completion will
* indicated later, asynchronously, by calling the completion handler. * be indicated later, asynchronously, by calling the completion handler.
* This call may be issued in interrupt context. * The three types of completion are success, error, and unlink
* (also called "request cancellation").
* URBs may be submitted in interrupt context.
* *
* The caller must have correctly initialized the URB before submitting * The caller must have correctly initialized the URB before submitting
* it. Functions such as usb_fill_bulk_urb() and usb_fill_control_urb() are * it. Functions such as usb_fill_bulk_urb() and usb_fill_control_urb() are
...@@ -148,20 +150,19 @@ struct urb * usb_get_urb(struct urb *urb) ...@@ -148,20 +150,19 @@ struct urb * usb_get_urb(struct urb *urb)
* *
* Memory Flags: * Memory Flags:
* *
* General rules for how to decide which mem_flags to use: * The general rules for how to decide which mem_flags to use
* * are the same as for kmalloc. There are four
* Basically the rules are the same as for kmalloc. There are four
* different possible values; GFP_KERNEL, GFP_NOFS, GFP_NOIO and * different possible values; GFP_KERNEL, GFP_NOFS, GFP_NOIO and
* GFP_ATOMIC. * GFP_ATOMIC.
* *
* GFP_NOFS is not ever used, as it has not been implemented yet. * GFP_NOFS is not ever used, as it has not been implemented yet.
* *
* There are three situations you must use GFP_ATOMIC. * GFP_ATOMIC is used when
* a) you are inside a completion handler, an interrupt, bottom half, * (a) you are inside a completion handler, an interrupt, bottom half,
* tasklet or timer. * tasklet or timer, or
* b) you are holding a spinlock or rwlock (does not apply to * (b) you are holding a spinlock or rwlock (does not apply to
* semaphores) * semaphores), or
* c) current->state != TASK_RUNNING, this is the case only after * (c) current->state != TASK_RUNNING, this is the case only after
* you've changed it. * you've changed it.
* *
* GFP_NOIO is used in the block io path and error handling of storage * GFP_NOIO is used in the block io path and error handling of storage
...@@ -169,17 +170,17 @@ struct urb * usb_get_urb(struct urb *urb) ...@@ -169,17 +170,17 @@ struct urb * usb_get_urb(struct urb *urb)
* *
* All other situations use GFP_KERNEL. * All other situations use GFP_KERNEL.
* *
* Specfic rules for how to decide which mem_flags to use: * Some more specific rules for mem_flags can be inferred, such as
* * (1) start_xmit, timeout, and receive methods of network drivers must
* - start_xmit, timeout, and receive methods of network drivers must * use GFP_ATOMIC (they are called with a spinlock held);
* use GFP_ATOMIC (spinlock) * (2) queuecommand methods of scsi drivers must use GFP_ATOMIC (also
* - queuecommand methods of scsi drivers must use GFP_ATOMIC (spinlock) * called with a spinlock held);
* - If you use a kernel thread with a network driver you must use * (3) If you use a kernel thread with a network driver you must use
* GFP_NOIO, unless b) or c) apply * GFP_NOIO, unless (b) or (c) apply;
* - After you have done a down() you use GFP_KERNEL, unless b) or c) * (4) after you have done a down() you can use GFP_KERNEL, unless (b) or (c)
* apply or your are in a storage driver's block io path * apply or your are in a storage driver's block io path;
* - probe and disconnect use GFP_KERNEL unless b) or c) apply * (5) USB probe and disconnect can use GFP_KERNEL unless (b) or (c) apply; and
* - Changing firmware on a running storage or net device uses * (6) changing firmware on a running storage or net device uses
* GFP_NOIO, unless b) or c) apply * GFP_NOIO, unless b) or c) apply
* *
*/ */
......
...@@ -1057,56 +1057,6 @@ int usb_get_current_frame_number(struct usb_device *dev) ...@@ -1057,56 +1057,6 @@ int usb_get_current_frame_number(struct usb_device *dev)
} }
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
/* for returning string descriptors in UTF-16LE */
static int ascii2utf (char *ascii, __u8 *utf, int utfmax)
{
int retval;
for (retval = 0; *ascii && utfmax > 1; utfmax -= 2, retval += 2) {
*utf++ = *ascii++ & 0x7f;
*utf++ = 0;
}
return retval;
}
/*
* root_hub_string is used by each host controller's root hub code,
* so that they're identified consistently throughout the system.
*/
int usb_root_hub_string (int id, int serial, char *type, __u8 *data, int len)
{
char buf [30];
// assert (len > (2 * (sizeof (buf) + 1)));
// assert (strlen (type) <= 8);
// language ids
if (id == 0) {
*data++ = 4; *data++ = 3; /* 4 bytes data */
*data++ = 0; *data++ = 0; /* some language id */
return 4;
// serial number
} else if (id == 1) {
sprintf (buf, "%x", serial);
// product description
} else if (id == 2) {
sprintf (buf, "USB %s Root Hub", type);
// id 3 == vendor description
// unsupported IDs --> "stall"
} else
return 0;
data [0] = 2 + ascii2utf (buf, data + 2, len - 2);
data [1] = 3;
return data [0];
}
/* /*
* __usb_get_extra_descriptor() finds a descriptor of specific type in the * __usb_get_extra_descriptor() finds a descriptor of specific type in the
* extra field of the interface and endpoint descriptor structs. * extra field of the interface and endpoint descriptor structs.
...@@ -1221,16 +1171,13 @@ void usb_connect(struct usb_device *dev) ...@@ -1221,16 +1171,13 @@ void usb_connect(struct usb_device *dev)
* won't have seen this, but not so for reinit ... * won't have seen this, but not so for reinit ...
*/ */
dev->descriptor.bMaxPacketSize0 = 8; /* Start off at 8 bytes */ dev->descriptor.bMaxPacketSize0 = 8; /* Start off at 8 bytes */
#ifndef DEVNUM_ROUND_ROBIN
devnum = find_next_zero_bit(dev->bus->devmap.devicemap, 128, 1);
#else /* round_robin alloc of devnums */
/* Try to allocate the next devnum beginning at bus->devnum_next. */ /* Try to allocate the next devnum beginning at bus->devnum_next. */
devnum = find_next_zero_bit(dev->bus->devmap.devicemap, 128, dev->bus->devnum_next); devnum = find_next_zero_bit(dev->bus->devmap.devicemap, 128, dev->bus->devnum_next);
if (devnum >= 128) if (devnum >= 128)
devnum = find_next_zero_bit(dev->bus->devmap.devicemap, 128, 1); devnum = find_next_zero_bit(dev->bus->devmap.devicemap, 128, 1);
dev->bus->devnum_next = ( devnum >= 127 ? 1 : devnum + 1); dev->bus->devnum_next = ( devnum >= 127 ? 1 : devnum + 1);
#endif /* round_robin alloc of devnums */
if (devnum < 128) { if (devnum < 128) {
set_bit(devnum, dev->bus->devmap.devicemap); set_bit(devnum, dev->bus->devmap.devicemap);
...@@ -1649,7 +1596,6 @@ EXPORT_SYMBOL(usb_interface_claimed); ...@@ -1649,7 +1596,6 @@ EXPORT_SYMBOL(usb_interface_claimed);
EXPORT_SYMBOL(usb_driver_release_interface); EXPORT_SYMBOL(usb_driver_release_interface);
EXPORT_SYMBOL(usb_match_id); EXPORT_SYMBOL(usb_match_id);
EXPORT_SYMBOL(usb_root_hub_string);
EXPORT_SYMBOL(usb_new_device); EXPORT_SYMBOL(usb_new_device);
EXPORT_SYMBOL(usb_reset_device); EXPORT_SYMBOL(usb_reset_device);
EXPORT_SYMBOL(usb_connect); EXPORT_SYMBOL(usb_connect);
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
* *
*-------------------------------------------------------------------------*/ *-------------------------------------------------------------------------*/
/* FIXME: reuse the root hub framework in usbcore, shrinking this code. */
#ifdef DEBUG #ifdef DEBUG
#undef DEBUG #undef DEBUG
#endif #endif
...@@ -229,6 +231,52 @@ static int rh_init_int_timer (struct urb * urb) ...@@ -229,6 +231,52 @@ static int rh_init_int_timer (struct urb * urb)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
/* for returning string descriptors in UTF-16LE */
static int ascii2utf (char *ascii, __u8 *utf, int utfmax)
{
int retval;
for (retval = 0; *ascii && utfmax > 1; utfmax -= 2, retval += 2) {
*utf++ = *ascii++ & 0x7f;
*utf++ = 0;
}
return retval;
}
static int root_hub_string (int id, int serial, char *type, __u8 *data, int len)
{
char buf [30];
// assert (len > (2 * (sizeof (buf) + 1)));
// assert (strlen (type) <= 8);
// language ids
if (id == 0) {
*data++ = 4; *data++ = 3; /* 4 bytes data */
*data++ = 0; *data++ = 0; /* some language id */
return 4;
// serial number
} else if (id == 1) {
sprintf (buf, "%x", serial);
// product description
} else if (id == 2) {
sprintf (buf, "USB %s Root Hub", type);
// id 3 == vendor description
// unsupported IDs --> "stall"
} else
return 0;
data [0] = 2 + ascii2utf (buf, data + 2, len - 2);
data [1] = 3;
return data [0];
}
/*-------------------------------------------------------------------------*/
/* helper macro */ /* helper macro */
#define OK(x) len = (x); break #define OK(x) len = (x); break
...@@ -409,7 +457,7 @@ static int rh_submit_urb (struct urb * urb) ...@@ -409,7 +457,7 @@ static int rh_submit_urb (struct urb * urb)
OK (len); OK (len);
case (0x03): /* string descriptors */ case (0x03): /* string descriptors */
len = usb_root_hub_string (wValue & 0xff, (int) (long) 0, len = root_hub_string (wValue & 0xff, (int) (long) 0,
"SL811HS", data, wLength); "SL811HS", data, wLength);
if (len > 0) { if (len > 0) {
data_buf = data; data_buf = data;
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/usb.h> #include <linux/usb.h>
#define usb_packetid(pipe) (usb_pipein(pipe) ? USB_PID_IN : USB_PID_OUT)
#define PIPE_DEVEP_MASK 0x0007ff00
/* /*
* Universal Host Controller Interface data structures and defines * Universal Host Controller Interface data structures and defines
*/ */
......
...@@ -57,27 +57,6 @@ ...@@ -57,27 +57,6 @@
#define USB_ENDPOINT_XFER_BULK 2 #define USB_ENDPOINT_XFER_BULK 2
#define USB_ENDPOINT_XFER_INT 3 #define USB_ENDPOINT_XFER_INT 3
/*
* USB Packet IDs (PIDs)
*/
#define USB_PID_UNDEF_0 0xf0
#define USB_PID_OUT 0xe1
#define USB_PID_ACK 0xd2
#define USB_PID_DATA0 0xc3
#define USB_PID_PING 0xb4 /* USB 2.0 */
#define USB_PID_SOF 0xa5
#define USB_PID_NYET 0x96 /* USB 2.0 */
#define USB_PID_DATA2 0x87 /* USB 2.0 */
#define USB_PID_SPLIT 0x78 /* USB 2.0 */
#define USB_PID_IN 0x69
#define USB_PID_NAK 0x5a
#define USB_PID_DATA1 0x4b
#define USB_PID_PREAMBLE 0x3c /* Token mode */
#define USB_PID_ERR 0x3c /* USB 2.0: handshake mode */
#define USB_PID_SETUP 0x2d
#define USB_PID_STALL 0x1e
#define USB_PID_MDATA 0x0f /* USB 2.0 */
/* /*
* Standard requests * Standard requests
*/ */
...@@ -318,8 +297,6 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size, ...@@ -318,8 +297,6 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size,
struct usb_operations; struct usb_operations;
#define DEVNUM_ROUND_ROBIN /***** OPTION *****/
/* /*
* Allocated per bus we have * Allocated per bus we have
*/ */
...@@ -327,9 +304,7 @@ struct usb_bus { ...@@ -327,9 +304,7 @@ struct usb_bus {
int busnum; /* Bus number (in order of reg) */ int busnum; /* Bus number (in order of reg) */
char *bus_name; /* stable id (PCI slot_name etc) */ char *bus_name; /* stable id (PCI slot_name etc) */
#ifdef DEVNUM_ROUND_ROBIN
int devnum_next; /* Next open device number in round-robin allocation */ int devnum_next; /* Next open device number in round-robin allocation */
#endif /* DEVNUM_ROUND_ROBIN */
struct usb_devmap devmap; /* device address allocation map */ struct usb_devmap devmap; /* device address allocation map */
struct usb_operations *op; /* Operations (specific to the HC) */ struct usb_operations *op; /* Operations (specific to the HC) */
...@@ -353,10 +328,6 @@ struct usb_bus { ...@@ -353,10 +328,6 @@ struct usb_bus {
atomic_t refcnt; atomic_t refcnt;
}; };
// FIXME: root_hub_string vanishes when "usb_hcd" conversion is done,
// along with pre-hcd versions of the OHCI and UHCI drivers.
extern int usb_root_hub_string(int id, int serial,
char *type, __u8 *data, int len);
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
...@@ -745,7 +716,7 @@ typedef void (*usb_complete_t)(struct urb *); ...@@ -745,7 +716,7 @@ typedef void (*usb_complete_t)(struct urb *);
/** /**
* struct urb - USB Request Block * struct urb - USB Request Block
* @urb_list: For use by current owner of the URB. * @urb_list: For use by current owner of the URB.
* @pipe: Holds endpoint number, direction, type, and max packet size. * @pipe: Holds endpoint number, direction, type, and more.
* Create these values with the eight macros available; * Create these values with the eight macros available;
* usb_{snd,rcv}TYPEpipe(dev,endpoint), where the type is "ctrl" * usb_{snd,rcv}TYPEpipe(dev,endpoint), where the type is "ctrl"
* (control), "bulk", "int" (interrupt), or "iso" (isochronous). * (control), "bulk", "int" (interrupt), or "iso" (isochronous).
...@@ -774,7 +745,8 @@ typedef void (*usb_complete_t)(struct urb *); ...@@ -774,7 +745,8 @@ typedef void (*usb_complete_t)(struct urb *);
* @transfer_buffer_length: How big is transfer_buffer. The transfer may * @transfer_buffer_length: How big is transfer_buffer. The transfer may
* be broken up into chunks according to the current maximum packet * be broken up into chunks according to the current maximum packet
* size for the endpoint, which is a function of the configuration * size for the endpoint, which is a function of the configuration
* and is encoded in the pipe. * and is encoded in the pipe. When the length is zero, neither
* transfer_buffer nor transfer_dma is used.
* @actual_length: This is read in non-iso completion functions, and * @actual_length: This is read in non-iso completion functions, and
* it tells how many bytes (out of transfer_buffer_length) were * it tells how many bytes (out of transfer_buffer_length) were
* transferred. It will normally be the same as requested, unless * transferred. It will normally be the same as requested, unless
...@@ -787,7 +759,7 @@ typedef void (*usb_complete_t)(struct urb *); ...@@ -787,7 +759,7 @@ typedef void (*usb_complete_t)(struct urb *);
* (Not used when URB_NO_DMA_MAP is set.) * (Not used when URB_NO_DMA_MAP is set.)
* @setup_dma: For control transfers with URB_NO_DMA_MAP set, the device * @setup_dma: For control transfers with URB_NO_DMA_MAP set, the device
* driver has provided this DMA address for the setup packet. The * driver has provided this DMA address for the setup packet. The
* host controller driver should use instead of setup_buffer. * host controller driver should use this instead of setup_buffer.
* If there is a data phase, its buffer is identified by transfer_dma. * If there is a data phase, its buffer is identified by transfer_dma.
* @start_frame: Returns the initial frame for interrupt or isochronous * @start_frame: Returns the initial frame for interrupt or isochronous
* transfers. * transfers.
...@@ -817,8 +789,9 @@ typedef void (*usb_complete_t)(struct urb *); ...@@ -817,8 +789,9 @@ typedef void (*usb_complete_t)(struct urb *);
* taken from the general page pool. That is provided by transfer_buffer * taken from the general page pool. That is provided by transfer_buffer
* (control requests also use setup_packet), and host controller drivers * (control requests also use setup_packet), and host controller drivers
* perform a dma mapping (and unmapping) for each buffer transferred. Those * perform a dma mapping (and unmapping) for each buffer transferred. Those
* mapping operations can be expensive on some platforms (such using a dma * mapping operations can be expensive on some platforms (perhaps using a dma
* bounce buffer), although they're cheap on commodity x86 and ppc hardware. * bounce buffer or talking to an IOMMU),
* although they're cheap on commodity x86 and ppc hardware.
* *
* Alternatively, drivers may pass the URB_NO_DMA_MAP transfer flag, which * Alternatively, drivers may pass the URB_NO_DMA_MAP transfer flag, which
* tells the host controller driver that no such mapping is needed since * tells the host controller driver that no such mapping is needed since
...@@ -884,7 +857,7 @@ typedef void (*usb_complete_t)(struct urb *); ...@@ -884,7 +857,7 @@ typedef void (*usb_complete_t)(struct urb *);
* things that a completion handler should do is check the status field. * things that a completion handler should do is check the status field.
* The status field is provided for all URBs. It is used to report * The status field is provided for all URBs. It is used to report
* unlinked URBs, and status for all non-ISO transfers. It should not * unlinked URBs, and status for all non-ISO transfers. It should not
* be examined outside of the completion handler. * be examined before the URB is returned to the completion handler.
* *
* The context field is normally used to link URBs back to the relevant * The context field is normally used to link URBs back to the relevant
* driver or request state. * driver or request state.
...@@ -1075,7 +1048,6 @@ extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, ...@@ -1075,7 +1048,6 @@ extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
int timeout); int timeout);
/* wrappers around usb_control_msg() for the most common standard requests */ /* wrappers around usb_control_msg() for the most common standard requests */
extern int usb_clear_halt(struct usb_device *dev, int pipe);
extern int usb_get_descriptor(struct usb_device *dev, unsigned char desctype, extern int usb_get_descriptor(struct usb_device *dev, unsigned char desctype,
unsigned char descindex, void *buf, int size); unsigned char descindex, void *buf, int size);
extern int usb_get_device_descriptor(struct usb_device *dev); extern int usb_get_device_descriptor(struct usb_device *dev);
...@@ -1085,6 +1057,9 @@ extern int usb_get_string(struct usb_device *dev, ...@@ -1085,6 +1057,9 @@ extern int usb_get_string(struct usb_device *dev,
unsigned short langid, unsigned char index, void *buf, int size); unsigned short langid, unsigned char index, void *buf, int size);
extern int usb_string(struct usb_device *dev, int index, extern int usb_string(struct usb_device *dev, int index,
char *buf, size_t size); char *buf, size_t size);
/* wrappers that also update important state inside usbcore */
extern int usb_clear_halt(struct usb_device *dev, int pipe);
extern int usb_set_configuration(struct usb_device *dev, int configuration); extern int usb_set_configuration(struct usb_device *dev, int configuration);
extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate); extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate);
...@@ -1123,9 +1098,10 @@ extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate); ...@@ -1123,9 +1098,10 @@ extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate);
* *
* - max size: bits 0-1 [Historical; now gone.] * - max size: bits 0-1 [Historical; now gone.]
* - direction: bit 7 (0 = Host-to-Device [Out], * - direction: bit 7 (0 = Host-to-Device [Out],
* 1 = Device-to-Host [In]) * 1 = Device-to-Host [In] ...
* - device: bits 8-14 * like endpoint bEndpointAddress)
* - endpoint: bits 15-18 * - device: bits 8-14 ... bit positions known to uhci-hcd
* - endpoint: bits 15-18 ... bit positions known to uhci-hcd
* - Data0/1: bit 19 [Historical; now gone. ] * - Data0/1: bit 19 [Historical; now gone. ]
* - lowspeed: bit 26 [Historical; now gone. ] * - lowspeed: bit 26 [Historical; now gone. ]
* - pipe type: bits 30-31 (00 = isochronous, 01 = interrupt, * - pipe type: bits 30-31 (00 = isochronous, 01 = interrupt,
...@@ -1146,10 +1122,9 @@ extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate); ...@@ -1146,10 +1122,9 @@ extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate);
#define usb_maxpacket(dev, pipe, out) (out \ #define usb_maxpacket(dev, pipe, out) (out \
? (dev)->epmaxpacketout[usb_pipeendpoint(pipe)] \ ? (dev)->epmaxpacketout[usb_pipeendpoint(pipe)] \
: (dev)->epmaxpacketin [usb_pipeendpoint(pipe)] ) : (dev)->epmaxpacketin [usb_pipeendpoint(pipe)] )
#define usb_packetid(pipe) (((pipe) & USB_DIR_IN) ? USB_PID_IN : USB_PID_OUT)
#define usb_pipeout(pipe) ((((pipe) >> 7) & 1) ^ 1) #define usb_pipein(pipe) ((pipe) & USB_DIR_IN)
#define usb_pipein(pipe) (((pipe) >> 7) & 1) #define usb_pipeout(pipe) (!usb_pipein(pipe))
#define usb_pipedevice(pipe) (((pipe) >> 8) & 0x7f) #define usb_pipedevice(pipe) (((pipe) >> 8) & 0x7f)
#define usb_pipeendpoint(pipe) (((pipe) >> 15) & 0xf) #define usb_pipeendpoint(pipe) (((pipe) >> 15) & 0xf)
#define usb_pipetype(pipe) (((pipe) >> 30) & 3) #define usb_pipetype(pipe) (((pipe) >> 30) & 3)
...@@ -1158,19 +1133,16 @@ extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate); ...@@ -1158,19 +1133,16 @@ extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate);
#define usb_pipecontrol(pipe) (usb_pipetype((pipe)) == PIPE_CONTROL) #define usb_pipecontrol(pipe) (usb_pipetype((pipe)) == PIPE_CONTROL)
#define usb_pipebulk(pipe) (usb_pipetype((pipe)) == PIPE_BULK) #define usb_pipebulk(pipe) (usb_pipetype((pipe)) == PIPE_BULK)
#define PIPE_DEVEP_MASK 0x0007ff00 /* The D0/D1 toggle bits ... USE WITH CAUTION (they're almost hcd-internal) */
/* The D0/D1 toggle bits */
#define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> (ep)) & 1) #define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> (ep)) & 1)
#define usb_dotoggle(dev, ep, out) ((dev)->toggle[out] ^= (1 << (ep))) #define usb_dotoggle(dev, ep, out) ((dev)->toggle[out] ^= (1 << (ep)))
#define usb_settoggle(dev, ep, out, bit) ((dev)->toggle[out] = ((dev)->toggle[out] & ~(1 << (ep))) | ((bit) << (ep))) #define usb_settoggle(dev, ep, out, bit) ((dev)->toggle[out] = ((dev)->toggle[out] & ~(1 << (ep))) | ((bit) << (ep)))
/* Endpoint halt control/status */ /* Endpoint halt control/status ... likewise USE WITH CAUTION */
#define usb_endpoint_out(ep_dir) ((((ep_dir) >> 7) & 1) ^ 1)
#define usb_endpoint_halt(dev, ep, out) ((dev)->halted[out] |= (1 << (ep)))
#define usb_endpoint_running(dev, ep, out) ((dev)->halted[out] &= ~(1 << (ep))) #define usb_endpoint_running(dev, ep, out) ((dev)->halted[out] &= ~(1 << (ep)))
#define usb_endpoint_halted(dev, ep, out) ((dev)->halted[out] & (1 << (ep))) #define usb_endpoint_halted(dev, ep, out) ((dev)->halted[out] & (1 << (ep)))
static inline unsigned int __create_pipe(struct usb_device *dev, unsigned int endpoint) static inline unsigned int __create_pipe(struct usb_device *dev, unsigned int endpoint)
{ {
return (dev->devnum << 8) | (endpoint << 15); return (dev->devnum << 8) | (endpoint << 15);
...@@ -1211,47 +1183,6 @@ void usb_show_string(struct usb_device *dev, char *id, int index); ...@@ -1211,47 +1183,6 @@ void usb_show_string(struct usb_device *dev, char *id, int index);
#define warn(format, arg...) printk(KERN_WARNING __FILE__ ": " format "\n" , ## arg) #define warn(format, arg...) printk(KERN_WARNING __FILE__ ": " format "\n" , ## arg)
/* -------------------------------------------------------------------------- */
/*
* driver list
* exported only for usbfs (not visible outside usbcore)
*/
extern struct list_head usb_driver_list;
/*
* USB device fs stuff
*/
#ifdef CONFIG_USB_DEVICEFS
/*
* these are expected to be called from the USB core/hub thread
* with the kernel lock held
*/
extern void usbfs_add_bus(struct usb_bus *bus);
extern void usbfs_remove_bus(struct usb_bus *bus);
extern void usbfs_add_device(struct usb_device *dev);
extern void usbfs_remove_device(struct usb_device *dev);
extern void usbfs_update_special (void);
extern int usbfs_init(void);
extern void usbfs_cleanup(void);
#else /* CONFIG_USB_DEVICEFS */
static inline void usbfs_add_bus(struct usb_bus *bus) {}
static inline void usbfs_remove_bus(struct usb_bus *bus) {}
static inline void usbfs_add_device(struct usb_device *dev) {}
static inline void usbfs_remove_device(struct usb_device *dev) {}
static inline void usbfs_update_special (void) {}
static inline int usbfs_init(void) { return 0; }
static inline void usbfs_cleanup(void) { }
#endif /* CONFIG_USB_DEVICEFS */
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment