usbcore updates
PATCH 1/1 usbcore updates
This basically lets the latest 2.5 ehci-hcd driver compile in a 2.4 kernel by slightly enriching the API exposed by usbcore:
- Some symbols were renamed; in 2.4 transitional APIs, drivers can prefer these #defines to the older symbols:
* URB_SHORT_NOT_OK ... use instead of USB_DISABLE_SPD
* usb_iso_packet_descriptor ... needs "usb_" prefix
- usb_make_path() support (topological/physical/stable ids)
* bus->bus_name (provided during hcd init)
* dev->devpath (save what hub code threw away)
- bandwidth related symbols out of <linux/usb.h>
* they're only provided for hcds
* exported/updated usb_calc_bandwidth()
- some stuff that only hcd drivers will care about
* internal symbols (and urb->*_dma, internal until 2.5)
* remove pci latency bogosity
Note that the 2.5 HCDs won't yet _work_ yet if anyone brings them back to 2.4 (note the FIXMEs in this patch, and there's a bit more). But this a big step towards making it possible to have the same (host controller) drivers running on both kernels, and can help some of other usb device drivers too.
Please merge to Marcelo's tree. I don't know if I'll have the ehci driver update ready before pre6 starts to slush.
- Dave
include/linux/usb.h renamed from include/linux/usb.h-dist +44 -25
@@ -437,6 +437,7 @@* urb->transfer_flags: */ #define USB_DISABLE_SPD 0x0001 +#define URB_SHORT_NOT_OK USB_DISABLE_SPD#define USB_ISO_ASAP 0x0002#define USB_ASYNC_UNLINK 0x0008#define USB_QUEUE_BULK 0x0010
@@ -454,6 +455,8 @@unsigned int status; }; +#define usb_iso_packet_descriptor iso_packet_descriptor +struct urb ;typedef void (*usb_complete_t )(struct urb *);
@@ -468,10 +471,12 @@int status;// returned status unsigned int transfer_flags;// USB_DISABLE_SPD | USB_ISO_ASAP | etc. void *transfer_buffer;// associated data buffer +dma_addr_t transfer_dma;// dma addr for transfer_buffer int transfer_buffer_length;// data buffer length int actual_length;// actual data buffer length int bandwidth;// bandwidth for this transfer request (INT or ISO) unsigned char *setup_packet;// setup packet (control only) +dma_addr_t setup_dma;// dma addr for setup_packet // int start_frame;// start frame (iso/irq only) int number_of_packets;// number of packets in this request (iso)
@@ -723,6 +728,7 @@*/ struct usb_bus {int busnum;/* Bus number (in order of reg) */ +char *bus_name;/* stable id (PCI slot_name etc) */ #ifdef DEVNUM_ROUND_ROBIN int devnum_next;/* Next open device number in round-robin allocation */
@@ -771,7 +777,8 @@#define USB_MAXCHILDREN (16)struct usb_device { -int devnum;/* Device number on USB bus */ +int devnum;/* Address on USB bus */ +char devpath [16 ];/* Use in messages: /port/port/... */ enum {USB_SPEED_UNKNOWN =0 ,/* enumerating */
@@ -846,10 +853,6 @@extern void usb_inc_dev_use (struct usb_device *);#define usb_dec_dev_use usb_free_dev -extern int usb_check_bandwidth (struct usb_device *dev,struct urb *urb); -extern void usb_claim_bandwidth (struct usb_device *dev,struct urb *urb,int bustime,int isoc); -extern void usb_release_bandwidth (struct usb_device *dev,struct urb *urb,int isoc); -extern int usb_control_msg (struct usb_device *dev,unsigned int pipe,__u8 request,__u8 requesttype,__u16 value,__u16 index,void *data,__u16 size,int timeout);extern int usb_root_hub_string (int id,int serial,char *type,__u8 *data,int len);
@@ -860,6 +863,42 @@int usb_get_current_frame_number (struct usb_device *usb_dev); + +/** +* usb_make_path - returns stable device path in the usb tree +* @dev: the device whose path is being constructed +* @buf: where to put the string +* @size: how big is "buf"? +* +* Returns length of the string (> 0) or negative if size was too small. +* +* This identifier is intended to be "stable", reflecting physical paths in +* hardware such as physical bus addresses for host controllers or ports on +* USB hubs. That makes it stay the same until systems are physically +* reconfigured, by re-cabling a tree of USB devices or by moving USB host +* controllers. Adding and removing devices, including virtual root hubs +* in host controller driver modules, does not change these path identifers; +* neither does rebooting or re-enumerating. These are more useful identifiers +* than changeable ("unstable") ones like bus numbers or device addresses. +* (The stability of the id depends on stability of the bus_name associated +* with the bus the device uses; that is normally stable.) +* +* With a partial exception for devices connected to USB 2.0 root hubs, these +* identifiers are also predictable. So long as the device tree isn't changed, +* plugging any USB device into a given hub port always gives it the same path. +* Because of the use of "companion" controllers, devices connected to ports on +* USB 2.0 root hubs (EHCI host controllers) will get one path ID if they are +* high speed, and a different one if they are full or low speed. +*/ +static inline int usb_make_path (struct usb_device *dev,char *buf,size_t size) +{ +int actual; + actual =snprintf (buf, size,"usb-%s-%s" , + dev->bus->bus_name, dev->devpath); +return (actual >= size) ?-1 : actual; +} + +/* * Calling this entity a "pipe" is glorifying it. A USB pipe * is something embarrassingly simple: it basically consists
@@ -986,26 +1025,6 @@__usb_get_extra_descriptor ((ifpoint)->extra,(ifpoint)->extralen,type,(void **)ptr)/* -* Some USB bandwidth allocation constants. - */ -#define BW_HOST_DELAY 1000L/* nanoseconds */ -#define BW_HUB_LS_SETUP 333L/* nanoseconds */ -/* 4 full-speed bit times (est.) */ - -#define FRAME_TIME_BITS 12000L/* frame = 1 millisecond */ -#define FRAME_TIME_MAX_BITS_ALLOC (90L * FRAME_TIME_BITS / 100L) -#define FRAME_TIME_USECS 1000L -#define FRAME_TIME_MAX_USECS_ALLOC (90L * FRAME_TIME_USECS / 100L) - -#define BitTime (bytecount) (7 * 8 * bytecount / 6)/* with integer truncation */ -/* Trying not to use worst-case bit-stuffing -of (7/6 * 8 * bytecount) = 9.33 * bytecount */ -/* bytecount = data payload byte count */ - -#define NS_TO_US (ns) ((ns + 500L) / 1000L) -/* convert & round nanoseconds to microseconds */ - -/* * Debugging helpers.. */void usb_show_device_descriptor (struct usb_device_descriptor *);
drivers/usb/usb.c renamed from drivers/usb-dist/usb.c +42 -26
116 lines not on this page · raw message
drivers/usb/hcd.h renamed from drivers/usb-dist/hcd.h +66 -0
81 lines not on this page · raw message
drivers/usb/hcd.c renamed from drivers/usb-dist/hcd.c +11 -12
@@ -56,7 +56,8 @@* USB Host Controller Driver framework * * Plugs into usbcore (usb_bus) and lets HCDs share code, minimizing -* HCD-specific behaviors/bugs. +* HCD-specific behaviors/bugs. Think of it as the "upper level" of +* some drivers, where the "lower level" is hardware-specific. * * This does error checks, tracks devices and urbs, and delegates to a * "hc_driver" only for code (and data) that really needs to know about
@@ -78,6 +79,9 @@* Roman Weissgaerber, Rory Bolt, ... * * HISTORY: +* 2002-sept Merge some 2.5 updates so we can share hardware level HCD +* code between the 2.4.20+ and 2.5 trees. +* 2002-feb merge to 2.4.19 * 2001-12-12 Initial patch version for Linux 2.5.1 kernel. */
@@ -583,7 +587,6 @@struct hc_driver *driver;unsigned long resource, len;void *base; -u8 latency, limit;struct usb_bus *bus;struct usb_hcd *hcd;int retval, region;
@@ -662,15 +665,6 @@ hcd->pdev = dev;info ("%s @ %s, %s" , hcd->description, dev->slot_name, dev->name); -pci_read_config_byte (dev,PCI_LATENCY_TIMER , &latency); -if (latency) { -pci_read_config_byte (dev,PCI_MAX_LAT , &limit); -if (limit && limit < latency) { -dbg ("PCI latency reduced to max %d" , limit); -pci_write_config_byte (dev,PCI_LATENCY_TIMER , limit); - } - } -#ifndef __sparc__sprintf (buf,"%d" , dev->irq);#else
@@ -701,7 +695,8 @@ goto clean_3; } hcd->bus = bus; - hcd->bus_name = dev->slot_name; + hcd->bus_name = dev->slot_name;/* prefer bus->bus_name */ + bus->bus_name = dev->slot_name; hcd->product_desc = dev->name; bus->hcpriv = (void *) hcd;
@@ -1072,6 +1067,8 @@if (urb->transfer_buffer_length <0 )return -EINVAL ; +// FIXME set urb->transfer_dma and/or setup_dma +if (urb->next) {warn ("use explicit queuing not urb->next" );return -EINVAL ;
@@ -1463,6 +1460,8 @@dbg ("giveback urb %p status %d len %d" , urb, urb->status, urb->actual_length); +// FIXME unmap urb->transfer_dma and/or setup_dma +/* pass ownership to the completion handler */ urb->complete (urb); }
drivers/usb/hub.c renamed from drivers/usb-dist/hub.c +23 -34
83 lines not on this page · raw message
drivers/usb/devices.c renamed from drivers/usb-dist/devices.c +2 -0
@@ -61,6 +61,8 @@#include <linux/usbdevice_fs.h> #include <asm/uaccess.h> +#include "hcd.h" +#define MAX_TOPO_LEVEL 6/* Define ALLOW_SERIAL_NUMBER if you want to see the serial number of devices */
drivers/usb/usb-ohci.c renamed from drivers/usb-dist/usb-ohci.c +2 -15
@@ -78,6 +78,7 @@#include "usb-ohci.h" +#include "hcd.h" #ifdef CONFIG_PMAC_PBOOK #include <asm/machdep.h>
@@ -2411,6 +2412,7 @@kfree (ohci);return NULL ; } + ohci->bus->bus_name = dev->slot_name; ohci->bus->hcpriv = (void *) ohci;return ohci;
@@ -2468,7 +2470,6 @@ void *mem_base, const struct pci_device_id *id) { ohci_t * ohci; -u8 latency, limit;char buf[8 ], *bufp = buf;int ret;
@@ -2508,20 +2509,6 @@if (ohci->flags &OHCI_QUIRK_AMD756 ) printk (KERN_INFO __FILE__ ": AMD756 erratum 4 workaround\n"); -/* bad pci latencies can contribute to overruns */ -pci_read_config_byte (dev,PCI_LATENCY_TIMER , &latency); -if (latency) { -pci_read_config_byte (dev,PCI_MAX_LAT , &limit); -if (limit && limit < latency) { -dbg ("PCI latency reduced to max %d" , limit); -pci_write_config_byte (dev,PCI_LATENCY_TIMER , limit); - ohci->pci_latency = limit; - }else { -/* it might already have been reduced */ - ohci->pci_latency = latency; - } - } -if (hc_reset (ohci) <0 ) {hc_release_ohci (ohci);return -ENODEV ;
drivers/usb/uhci.c renamed from drivers/usb-dist/uhci.c +3 -0
@@ -57,6 +57,8 @@#include <linux/pm.h> +#include "hcd.h" +/* * Version Information */
@@ -2797,6 +2799,7 @@ } uhci->bus = bus; + bus->bus_name = dev->slot_name; bus->hcpriv = uhci;usb_register_bus (uhci->bus);
drivers/usb/usb-uhci.c renamed from drivers/usb-dist/usb-uhci.c +3 -0
@@ -59,6 +59,8 @@#include "usb-uhci.h" #include "usb-uhci-debug.h" +#include "hcd.h" +/* * Version Information */
@@ -2952,6 +2954,7 @@ } s->bus = bus; + bus->bus_name = dev->slot_name; bus->hcpriv = s;/* UHCI specs says devices must have 2 ports, but goes on to say */
drivers/usb/hc_sl811.c renamed from drivers/usb-dist/hc_sl811.c +1 -0
@@ -1162,6 +1162,7 @@ } hci->bus = bus; + bus->bus_name ="sl811" ; bus->hcpriv = (void *) hci;return hci;
Whoops, cc'd to wrong list -- sorry.
- Dave
-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old cell phone? Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel