USB and Driver Core patches for 2.6.10
Subsystems (32)
ChangeSet 1.1938.446.34, 2004/12/17 15:39:21-08:00, [email protected]
[PATCH] USB: gadget kconfig doc updates
This updates the "USB Gadget" Kconfig support:
- Highlighting the the two Documentation/usb files have
information about how to interoperate with MS-Windows using RNDIS or CDC-ACM;
- Flagging CDC ACM and CDC Ethernet support in the config
menu descriptions;
- Providing a bit more description about what a "gadget driver"
does, for the benefit of folk coming to this part of Linux with background in similar proprietary driver stacks.
- Pointing to the Linux-USB website for this API, and the
kerneldoc.
In short: make important driver framework information more accessible.
drivers/usb/gadget/Kconfig | 35 +++++++++++++++++++++++++++++++++-- 1 files changed, 33 insertions(+), 2 deletions(-)
drivers/usb/gadget/Kconfig +33 -2
@@ -39,6 +39,9 @@ If in doubt, say "N" and don't enable these drivers; most people don't have this kind of hardware (except maybe inside Linux PDAs). + For more information, see <http://www.linux-usb.org/gadget> and + the kernel DocBook documentation for this API. + config USB_GADGET_DEBUG_FILES boolean "Debugging information files" depends on USB_GADGET && PROC_FS
@@ -59,6 +62,8 @@ help A USB device uses a controller to talk to its host. Systems should have only one such upstream link. + Many controller drivers are platform-specific; these + often need board-specific hooks. config USB_GADGET_NET2280 boolean "NetChip 2280"
@@ -234,6 +239,21 @@ tristate "USB Gadget Drivers" depends on USB_GADGET default USB_ETH + help + A Linux "Gadget Driver" talks to the USB Peripheral Controller + driver through the abstract "gadget" API. Some other operating + systems call these "client" drivers, of which "class drivers" + are a subset (implementing a USB device class specification). + A gadget driver implements one or more USB functions using + the peripheral hardware. + + Gadget drivers are hardware-neutral, or "platform independent", + except that they sometimes must understand quirks or limitations + of the particular controllers they work with. For example, when + a controller doesn't support alternate configurations or provide + enough of the right types of endpoints, the gadget driver might + not be able work with that controller, or might need to implement + a less common variant of a device class protocol. # this first set of drivers all depend on bulk-capable hardware.
@@ -273,7 +293,7 @@ one serve as the USB host instead (in the "B-Host" role). config USB_ETH - tristate "Ethernet Gadget" + tristate "Ethernet Gadget (with CDC Ethernet support)" depends on NET help This driver implements Ethernet style communication, in either
@@ -314,6 +334,11 @@ If you say "y" here, the Ethernet gadget driver will try to provide a second device configuration, supporting RNDIS to talk to such Microsoft USB hosts. + + To make MS-Windows work with this, use Documentation/usb/linux.inf + as the "driver info file". For versions of MS-Windows older than + XP, you'll need to download drivers from Microsoft's website; a URL + is given in comments found in that info file. config USB_GADGETFS tristate "Gadget Filesystem (EXPERIMENTAL)"
@@ -352,13 +377,19 @@ normal operation. config USB_G_SERIAL - tristate "Serial Gadget" + tristate "Serial Gadget (with CDC ACM support)" help The Serial Gadget talks to the Linux-USB generic serial driver. + This driver supports a CDC-ACM module option, which can be used + to interoperate with MS-Windows hosts or with the Linux-USB + "cdc-acm" driver. Say "y" to link the driver statically, or "m" to build a dynamically linked module called "g_serial". + For more information, see Documentation/usb/gadget_serial.txt + which includes instructions and a "driver info file" needed to + make MS-Windows work with this driver. # put drivers that need isochronous transfer support (for audio
ChangeSet 1.1938.446.35, 2004/12/17 15:39:44-08:00, [email protected]
[PATCH] USB: dummy_hcd: update to match the new endpoint changes
Here's the patch to make dummy_hcd build properly once again. I did some quick light testing to make sure that it still works too. The patch takes the easy way out by allocating a new private data structure for each URB, just to keep a single united list of all the outstanding URBs. More extensive changes would be needed to make effective use of the per-endpoint queues now available, and it's probably not worth the effort.
drivers/usb/gadget/dummy_hcd.c | 60 +++++++++++++++++++++++------------------ 1 files changed, 35 insertions(+), 25 deletions(-)
drivers/usb/gadget/dummy_hcd.c +35 -25
@@ -65,7 +65,7 @@#define DRIVER_DESC "USB Host+Gadget Emulator" -#define DRIVER_VERSION "29 Oct 2004" +#define DRIVER_VERSION "17 Dec 2004"static const char driver_name [] ="dummy_hcd" ;static const char driver_desc [] ="USB Host+Gadget Emulator" ;
@@ -143,6 +143,11 @@#define FIFO_SIZE 64 +struct urbp { +struct urb *urb; +struct list_head urbp_list; +}; +struct dummy {struct usb_hcd hcd;/* must come first! */ spinlock_t lock;
@@ -168,6 +173,7 @@unsigned long re_timeout;struct usb_device *udev; +struct list_head urbp_list; };static inline struct dummy *hcd_to_dummy (struct usb_hcd *hcd)
@@ -830,16 +836,23 @@*/ static int dummy_urb_enqueue ( -struct usb_hcd *hcd, -struct urb *urb, -int mem_flags +struct usb_hcd *hcd, +struct usb_host_endpoint *ep, +struct urb *urb, +int mem_flags ) {struct dummy *dum; +struct urbp *urbp;unsigned long flags;if (!urb->transfer_buffer && urb->transfer_buffer_length)return -EINVAL ; + urbp =kmalloc (sizeof *urbp, mem_flags); +if (!urbp) +return -ENOMEM ; + urbp->urb = urb; + dum =hcd_to_dummy (hcd);spin_lock_irqsave (&dum->lock, flags);
@@ -849,7 +862,8 @@ }else if (unlikely (dum->udev != urb->dev))dev_err (dummy_dev (dum),"usb_device address has changed!\n" ); - urb->hcpriv = dum; +list_add_tail (&urbp->urbp_list, &dum->urbp_list); + urb->hcpriv = urbp;if (usb_pipetype (urb->pipe) ==PIPE_CONTROL ) urb->error_count =1 ;/* mark as a new urb */
@@ -1055,8 +1069,7 @@static void dummy_timer (unsigned long _dum) {struct dummy *dum = (struct dummy *) _dum; -struct hcd_dev *hdev; -struct list_head *entry, *tmp; +struct urbp *urbp, *tmp;unsigned long flags;int limit, total;int i;
@@ -1088,7 +1101,6 @@spin_unlock_irqrestore (&dum->lock, flags);return ; } - hdev = dum->udev->hcpriv;for (i =0 ; i <DUMMY_ENDPOINTS ; i++) {if (!ep_name [i])
@@ -1097,14 +1109,14 @@ } restart: - list_for_each_safe (entry, tmp, &hdev->urb_list) { + list_for_each_entry_safe (urbp, tmp, &dum->urbp_list, urbp_list) {struct urb *urb;struct dummy_request *req;u8 address;struct dummy_ep *ep =0 ;int type; - urb = list_entry (entry, struct urb, urb_list); + urb = urbp->urb;if (urb->status != -EINPROGRESS ) {/* likely it was just unlinked */ goto return_urb;
@@ -1349,7 +1361,9 @@continue ; return_urb: - urb->hcpriv =0 ; + urb->hcpriv =NULL ; +list_del (&urbp->urbp_list); +kfree (urbp);if (ep) ep->already_seen = ep->setup_stage =0 ;
@@ -1361,7 +1375,7 @@ }/* want a 1 msec delay here */ -if (!list_empty (&hdev->urb_list)) +if (!list_empty (&dum->urbp_list))mod_timer (&dum->timer, jiffies +msecs_to_jiffies (1 ));else {usb_put_dev (dum->udev);
@@ -1601,21 +1615,17 @@ {struct usb_hcd *hcd =dev_get_drvdata (dev);struct dummy *dum =hcd_to_dummy (hcd); -struct urb *urb; +struct urbp *urbp;size_t size =0 ;unsigned long flags; -struct hcd_dev *hdev;spin_lock_irqsave (&dum->lock, flags); -if (dum->udev) { - hdev = dum->udev->hcpriv; - list_for_each_entry (urb, &hdev->urb_list, urb_list) { -size_t temp; - - temp =show_urb (buf,PAGE_SIZE - size, urb); - buf += temp; - size += temp; - } + list_for_each_entry (urbp, &dum->urbp_list, urbp_list) { +size_t temp; + + temp =show_urb (buf,PAGE_SIZE - size, urbp->urb); + buf += temp; + size += temp; }spin_unlock_irqrestore (&dum->lock, flags);
@@ -1642,6 +1652,8 @@ dum->timer.function = dummy_timer; dum->timer.data = (unsigned long ) dum; +INIT_LIST_HEAD (&dum->urbp_list); + root =usb_alloc_dev (0 , &hcd->self,0 );if (!root)return -ENOMEM ;
@@ -1754,8 +1766,6 @@ hcd->self.hcpriv = hcd; hcd->self.bus_name = dev->bus_id; hcd->product_desc ="Dummy host controller" ; - -INIT_LIST_HEAD (&hcd->dev_list);usb_register_bus (&hcd->self);
ChangeSet 1.1938.446.36, 2004/12/17 15:40:33-08:00, [email protected]
[PATCH] Re: garmin gps driver patch 0.23
From: Hermann Kneissel <[email protected]>
drivers/usb/serial/Kconfig | 13 drivers/usb/serial/Makefile | 1 drivers/usb/serial/garmin_gps.c | 1542 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1556 insertions(+)
drivers/usb/serial/Kconfig +13 -0
@@ -202,6 +202,19 @@ To compile this driver as a module, choose M here: the module will be called io_ti. +config USB_SERIAL_GARMIN + tristate "Garmin GPS driver" + depends on USB_SERIAL + help + Say Y here if you want to connect to your Garmin GPS. + Should work with most Garmin GPS devices which have a native USB port. + + See <http://sourceforge.net/projects/garmin-gps> for the latest + version of the driver. + + To compile this driver as a module, choose M here: the + module will be called garmin_gps. + config USB_SERIAL_IPW tristate "USB IPWireless (3G UMTS TDD) Driver (EXPERIMENTAL)" depends on USB_SERIAL && EXPERIMENTAL
drivers/usb/serial/Makefile +1 -0
@@ -19,6 +19,7 @@ obj-$(CONFIG_USB_SERIAL_EDGEPORT_TI) += io_ti.o obj-$(CONFIG_USB_SERIAL_EMPEG) += empeg.o obj-$(CONFIG_USB_SERIAL_FTDI_SIO) += ftdi_sio.o +obj-$(CONFIG_USB_SERIAL_GARMIN) += garmin_gps.o obj-$(CONFIG_USB_SERIAL_IPAQ) += ipaq.o obj-$(CONFIG_USB_SERIAL_IPW) += ipw.o obj-$(CONFIG_USB_SERIAL_IR) += ir-usb.o
drivers/usb/serial/garmin_gps.c new file +1542 -0
1,542 lines not on this page · raw message
ChangeSet 1.1938.446.37, 2004/12/17 15:41:32-08:00, [email protected]
[PATCH] USB: fix up some sparse warnings in the new garmin_gps driver
drivers/usb/serial/garmin_gps.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-)
drivers/usb/serial/garmin_gps.c +5 -6
@@ -343,7 +343,7 @@static struct garmin_packet *pkt_pop (struct garmin_data * garmin_data_p) {unsigned long flags; -struct garmin_packet *result =0 ; +struct garmin_packet *result =NULL ;spin_lock_irqsave (&garmin_data_p->lock, flags);if (!list_empty (&garmin_data_p->pktlist)) {
@@ -359,7 +359,7 @@static void pkt_clear (struct garmin_data * garmin_data_p) {unsigned long flags; -struct garmin_packet *result =0 ; +struct garmin_packet *result =NULL ;dbg ("%s" , __FUNCTION__);
@@ -737,10 +737,9 @@*/ static void gsp_next_packet (struct garmin_data * garmin_data_p) { -struct garmin_packet *pkt =0 ; +struct garmin_packet *pkt =NULL ; -while ((pkt =pkt_pop (garmin_data_p)) !=0 ) - { +while ((pkt =pkt_pop (garmin_data_p)) !=0 ) {dbg ("%s - next pkt: %d" , __FUNCTION__, pkt->seq);if (gsp_send (garmin_data_p, pkt->data, pkt->size) >0 ) {kfree (pkt);
@@ -1428,7 +1427,7 @@ {int status =0 ;struct usb_serial_port *port = serial->port[0 ]; -struct garmin_data * garmin_data_p =0 ; +struct garmin_data * garmin_data_p =NULL ;dbg ("%s" , __FUNCTION__);
ChangeSet 1.1938.446.38, 2004/12/17 16:11:38-08:00, [email protected]
[PATCH] Clean mct_u232 in 2.6.10-rc2
I would like to clean up mct_u232 a little bit, although primarily to make my fixes to 2.4 branch look better. The attached patch does this:
- zeroes whole private structure
- zaps dangling pointer (or why do we check it then)
- removes unused code for FIX_WRITE_RETURN_CODE_PROBLEM
- changes version
- makes the diagnostic name not quite as pompous
- makes debugging printouts a little more informative
From: Pete Zaitcev <[email protected]>
drivers/usb/serial/mct_u232.c | 148 +++--------------------------------------- 1 files changed, 12 insertions(+), 136 deletions(-)
drivers/usb/serial/mct_u232.c +12 -136
@@ -82,21 +82,10 @@/* * Version Information */ -#define DRIVER_VERSION "v1.2" +#define DRIVER_VERSION "z2.0"/* Linux in-kernel version */ #define DRIVER_AUTHOR "Wolfgang Grandegger <[email protected]>"#define DRIVER_DESC "Magic Control Technology USB-RS232 converter driver" -/* -* Some not properly written applications do not handle the return code of -* write() correctly. This can result in character losses. A work-a-round -* can be compiled in with the following definition. This work-a-round -* should _NOT_ be part of an 'official' kernel release, of course! -*/ -#undef FIX_WRITE_RETURN_CODE_PROBLEM -#ifdef FIX_WRITE_RETURN_CODE_PROBLEM -static int write_blocking;/* disabled by default */ -#endif -static int debug;/*
@@ -108,12 +97,6 @@ struct file *filp);static void mct_u232_close (struct usb_serial_port *port,struct file *filp); -#ifdef FIX_WRITE_RETURN_CODE_PROBLEM -static int mct_u232_write (struct usb_serial_port *port, -const unsigned char *buf, -int count); -static void mct_u232_write_bulk_callback (struct urb *urb,struct pt_regs *regs); -#endif static void mct_u232_read_int_callback (struct urb *urb,struct pt_regs *regs);static void mct_u232_set_termios (struct usb_serial_port *port,struct termios * old);
@@ -151,7 +134,7 @@static struct usb_serial_device_type mct_u232_device = { .owner =THIS_MODULE , - .name ="Magic Control Technology USB-RS232" , + .name ="MCT U232" , .short_name ="mct_u232" , .id_table = id_table_combined, .num_interrupt_in =2 ,
@@ -160,10 +143,6 @@ .num_ports = 1, .open = mct_u232_open, .close = mct_u232_close, -#ifdef FIX_WRITE_RETURN_CODE_PROBLEM - .write = mct_u232_write, - .write_bulk_callback = mct_u232_write_bulk_callback, -#endif .read_int_callback = mct_u232_read_int_callback, .ioctl = mct_u232_ioctl, .set_termios = mct_u232_set_termios,
@@ -366,15 +345,11 @@struct mct_u232_private *priv;struct usb_serial_port *port, *rport; -/* allocate the private data structure */ priv =kmalloc (sizeof (struct mct_u232_private ),GFP_KERNEL );if (!priv)return -ENOMEM ; -/* set initial values for control structures */ +memset (priv,0 ,sizeof (struct mct_u232_private ));spin_lock_init (&priv->lock); - priv->control_state =0 ; - priv->last_lsr =0 ; - priv->last_msr =0 ;usb_set_serial_port_data (serial->port[0 ], priv);init_waitqueue_head (&serial->port[0 ]->write_wait);
@@ -404,8 +379,10 @@for (i=0 ; i < serial->num_ports; ++i) {/* My special items, the standard routines free my urbs */ priv =usb_get_serial_port_data (serial->port[i]); -if (priv) +if (priv) { +usb_set_serial_port_data (serial->port[i],NULL );kfree (priv); + } } }/* mct_u232_shutdown */
@@ -459,14 +436,16 @@ port->read_urb->dev = port->serial->dev; retval =usb_submit_urb (port->read_urb,GFP_KERNEL );if (retval) { -err ("usb_submit_urb(read bulk) failed" ); +err ("usb_submit_urb(read bulk) failed pipe 0x%x err %d" , + port->read_urb->pipe, retval); goto exit; } port->interrupt_in_urb->dev = port->serial->dev; retval =usb_submit_urb (port->interrupt_in_urb,GFP_KERNEL );if (retval) -err (" usb_submit_urb(read int) failed" ); +err (" usb_submit_urb(read int) failed pipe 0x%x err %d" , + port->interrupt_in_urb->pipe, retval); exit:return 0 ;
@@ -486,101 +465,6 @@ }/* mct_u232_close */ -#ifdef FIX_WRITE_RETURN_CODE_PROBLEM -/* The generic routines work fine otherwise */ - -static int mct_u232_write (struct usb_serial_port *port, -const unsigned char *buf,int count) -{ -struct usb_serial *serial = port->serial; -int result, bytes_sent, size; - -dbg ("%s - port %d" , __FUNCTION__, port->number); - -if (count ==0 ) { -dbg ("%s - write request of 0 bytes" , __FUNCTION__); -return (0 ); - } - -/* only do something if we have a bulk out endpoint */ -if (!serial->num_bulk_out) -return (0 ); - -/* another write is still pending? */ -if (port->write_urb->status == -EINPROGRESS ) { -dbg ("%s - already writing" , __FUNCTION__); -return (0 ); - } - - bytes_sent =0 ; -while (count >0 ) { - size = (count > port->bulk_out_size) ? port->bulk_out_size : count; - -usb_serial_debug_data (debug, &port->dev, __FUNCTION__, size, buf); - -memcpy (port->write_urb->transfer_buffer, buf, size); - -/* set up our urb */ -usb_fill_bulk_urb (port->write_urb, serial->dev, -usb_sndbulkpipe (serial->dev, - port->bulk_out_endpointAddress), - port->write_urb->transfer_buffer, size, - ((serial->type->write_bulk_callback) ? - serial->type->write_bulk_callback : - mct_u232_write_bulk_callback), - port); - -/* send the data out the bulk port */ - result =usb_submit_urb (port->write_urb,GFP_ATOMIC ); -if (result) { -err ("%s - failed submitting write urb, error %d" , __FUNCTION__, result); -return result; - } - - bytes_sent += size; -if (write_blocking) -interruptible_sleep_on (&port->write_wait); -else -break ; - - buf += size; - count -= size; - } - -return bytes_sent; -}/* mct_u232_write */ - -static void mct_u232_write_bulk_callback (struct urb *urb,struct pt_regs *regs) -{ -struct usb_serial_port *port = (struct usb_serial_port *)urb->context; -struct usb_serial *serial = port->serial; -struct tty_struct *tty = port->tty; - -dbg ("%s - port %d" , __FUNCTION__, port->number); - -if (!serial) { -dbg ("%s - bad serial pointer, exiting" , __FUNCTION__); -return ; - } - -if (urb->status) { -dbg ("%s - nonzero write bulk status received: %d" , __FUNCTION__, - urb->status); -return ; - } - -if (write_blocking) { -wake_up_interruptible (&port->write_wait); -tty_wakeup (tty); - }else { -/* from generic_write_bulk_callback */ -schedule_work (&port->work); - } - -return ; -}/* mct_u232_write_bulk_callback */ -#endif -static void mct_u232_read_int_callback (struct urb *urb,struct pt_regs *regs) {struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
@@ -591,8 +475,6 @@int status;unsigned long flags; -dbg ("%s - port %d" , __FUNCTION__, port->number); -switch (urb->status) {case 0 :/* success */
@@ -612,7 +494,8 @@dbg ("%s - bad serial pointer, exiting" , __FUNCTION__);return ; } - + +dbg ("%s - port %d" , __FUNCTION__, port->number);usb_serial_debug_data (debug, &port->dev, __FUNCTION__, urb->actual_length, data);/*
@@ -893,12 +776,5 @@MODULE_DESCRIPTION (DRIVER_DESC );MODULE_LICENSE ("GPL" ); -#ifdef FIX_WRITE_RETURN_CODE_PROBLEM -module_param (write_blocking, int,0 ); -MODULE_PARM_DESC (write_blocking, -"The write function will block to write out all data" ); -#endif -module_param (debug, bool,S_IRUGO |S_IWUSR );MODULE_PARM_DESC (debug,"Debug enabled or not" ); -
ChangeSet 1.1938.446.39, 2004/12/20 10:37:42-08:00, [email protected]
USB: change warning level in ftdi_sio driver of a debug message.
This keeps users happy as it really isn't an error.
drivers/usb/serial/ftdi_sio.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)
drivers/usb/serial/ftdi_sio.c +1 -1
@@ -1651,7 +1651,7 @@dbg ("%s port %d, %d bytes" , __FUNCTION__, port->number, count);if (count ==0 ) { -err ("write request of 0 bytes" ); +dbg ("write request of 0 bytes" );return 0 ; }
ChangeSet 1.1938.446.40, 2004/12/20 14:17:44-08:00, [email protected]
[PATCH] USB: Create usb_hcd structures within usbcore [1/13]
This patch changes the usbcore routines, making them fully responsible for the entire lifecycle of each usb_hcd. It also splits up registration of the USB host class_device into an _init and an _add phase, to match the initialization and registration of the USB bus belonging to the host.
drivers/usb/core/hcd-pci.c | 21 +++------------- drivers/usb/core/hcd.c | 59 ++++++++++++++++++++++++++++++++++++--------- drivers/usb/core/hcd.h | 27 +++++++++----------- 3 files changed, 66 insertions(+), 41 deletions(-)
drivers/usb/core/hcd-pci.c +5 -16
@@ -124,7 +124,7 @@// driver->reset(), later on, will transfer device from // control by SMM/BIOS to control by Linux (if needed) - hcd = driver->hcd_alloc (); + hcd =usb_create_hcd (driver);if (hcd ==NULL ){dev_dbg (&dev->dev,"hcd alloc fail\n" ); retval = -ENOMEM ;
@@ -144,20 +144,16 @@ hcd->region = region;pci_set_drvdata (dev, hcd); - hcd->driver = driver; - hcd->description = driver->description; hcd->self.bus_name =pci_name (dev);#ifdef CONFIG_PCI_NAMES hcd->product_desc = dev->pretty_name; -#else -if (hcd->product_desc ==NULL ) - hcd->product_desc ="USB Host Controller" ;#endif hcd->self.controller = &dev->dev;if ((retval =hcd_buffer_create (hcd)) !=0 ) { clean_3: -kfree (hcd); +pci_set_drvdata (dev,NULL ); +usb_put_hcd (hcd); goto clean_2; }
@@ -168,7 +164,6 @@dev_err (hcd->self.controller,"can't reset\n" ); goto clean_3; } - hcd->state =USB_STATE_HALT ;pci_set_master (dev);#ifndef __sparc__
@@ -177,7 +172,7 @@ bufp =__irq_itoa (dev->irq);#endif retval =request_irq (dev->irq, usb_hcd_irq,SA_SHIRQ , - hcd->description, hcd); + hcd->driver->description, hcd);if (retval !=0 ) {dev_err (hcd->self.controller,"request interrupt %s failed\n" , bufp);
@@ -189,12 +184,6 @@ (driver->flags &HCD_MEMORY ) ?"pci mem" :"io base" , resource); -usb_bus_init (&hcd->self); - hcd->self.op = &usb_hcd_operations; - hcd->self.release = &usb_hcd_release; - hcd->self.hcpriv = (void *) hcd; -init_timer (&hcd->rh_timer); -usb_register_bus (&hcd->self);if ((retval = driver->start (hcd)) <0 ) {
@@ -409,7 +398,7 @@pci_set_power_state (dev,0 ); dev->dev.power.power_state =0 ; retval =request_irq (dev->irq, usb_hcd_irq,SA_SHIRQ , - hcd->description, hcd); + hcd->driver->description, hcd);if (retval <0 ) {dev_err (hcd->self.controller,"can't restore IRQ after resume!\n" );
drivers/usb/core/hcd.c +48 -11
98 lines not on this page · raw message
drivers/usb/core/hcd.h +13 -14
@@ -63,14 +63,13 @@struct usb_bus self;/* hcd is-a bus */ const char *product_desc;/* product/vendor string */ -const char *description;/* "ehci-hcd" etc */ struct timer_list rh_timer;/* drives root hub */ /* * hardware info/state */ -struct hc_driver *driver;/* hw-specific hooks */ +const struct hc_driver *driver;/* hw-specific hooks */ unsigned saw_irq : 1; unsigned can_wakeup:1; /* hw supports wakeup? */ unsigned remote_wakeup:1;/* sw should use wakeup? */
@@ -103,6 +102,12 @@* input size of periodic table to an interrupt scheduler. * (ohci 32, uhci 1024, ehci 256/512/1024). */ + +/* The HC driver's private data is stored at the end of +* this structure. +*/ + unsigned long hcd_priv[0] + __attribute__ ((aligned (sizeof(unsigned long)))); };/* 2.4 does this a bit differently ... */
@@ -152,6 +157,8 @@struct hc_driver {const char *description;/* "ehci-hcd" etc */ +const char *product_desc;/* product/vendor string */ +size_t hcd_priv_size;/* size of private data */ /* irq handler */ irqreturn_t (*irq) (struct usb_hcd *hcd,struct pt_regs *regs);
@@ -180,15 +187,6 @@/* return current frame number */ int (*get_frame_number) (struct usb_hcd *hcd); -/* memory lifecycle */ -/* Note: The absence of hcd_free reflects a temporary situation; -* in the near future hcd_alloc will disappear as well and all -* allocations/deallocations will be handled by usbcore. For the -* moment, drivers are required to return a pointer that the core -* can pass to kfree, i.e., the struct usb_hcd must be the _first_ -* member of a larger driver-specific structure. */ -struct usb_hcd *(*hcd_alloc) (void ); -/* manage i/o requests, device state */ int (*urb_enqueue) (struct usb_hcd *hcd, struct usb_host_endpoint *ep,
@@ -213,6 +211,10 @@extern void usb_hcd_giveback_urb (struct usb_hcd *hcd,struct urb *urb,struct pt_regs *regs);extern void usb_bus_init (struct usb_bus *bus); +extern struct usb_hcd *usb_create_hcd (const struct hc_driver *driver); +extern void usb_put_hcd (struct usb_hcd *hcd); + +#ifdef CONFIG_PCI struct pci_dev ;struct pci_device_id ;
@@ -237,7 +239,6 @@ void *addr, dma_addr_t dma);/* generic bus glue, needed for host controllers that don't use PCI */ -extern struct usb_operations usb_hcd_operations;extern irqreturn_t usb_hcd_irq (int irq,void *__hcd,struct pt_regs *r);extern void usb_hc_died (struct usb_hcd *hcd);
@@ -356,8 +357,6 @@return usb_register_root_hub (usb_dev, hcd->self.controller); } - -extern void usb_hcd_release (struct usb_bus *);extern void usb_set_device_state (struct usb_device *udev,enum usb_device_state new_state);
ChangeSet 1.1938.446.41, 2004/12/20 14:18:23-08:00, [email protected]
[PATCH] USB: Create usb_hcd structures within usbcore [2/13]
This patch alters the EHCI driver, removing the routine that allocates the hcd structure and introducing inline functions to convert safely between the public and private hcd structures.
drivers/usb/host/ehci-dbg.c | 30 +++++++++++++++------------- drivers/usb/host/ehci-hcd.c | 45 ++++++++++++++++++++---------------------- drivers/usb/host/ehci-hub.c | 12 +++++------ drivers/usb/host/ehci-mem.c | 31 +++++----------------------- drivers/usb/host/ehci-q.c | 23 +++++++++++---------- drivers/usb/host/ehci-sched.c | 34 +++++++++++++++---------------- drivers/usb/host/ehci.h | 23 +++++++++++++-------- 7 files changed, 94 insertions(+), 104 deletions(-)
drivers/usb/host/ehci-dbg.c +17 -13
@@ -19,13 +19,13 @@/* this file is part of ehci-hcd.c */ #define ehci_dbg(ehci, fmt, args...) \ - dev_dbg ((ehci)->hcd.self.controller , fmt , ## args ) + dev_dbg (ehci_to_hcd(ehci)->self.controller , fmt , ## args ) #define ehci_err(ehci, fmt, args...) \ - dev_err ((ehci)->hcd.self.controller , fmt , ## args ) + dev_err (ehci_to_hcd(ehci)->self.controller , fmt , ## args ) #define ehci_info(ehci, fmt, args...) \ - dev_info ((ehci)->hcd.self.controller , fmt , ## args ) + dev_info (ehci_to_hcd(ehci)->self.controller , fmt , ## args ) #define ehci_warn(ehci, fmt, args...) \ - dev_warn ((ehci)->hcd.self.controller , fmt , ## args ) + dev_warn (ehci_to_hcd(ehci)->self.controller , fmt , ## args )#ifdef EHCI_VERBOSE_DEBUG # define vdbg dbg
@@ -657,7 +657,7 @@"EHCI %x.%02x, hcd state %d\n" , hcd->self.controller->bus->name, hcd->self.controller->bus_id, - i >> 8, i & 0x0ff, ehci->hcd.state); + i >> 8, i & 0x0ff, hcd->state); size -= temp; next += temp;
@@ -733,18 +733,22 @@ } static CLASS_DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL); -static inline void create_debug_files (struct ehci_hcd *bus) +static inline void create_debug_files (struct ehci_hcd *ehci) { -class_device_create_file (&bus->hcd.self.class_dev, &class_device_attr_async); -class_device_create_file (&bus->hcd.self.class_dev, &class_device_attr_periodic); -class_device_create_file (&bus->hcd.self.class_dev, &class_device_attr_registers); +struct class_device *cldev = &ehci_to_hcd (ehci)->self.class_dev; + +class_device_create_file (cldev, &class_device_attr_async); +class_device_create_file (cldev, &class_device_attr_periodic); +class_device_create_file (cldev, &class_device_attr_registers); } -static inline void remove_debug_files (struct ehci_hcd *bus) +static inline void remove_debug_files (struct ehci_hcd *ehci) { -class_device_remove_file (&bus->hcd.self.class_dev, &class_device_attr_async); -class_device_remove_file (&bus->hcd.self.class_dev, &class_device_attr_periodic); -class_device_remove_file (&bus->hcd.self.class_dev, &class_device_attr_registers); +struct class_device *cldev = &ehci_to_hcd (ehci)->self.class_dev; + +class_device_remove_file (cldev, &class_device_attr_async); +class_device_remove_file (cldev, &class_device_attr_periodic); +class_device_remove_file (cldev, &class_device_attr_registers); }#endif /* STUB_DEBUG_FILES */
drivers/usb/host/ehci-hcd.c +22 -23
159 lines not on this page · raw message
drivers/usb/host/ehci-hub.c +6 -6
@@ -44,7 +44,7 @@/* stop schedules, clean any completed work */ if (HCD_IS_RUNNING (hcd->state)) {ehci_quiesce (ehci); - ehci->hcd.state =USB_STATE_QUIESCING ; + hcd->state =USB_STATE_QUIESCING ; } ehci->command =readl (&ehci->regs->command);if (ehci->reclaim)
@@ -59,7 +59,7 @@if ((t1 &PORT_PE ) && !(t1 &PORT_OWNER )) t2 |=PORT_SUSPEND ; -if (ehci->hcd.remote_wakeup) +if (hcd->remote_wakeup) t2 |=PORT_WKOC_E |PORT_WKDISC_E |PORT_WKCONN_E ;else t2 &= ~(PORT_WKOC_E |PORT_WKDISC_E |PORT_WKCONN_E );
@@ -73,7 +73,7 @@/* turn off now-idle HC */ ehci_halt (ehci); - ehci->hcd.state =HCD_STATE_SUSPENDED ; + hcd->state =HCD_STATE_SUSPENDED ; ehci->next_statechange = jiffies +msecs_to_jiffies (10 );spin_unlock_irq (&ehci->lock);
@@ -145,7 +145,7 @@ } ehci->next_statechange = jiffies +msecs_to_jiffies (5 ); - ehci->hcd.state =USB_STATE_RUNNING ; + hcd->state =USB_STATE_RUNNING ;/* Now we can safely re-enable irqs */ if (intr_enable)
@@ -212,7 +212,7 @@unsigned long flags;/* if !USB_SUSPEND, root hub timers won't get shut down ... */ -if (!HCD_IS_RUNNING (ehci->hcd.state)) +if (!HCD_IS_RUNNING (hcd->state))return 0 ;/* init status to no-changes */
@@ -499,7 +499,7 @@if ((temp &PORT_PE ) ==0 || (temp &PORT_RESET ) !=0 ) goto error; -if (ehci->hcd.remote_wakeup) +if (hcd->remote_wakeup) temp |=PORT_WAKE_BITS ;writel (temp |PORT_SUSPEND , &ehci->regs->port_status [wIndex]);
drivers/usb/host/ehci-mem.c +6 -25
@@ -32,25 +32,6 @@*/ /*-------------------------------------------------------------------------*/ -/* -* Allocator / cleanup for the per device structure -* Called by hcd init / removal code -*/ -static struct usb_hcd *ehci_hcd_alloc (void ) -{ -struct ehci_hcd *ehci; - - ehci = (struct ehci_hcd *) -kmalloc (sizeof (struct ehci_hcd ),GFP_KERNEL ); -if (ehci !=0 ) { -memset (ehci,0 ,sizeof (struct ehci_hcd )); - ehci->hcd.product_desc ="EHCI Host Controller" ; -return &ehci->hcd; - } -return NULL ; -} - -/*-------------------------------------------------------------------------*/ /* Allocate the key transfer structures from the previously allocated pool */
@@ -169,7 +150,7 @@ ehci->sitd_pool =NULL ;if (ehci->periodic) -dma_free_coherent (ehci->hcd.self.controller, +dma_free_coherent (ehci_to_hcd (ehci)->self.controller, ehci->periodic_size *sizeof (u32), ehci->periodic, ehci->periodic_dma); ehci->periodic =NULL ;
@@ -187,7 +168,7 @@/* QTDs for control/bulk/intr transfers */ ehci->qtd_pool =dma_pool_create ("ehci_qtd" , - ehci->hcd.self.controller, +ehci_to_hcd (ehci)->self.controller,sizeof (struct ehci_qtd ),32 /* byte alignment (for hw parts) */ ,4096 /* can't cross 4K */ );
@@ -197,7 +178,7 @@/* QHs for control/bulk/intr transfers */ ehci->qh_pool =dma_pool_create ("ehci_qh" , - ehci->hcd.self.controller, +ehci_to_hcd (ehci)->self.controller,sizeof (struct ehci_qh ),32 /* byte alignment (for hw parts) */ ,4096 /* can't cross 4K */ );
@@ -211,7 +192,7 @@/* ITD for high speed ISO transfers */ ehci->itd_pool =dma_pool_create ("ehci_itd" , - ehci->hcd.self.controller, +ehci_to_hcd (ehci)->self.controller,sizeof (struct ehci_itd ),32 /* byte alignment (for hw parts) */ ,4096 /* can't cross 4K */ );
@@ -221,7 +202,7 @@/* SITD for full/low speed split ISO transfers */ ehci->sitd_pool =dma_pool_create ("ehci_sitd" , - ehci->hcd.self.controller, +ehci_to_hcd (ehci)->self.controller,sizeof (struct ehci_sitd ),32 /* byte alignment (for hw parts) */ ,4096 /* can't cross 4K */ );
@@ -231,7 +212,7 @@/* Hardware periodic table */ ehci->periodic = (__le32 *) -dma_alloc_coherent (ehci->hcd.self.controller, +dma_alloc_coherent (ehci_to_hcd (ehci)->self.controller, ehci->periodic_size *sizeof (__le32), &ehci->periodic_dma,0 );if (ehci->periodic ==0 ) {
drivers/usb/host/ehci-q.c +12 -11
@@ -200,7 +200,7 @@ || QTD_CERR(token) == 0) && (!ehci_is_ARC(ehci) || urb->dev->tt->hub != - ehci->hcd.self.root_hub)) { + ehci_to_hcd(ehci)->self.root_hub)) {#ifdef DEBUG struct usb_device *tt = urb->dev->tt->hub; dev_dbg (&tt->dev,
@@ -225,7 +225,7 @@if ((qh->hw_info2 &__constant_cpu_to_le32 (0x00ff )) !=0 ) {/* ... update hc-wide periodic stats (for usbfs) */ -hcd_to_bus (&ehci->hcd)->bandwidth_int_reqs--; +ehci_to_hcd (ehci)->self.bandwidth_int_reqs--; }qh_put (qh); }
@@ -262,7 +262,7 @@/* complete() can reenter this HCD */ spin_unlock (&ehci->lock); -usb_hcd_giveback_urb (&ehci->hcd, urb, regs); +usb_hcd_giveback_urb (ehci_to_hcd (ehci), urb, regs);spin_lock (&ehci->lock); }
@@ -347,13 +347,13 @@/* stop scanning when we reach qtds the hc is using */ }else if (likely (!stopped - &&HCD_IS_RUNNING (ehci->hcd.state))) { + &&HCD_IS_RUNNING (ehci_to_hcd (ehci)->state))) {break ; }else { stopped =1 ; -if (unlikely (!HCD_IS_RUNNING (ehci->hcd.state))) +if (unlikely (!HCD_IS_RUNNING (ehci_to_hcd (ehci)->state))) urb->status = -ESHUTDOWN ;/* ignore active urbs unless some previous qtd
@@ -717,7 +717,8 @@* root hub tt, leave it zeroed. */ if (!ehci_is_ARC (ehci) - || urb->dev->tt->hub != ehci->hcd.self.root_hub) + || urb->dev->tt->hub != +ehci_to_hcd (ehci)->self.root_hub) info2 |= urb->dev->tt->hub->devnum <<16 ;/* NOTE: if (PIPE_INTERRUPT) { scheduler sets c-mask } */
@@ -778,7 +779,7 @@ (void )handshake (&ehci->regs->status,STS_ASS ,0 ,150 ); cmd |=CMD_ASE |CMD_RUN ;writel (cmd, &ehci->regs->command); - ehci->hcd.state =USB_STATE_RUNNING ; +ehci_to_hcd (ehci)->state =USB_STATE_RUNNING ;/* posted write need not be known to HC yet ... */ } }
@@ -957,7 +958,7 @@qh_completions (ehci, qh, regs);if (!list_empty (&qh->qtd_list) - &&HCD_IS_RUNNING (ehci->hcd.state)) + &&HCD_IS_RUNNING (ehci_to_hcd (ehci)->state))qh_link_async (ehci, qh);else {qh_put (qh);// refcount from async list
@@ -965,7 +966,7 @@/* it's not free to turn the async schedule on/off; leave it * active but idle for a while once it empties. */ -if (HCD_IS_RUNNING (ehci->hcd.state) +if (HCD_IS_RUNNING (ehci_to_hcd (ehci)->state) && ehci->async->qh_next.qh ==0 )timer_action (ehci,TIMER_ASYNC_OFF ); }
@@ -999,7 +1000,7 @@/* stop async schedule right now? */ if (unlikely (qh == ehci->async)) {/* can't get here without STS_ASS set */ -if (ehci->hcd.state !=USB_STATE_HALT ) { +if (ehci_to_hcd (ehci)->state !=USB_STATE_HALT ) {writel (cmd & ~CMD_ASE , &ehci->regs->command);wmb ();// handshake later, if we need to
@@ -1019,7 +1020,7 @@ prev->qh_next = qh->qh_next;wmb (); -if (unlikely (ehci->hcd.state ==USB_STATE_HALT )) { +if (unlikely (ehci_to_hcd (ehci)->state ==USB_STATE_HALT )) {/* if (unlikely (qh->reclaim != 0)) * this will recurse, probably not much */
drivers/usb/host/ehci-sched.c +17 -17
@@ -249,14 +249,14 @@*/ status =handshake (&ehci->regs->status,STS_PSS ,0 ,9 *125 );if (status !=0 ) { - ehci->hcd.state =USB_STATE_HALT ; +ehci_to_hcd (ehci)->state =USB_STATE_HALT ;return status; } cmd =readl (&ehci->regs->command) |CMD_PSE ;writel (cmd, &ehci->regs->command);/* posted write ... PSS happens later */ - ehci->hcd.state =USB_STATE_RUNNING ; +ehci_to_hcd (ehci)->state =USB_STATE_RUNNING ;/* make sure ehci_work scans these */ ehci->next_uframe =readl (&ehci->regs->frame_index)
@@ -274,7 +274,7 @@*/ status =handshake (&ehci->regs->status,STS_PSS ,STS_PSS ,9 *125 );if (status !=0 ) { - ehci->hcd.state =USB_STATE_HALT ; +ehci_to_hcd (ehci)->state =USB_STATE_HALT ;return status; }
@@ -348,7 +348,7 @@qh_get (qh);/* update per-qh bandwidth for usbfs */ -hcd_to_bus (&ehci->hcd)->bandwidth_allocated += qh->period +ehci_to_hcd (ehci)->self.bandwidth_allocated += qh->period ? ((qh->usecs + qh->c_usecs) / qh->period) : (qh->usecs *8 );
@@ -379,7 +379,7 @@periodic_unlink (ehci, i, qh);/* update per-qh bandwidth for usbfs */ -hcd_to_bus (&ehci->hcd)->bandwidth_allocated -= qh->period +ehci_to_hcd (ehci)->self.bandwidth_allocated -= qh->period ? ((qh->usecs + qh->c_usecs) / qh->period) : (qh->usecs *8 );
@@ -618,7 +618,7 @@BUG_ON (qh ==0 );/* ... update usbfs periodic stats */ -hcd_to_bus (&ehci->hcd)->bandwidth_int_reqs++; +ehci_to_hcd (ehci)->self.bandwidth_int_reqs++; done:spin_unlock_irqrestore (&ehci->lock, flags);
@@ -1258,7 +1258,7 @@ next_uframe = stream->next_uframe % mod;if (unlikely (list_empty (&stream->td_list))) { -hcd_to_bus (&ehci->hcd)->bandwidth_allocated +ehci_to_hcd (ehci)->self.bandwidth_allocated += stream->bandwidth; ehci_vdbg (ehci, "schedule devp %s ep%d%s-iso period %d start %d.%d\n",
@@ -1268,7 +1268,7 @@ next_uframe >> 3, next_uframe & 0x7); stream->start = jiffies; } -hcd_to_bus (&ehci->hcd)->bandwidth_isoc_reqs++; +ehci_to_hcd (ehci)->self.bandwidth_isoc_reqs++;/* fill iTDs uframe by uframe */ for (packet =0 , itd =NULL ; packet < urb->number_of_packets; ) {
@@ -1390,10 +1390,10 @@ ehci->periodic_sched--;if (unlikely (!ehci->periodic_sched)) (void )disable_periodic (ehci); -hcd_to_bus (&ehci->hcd)->bandwidth_isoc_reqs--; +ehci_to_hcd (ehci)->self.bandwidth_isoc_reqs--;if (unlikely (list_empty (&stream->td_list))) { -hcd_to_bus (&ehci->hcd)->bandwidth_allocated +ehci_to_hcd (ehci)->self.bandwidth_allocated -= stream->bandwidth; ehci_vdbg (ehci, "deschedule devp %s ep%d%s-iso\n",
@@ -1643,7 +1643,7 @@if (list_empty (&stream->td_list)) {/* usbfs ignores TT bandwidth */ -hcd_to_bus (&ehci->hcd)->bandwidth_allocated +ehci_to_hcd (ehci)->self.bandwidth_allocated += stream->bandwidth; ehci_vdbg (ehci, "sched dev%s ep%d%s-iso [%d] %dms/%04x\n",
@@ -1653,7 +1653,7 @@ stream->interval, le32_to_cpu (stream->splits)); stream->start = jiffies; } -hcd_to_bus (&ehci->hcd)->bandwidth_isoc_reqs++; +ehci_to_hcd (ehci)->self.bandwidth_isoc_reqs++;/* fill sITDs frame by frame */ for (packet = 0, sitd = NULL;
@@ -1753,10 +1753,10 @@ ehci->periodic_sched--;if (!ehci->periodic_sched) (void )disable_periodic (ehci); -hcd_to_bus (&ehci->hcd)->bandwidth_isoc_reqs--; +ehci_to_hcd (ehci)->self.bandwidth_isoc_reqs--;if (list_empty (&stream->td_list)) { -hcd_to_bus (&ehci->hcd)->bandwidth_allocated +ehci_to_hcd (ehci)->self.bandwidth_allocated -= stream->bandwidth; ehci_vdbg (ehci, "deschedule devp %s ep%d%s-iso\n",
@@ -1860,7 +1860,7 @@* Touches as few pages as possible: cache-friendly. */ now_uframe = ehci->next_uframe; -if (HCD_IS_RUNNING (ehci->hcd.state)) +if (HCD_IS_RUNNING (ehci_to_hcd (ehci)->state)) clock =readl (&ehci->regs->frame_index);else clock = now_uframe + mod -1 ;
@@ -1894,7 +1894,7 @@union ehci_shadow temp;int live; - live =HCD_IS_RUNNING (ehci->hcd.state); + live =HCD_IS_RUNNING (ehci_to_hcd (ehci)->state);switch (type) {case Q_TYPE_QH :/* handle any completions */
@@ -1983,7 +1983,7 @@if (now_uframe == clock) {unsigned now; -if (!HCD_IS_RUNNING (ehci->hcd.state)) +if (!HCD_IS_RUNNING (ehci_to_hcd (ehci)->state))break ; ehci->next_uframe = now_uframe; now =readl (&ehci->regs->frame_index) % mod;
drivers/usb/host/ehci.h +14 -9
@@ -47,13 +47,6 @@#define EHCI_MAX_ROOT_PORTS 15/* see HCS_N_PORTS */ struct ehci_hcd {/* one per controller */ - -/* glue to PCI and HCD framework */ -struct usb_hcd hcd;/* must come first! */ -struct ehci_caps __iomem *caps; -struct ehci_regs __iomem *regs; -__u32 hcs_params;/* cached register copy */ -spinlock_t lock;/* async schedule support */
@@ -91,6 +84,11 @@ unsigned is_arc_rh_tt:1; /* ARC roothub with TT */ +/* glue to PCI and HCD framework */ +struct ehci_caps __iomem *caps; +struct ehci_regs __iomem *regs; +__u32 hcs_params;/* cached register copy */ +/* irq statistics */ #ifdef EHCI_STATS struct ehci_stats stats;
@@ -100,8 +98,15 @@#endif }; -/* unwrap an HCD pointer to get an EHCI_HCD pointer */ -#define hcd_to_ehci (hcd_ptr) container_of(hcd_ptr, struct ehci_hcd, hcd) +/* convert between an HCD pointer and the corresponding EHCI_HCD */ +static inline struct ehci_hcd *hcd_to_ehci (struct usb_hcd *hcd) +{ +return (struct ehci_hcd *) (hcd->hcd_priv); +} +static inline struct usb_hcd *ehci_to_hcd (struct ehci_hcd *ehci) +{ + return container_of ((void *) ehci, struct usb_hcd, hcd_priv); +}enum ehci_timer_action {
ChangeSet 1.1938.446.42, 2004/12/20 14:19:05-08:00, [email protected]
[PATCH] USB: Create usb_hcd structures within usbcore [3/13]
This patch alters the OHCI driver, removing the routine that allocates the hcd structure and introducing inline functions to convert safely between the public and private hcd structures. It also moves the code to initialize the private structure into the reset routine, since the allocation routine is now gone. That particular aspect should be reviewed by David, but for now it seems to work.
drivers/usb/host/ohci-dbg.c | 22 +++++++++++++--------- drivers/usb/host/ohci-hcd.c | 34 +++++++++++++++++----------------- drivers/usb/host/ohci-hub.c | 27 +++++++++++++-------------- drivers/usb/host/ohci-mem.c | 25 +++++++++---------------- drivers/usb/host/ohci-pci.c | 8 +++----- drivers/usb/host/ohci-q.c | 32 ++++++++++++++++---------------- drivers/usb/host/ohci.h | 25 ++++++++++++++----------- 7 files changed, 85 insertions(+), 88 deletions(-)
drivers/usb/host/ohci-dbg.c +13 -9
@@ -676,19 +676,23 @@ static CLASS_DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL); -static inline void create_debug_files (struct ohci_hcd *bus) +static inline void create_debug_files (struct ohci_hcd *ohci) { -class_device_create_file (&bus->hcd.self.class_dev, &class_device_attr_async); -class_device_create_file (&bus->hcd.self.class_dev, &class_device_attr_periodic); -class_device_create_file (&bus->hcd.self.class_dev, &class_device_attr_registers); -ohci_dbg (bus,"created debug files\n" ); +struct class_device *cldev = &ohci_to_hcd (ohci)->self.class_dev; + +class_device_create_file (cldev, &class_device_attr_async); +class_device_create_file (cldev, &class_device_attr_periodic); +class_device_create_file (cldev, &class_device_attr_registers); +ohci_dbg (ohci,"created debug files\n" ); } -static inline void remove_debug_files (struct ohci_hcd *bus) +static inline void remove_debug_files (struct ohci_hcd *ohci) { -class_device_remove_file (&bus->hcd.self.class_dev, &class_device_attr_async); -class_device_remove_file (&bus->hcd.self.class_dev, &class_device_attr_periodic); -class_device_remove_file (&bus->hcd.self.class_dev, &class_device_attr_registers); +struct class_device *cldev = &ohci_to_hcd (ohci)->self.class_dev; + +class_device_remove_file (cldev, &class_device_attr_async); +class_device_remove_file (cldev, &class_device_attr_periodic); +class_device_remove_file (cldev, &class_device_attr_registers); }#endif
drivers/usb/host/ohci-hcd.c +17 -17
@@ -240,7 +240,7 @@spin_lock_irqsave (&ohci->lock, flags);/* don't submit to a dead HC */ -if (!HCD_IS_RUNNING (ohci->hcd.state)) { +if (!HCD_IS_RUNNING (hcd->state)) { retval = -ENODEV ; goto fail; }
@@ -308,7 +308,7 @@#endif spin_lock_irqsave (&ohci->lock, flags); -if (HCD_IS_RUNNING (ohci->hcd.state)) { +if (HCD_IS_RUNNING (hcd->state)) {urb_priv_t *urb_priv;/* Unless an IRQ completed the unlink while it was being
@@ -355,7 +355,7 @@ rescan:spin_lock_irqsave (&ohci->lock, flags); -if (!HCD_IS_RUNNING (ohci->hcd.state)) { +if (!HCD_IS_RUNNING (hcd->state)) { sanitize: ed->state =ED_IDLE ;finish_unlinks (ohci,0 ,NULL );
@@ -420,7 +420,7 @@int ret;disable (ohci); - ohci->regs = ohci->hcd.regs; + ohci->regs =ohci_to_hcd (ohci)->regs; ohci->next_statechange = jiffies;#ifndef IR_DISABLE
@@ -456,13 +456,13 @@if (ohci->hcca)return 0 ; - ohci->hcca =dma_alloc_coherent (ohci->hcd.self.controller, + ohci->hcca =dma_alloc_coherent (ohci_to_hcd (ohci)->self.controller,sizeof *ohci->hcca, &ohci->hcca_dma,0 );if (!ohci->hcca)return -ENOMEM ;if ((ret =ohci_mem_init (ohci)) <0 ) -ohci_stop (&ohci->hcd); +ohci_stop (ohci_to_hcd (ohci));return ret;
@@ -507,7 +507,7 @@if (ohci->hc_control &OHCI_CTRL_RWC && !(ohci->flags &OHCI_QUIRK_AMD756 )) - ohci->hcd.can_wakeup =1 ; +ohci_to_hcd (ohci)->can_wakeup =1 ;switch (ohci->hc_control &OHCI_CTRL_HCFS ) {case OHCI_USB_OPER :
@@ -605,7 +605,7 @@ ohci->hc_control &=OHCI_CTRL_RWC ; ohci->hc_control |=OHCI_CONTROL_INIT |OHCI_USB_OPER ;ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); - ohci->hcd.state =USB_STATE_RUNNING ; +ohci_to_hcd (ohci)->state =USB_STATE_RUNNING ;/* wake on ConnectStatusChange, matching external hubs */ ohci_writel (ohci,RH_HS_DRWE , &ohci->regs->roothub.status);
@@ -645,12 +645,12 @@// POTPGT delay is bits 24-31, in 2 ms units. mdelay ((roothub_a (ohci) >>23 ) &0x1fe ); - bus =hcd_to_bus (&ohci->hcd); - ohci->hcd.state =USB_STATE_RUNNING ; + bus = &ohci_to_hcd (ohci)->self; +ohci_to_hcd (ohci)->state =USB_STATE_RUNNING ;ohci_dump (ohci,1 ); - udev =hcd_to_bus (&ohci->hcd)->root_hub; + udev = bus->root_hub;if (udev) {return 0 ; }
@@ -665,7 +665,7 @@ } udev->speed =USB_SPEED_FULL ; -if (hcd_register_root (udev, &ohci->hcd) !=0 ) { +if (hcd_register_root (udev,ohci_to_hcd (ohci)) !=0 ) {usb_put_dev (udev);disable (ohci); ohci->hc_control &= ~OHCI_CTRL_HCFS ;
@@ -740,11 +740,11 @@if (ohci->ed_rm_list)finish_unlinks (ohci,ohci_frame_no (ohci), ptregs);if ((ints &OHCI_INTR_SF ) !=0 && !ohci->ed_rm_list - &&HCD_IS_RUNNING (ohci->hcd.state)) + &&HCD_IS_RUNNING (hcd->state))ohci_writel (ohci,OHCI_INTR_SF , ®s->intrdisable);spin_unlock (&ohci->lock); -if (HCD_IS_RUNNING (ohci->hcd.state)) { +if (HCD_IS_RUNNING (hcd->state)) {ohci_writel (ohci, ints, ®s->intrstatus);ohci_writel (ohci,OHCI_INTR_MIE , ®s->intrenable);// flush those writes
@@ -762,7 +762,7 @@ohci_dbg (ohci,"stop %s controller (state 0x%02x)\n" ,hcfs2string (ohci->hc_control &OHCI_CTRL_HCFS ), - ohci->hcd.state); + hcd->state);ohci_dump (ohci,1 );flush_scheduled_work ();
@@ -773,7 +773,7 @@remove_debug_files (ohci);ohci_mem_cleanup (ohci);if (ohci->hcca) { -dma_free_coherent (ohci->hcd.self.controller, +dma_free_coherent (hcd->self.controller,sizeof *ohci->hcca, ohci->hcca, ohci->hcca_dma); ohci->hcca =NULL ;
@@ -792,7 +792,7 @@int temp;int i;struct urb_priv *priv; -struct usb_device *root = ohci->hcd.self.root_hub; +struct usb_device *root =ohci_to_hcd (ohci)->self.root_hub;/* mark any devices gone, so they do nothing till khubd disconnects. * recycle any "live" eds/tds (and urbs) right away.
drivers/usb/host/ohci-hub.c +13 -14
@@ -73,7 +73,7 @@ohci_dbg (ohci,"suspend root hub\n" );/* First stop any processing */ - ohci->hcd.state =USB_STATE_QUIESCING ; + hcd->state =USB_STATE_QUIESCING ;if (ohci->hc_control &OHCI_SCHED_ENABLES ) {int limit;
@@ -103,7 +103,7 @@ &ohci->regs->intrstatus);/* maybe resume can wake root hub */ -if (ohci->hcd.remote_wakeup) +if (hcd->remote_wakeup) ohci->hc_control |=OHCI_CTRL_RWE ;else ohci->hc_control &= ~OHCI_CTRL_RWE ;
@@ -119,7 +119,7 @@ done:if (status ==0 ) - ohci->hcd.state =HCD_STATE_SUSPENDED ; + hcd->state =HCD_STATE_SUSPENDED ;spin_unlock_irqrestore (&ohci->lock, flags);return status; }
@@ -198,7 +198,7 @@ }/* Some controllers (lucent) need extra-long delays */ - ohci->hcd.state =USB_STATE_RESUMING ; + hcd->state =USB_STATE_RESUMING ;mdelay (20 /* usb 11.5.1.10 */ +15 ); temp =ohci_readl (ohci, &ohci->regs->control);
@@ -231,7 +231,7 @@msleep (3 ); temp =OHCI_CONTROL_INIT |OHCI_USB_OPER ; -if (ohci->hcd.can_wakeup) +if (hcd->can_wakeup) temp |=OHCI_CTRL_RWC ; ohci->hc_control = temp;ohci_writel (ohci, temp, &ohci->regs->control);
@@ -261,8 +261,7 @@ temp |=OHCI_BLF ; } } -if (hcd_to_bus (&ohci->hcd)->bandwidth_isoc_reqs - ||hcd_to_bus (&ohci->hcd)->bandwidth_int_reqs) +if (hcd->self.bandwidth_isoc_reqs || hcd->self.bandwidth_int_reqs) enables |=OHCI_CTRL_PLE |OHCI_CTRL_IE ;if (enables) {ohci_dbg (ohci,"restarting schedules ... %08x\n" , enables);
@@ -273,7 +272,7 @@ (void )ohci_readl (ohci, &ohci->regs->control); } - ohci->hcd.state =USB_STATE_RUNNING ; + hcd->state =USB_STATE_RUNNING ;return 0 ; }
@@ -314,7 +313,7 @@* letting khubd or root hub timer see state changes. */ if ((ohci->hc_control &OHCI_CTRL_HCFS ) !=OHCI_USB_OPER - || !HCD_IS_RUNNING (ohci->hcd.state)) { + || !HCD_IS_RUNNING (hcd->state)) { can_suspend =0 ; goto done; }
@@ -356,7 +355,7 @@*/ if (!(status &RH_PS_CCS ))continue ; -if ((status &RH_PS_PSS ) && ohci->hcd.remote_wakeup) +if ((status &RH_PS_PSS ) && hcd->remote_wakeup)continue ; can_suspend =0 ; }
@@ -378,8 +377,8 @@ && usb_trylock_device (hcd->self.root_hub) ) {ohci_vdbg (ohci,"autosuspend\n" ); - (void )ohci_hub_suspend (&ohci->hcd); - ohci->hcd.state =USB_STATE_RUNNING ; + (void )ohci_hub_suspend (hcd); + hcd->state =USB_STATE_RUNNING ;usb_unlock_device (hcd->self.root_hub); }#endif
@@ -613,8 +612,8 @@switch (wValue) {case USB_PORT_FEAT_SUSPEND :#ifdef CONFIG_USB_OTG -if (ohci->hcd.self.otg_port == (wIndex +1 ) - && ohci->hcd.self.b_hnp_enable) +if (hcd->self.otg_port == (wIndex +1 ) + && hcd->self.b_hnp_enable)start_hnp (ohci); else#endif
drivers/usb/host/ohci-mem.c +9 -16
@@ -23,34 +23,27 @@/*-------------------------------------------------------------------------*/ -static struct usb_hcd *ohci_hcd_alloc (void ) +static void ohci_hcd_init (struct ohci_hcd *ohci) { -struct ohci_hcd *ohci; - - ohci = (struct ohci_hcd *)kmalloc (sizeof *ohci,GFP_KERNEL ); -if (ohci !=0 ) { -memset (ohci,0 ,sizeof (struct ohci_hcd )); - ohci->hcd.product_desc ="OHCI Host Controller" ; - ohci->next_statechange = jiffies; -spin_lock_init (&ohci->lock); -INIT_LIST_HEAD (&ohci->pending); -INIT_WORK (&ohci->rh_resume, ohci_rh_resume, &ohci->hcd); -return &ohci->hcd; - } -return NULL ; + ohci->next_statechange = jiffies; +spin_lock_init (&ohci->lock); +INIT_LIST_HEAD (&ohci->pending); +INIT_WORK (&ohci->rh_resume, ohci_rh_resume,ohci_to_hcd (ohci)); }/*-------------------------------------------------------------------------*/ static int ohci_mem_init (struct ohci_hcd *ohci) { - ohci->td_cache =dma_pool_create ("ohci_td" , ohci->hcd.self.controller, + ohci->td_cache =dma_pool_create ("ohci_td" , +ohci_to_hcd (ohci)->self.controller,sizeof (struct td ),32 /* byte alignment */ ,0 /* no page-crossing issues */ );if (!ohci->td_cache)return -ENOMEM ; - ohci->ed_cache =dma_pool_create ("ohci_ed" , ohci->hcd.self.controller, + ohci->ed_cache =dma_pool_create ("ohci_ed" , +ohci_to_hcd (ohci)->self.controller,sizeof (struct ed ),16 /* byte alignment */ ,0 /* no page-crossing issues */ );
drivers/usb/host/ohci-pci.c +3 -5
@@ -35,6 +35,7 @@ {struct ohci_hcd *ohci =hcd_to_ohci (hcd); +ohci_hcd_init (ohci);return ohci_init (ohci); }
@@ -172,6 +173,8 @@static const struct hc_driver ohci_pci_hc_driver = { .description = hcd_name, + .product_desc ="OHCI Host Controller" , + .hcd_priv_size =sizeof (struct ohci_hcd ),/* * generic hardware linkage
@@ -189,11 +192,6 @@ .resume = ohci_pci_resume, #endif .stop = ohci_stop, - -/* -* memory lifecycle (except per-request) -*/ - .hcd_alloc = ohci_hcd_alloc,/* * managing i/o requests and associated device resources
drivers/usb/host/ohci-q.c +16 -16
@@ -60,10 +60,10 @@switch (usb_pipetype (urb->pipe)) {case PIPE_ISOCHRONOUS : -hcd_to_bus (&ohci->hcd)->bandwidth_isoc_reqs--; +ohci_to_hcd (ohci)->self.bandwidth_isoc_reqs--;break ;case PIPE_INTERRUPT : -hcd_to_bus (&ohci->hcd)->bandwidth_int_reqs--; +ohci_to_hcd (ohci)->self.bandwidth_int_reqs--;break ; }
@@ -73,12 +73,12 @@/* urb->complete() can reenter this HCD */ spin_unlock (&ohci->lock); -usb_hcd_giveback_urb (&ohci->hcd, urb, regs); +usb_hcd_giveback_urb (ohci_to_hcd (ohci), urb, regs);spin_lock (&ohci->lock);/* stop periodic dma if it's not needed */ -if (hcd_to_bus (&ohci->hcd)->bandwidth_isoc_reqs ==0 - &&hcd_to_bus (&ohci->hcd)->bandwidth_int_reqs ==0 ) { +if (ohci_to_hcd (ohci)->self.bandwidth_isoc_reqs ==0 + &&ohci_to_hcd (ohci)->self.bandwidth_int_reqs ==0 ) { ohci->hc_control &= ~(OHCI_CTRL_PLE |OHCI_CTRL_IE );ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); }
@@ -163,7 +163,7 @@ } ohci->load [i] += ed->load; } -hcd_to_bus (&ohci->hcd)->bandwidth_allocated += ed->load / ed->interval; +ohci_to_hcd (ohci)->self.bandwidth_allocated += ed->load / ed->interval; }/* link an ed into one of the HC chains */
@@ -172,7 +172,7 @@ {int branch; -if (ohci->hcd.state ==USB_STATE_QUIESCING ) +if (ohci_to_hcd (ohci)->state ==USB_STATE_QUIESCING )return -EAGAIN ; ed->state =ED_OPER ;
@@ -276,7 +276,7 @@ } ohci->load [i] -= ed->load; } -hcd_to_bus (&ohci->hcd)->bandwidth_allocated -= ed->load / ed->interval; +ohci_to_hcd (ohci)->self.bandwidth_allocated -= ed->load / ed->interval; ohci_vdbg (ohci, "unlink %sed %p branch %d [%dus.], interval %d\n", (ed->hwINFO & cpu_to_hc32 (ohci, ED_ISO)) ? "iso " : "",
@@ -619,8 +619,8 @@*/ case PIPE_INTERRUPT :/* ... and periodic urbs have extra accounting */ - periodic =hcd_to_bus (&ohci->hcd)->bandwidth_int_reqs++ ==0 - &&hcd_to_bus (&ohci->hcd)->bandwidth_isoc_reqs ==0 ; + periodic =ohci_to_hcd (ohci)->self.bandwidth_int_reqs++ ==0 + &&ohci_to_hcd (ohci)->self.bandwidth_isoc_reqs ==0 ;/* FALLTHROUGH */ case PIPE_BULK : info = is_out
@@ -688,8 +688,8 @@ data + urb->iso_frame_desc [cnt].offset, urb->iso_frame_desc [cnt].length, urb, cnt); } - periodic =hcd_to_bus (&ohci->hcd)->bandwidth_isoc_reqs++ ==0 - &&hcd_to_bus (&ohci->hcd)->bandwidth_int_reqs ==0 ; + periodic =ohci_to_hcd (ohci)->self.bandwidth_isoc_reqs++ ==0 + &&ohci_to_hcd (ohci)->self.bandwidth_int_reqs ==0 ;break ; }
@@ -920,7 +920,7 @@/* only take off EDs that the HC isn't using, accounting for * frame counter wraps and EDs with partially retired TDs */ -if (likely (regs &&HCD_IS_RUNNING (ohci->hcd.state))) { +if (likely (regs &&HCD_IS_RUNNING (ohci_to_hcd (ohci)->state))) {if (tick_before (tick, ed->tick)) { skip_ed: last = &ed->ed_next;
@@ -1002,7 +1002,7 @@/* but if there's work queued, reschedule */ if (!list_empty (&ed->td_list)) { -if (HCD_IS_RUNNING (ohci->hcd.state)) +if (HCD_IS_RUNNING (ohci_to_hcd (ohci)->state))ed_schedule (ohci, ed); }
@@ -1011,8 +1011,8 @@ }/* maybe reenable control and bulk lists */ -if (HCD_IS_RUNNING (ohci->hcd.state) - && ohci->hcd.state !=USB_STATE_QUIESCING +if (HCD_IS_RUNNING (ohci_to_hcd (ohci)->state) + &&ohci_to_hcd (ohci)->state !=USB_STATE_QUIESCING && !ohci->ed_rm_list) {u32 command =0 , control =0 ;
drivers/usb/host/ohci.h +14 -11
@@ -345,11 +345,6 @@*/ struct ohci_hcd { -/* -* framework state -*/ -struct usb_hcd hcd;/* must come first! */ -spinlock_t lock;/*
@@ -405,7 +400,15 @@ }; -#define hcd_to_ohci (hcd_ptr) container_of(hcd_ptr, struct ohci_hcd, hcd) +/* convert between an hcd pointer and the corresponding ohci_hcd */ +static inline struct ohci_hcd *hcd_to_ohci (struct usb_hcd *hcd) +{ +return (struct ohci_hcd *) (hcd->hcd_priv); +} +static inline struct usb_hcd *ohci_to_hcd (const struct ohci_hcd *ohci) +{ + return container_of ((void *) ohci, struct usb_hcd, hcd_priv); +}/*-------------------------------------------------------------------------*/
@@ -414,13 +417,13 @@#endif /* DEBUG */ #define ohci_dbg(ohci, fmt, args...) \ - dev_dbg ((ohci)->hcd.self.controller , fmt , ## args ) + dev_dbg (ohci_to_hcd(ohci)->self.controller , fmt , ## args ) #define ohci_err(ohci, fmt, args...) \ - dev_err ((ohci)->hcd.self.controller , fmt , ## args ) + dev_err (ohci_to_hcd(ohci)->self.controller , fmt , ## args ) #define ohci_info(ohci, fmt, args...) \ - dev_info ((ohci)->hcd.self.controller , fmt , ## args ) + dev_info (ohci_to_hcd(ohci)->self.controller , fmt , ## args ) #define ohci_warn(ohci, fmt, args...) \ - dev_warn ((ohci)->hcd.self.controller , fmt , ## args ) + dev_warn (ohci_to_hcd(ohci)->self.controller , fmt , ## args )#ifdef OHCI_VERBOSE_DEBUG # define ohci_vdbg ohci_dbg
@@ -553,7 +556,7 @@static inline void disable (struct ohci_hcd *ohci) { - ohci->hcd.state =USB_STATE_HALT ; +ohci_to_hcd (ohci)->state =USB_STATE_HALT ; }#define FI 0x2edf/* 12000 bits per frame (-1) */
ChangeSet 1.1938.446.43, 2004/12/20 14:19:38-08:00, [email protected]
[PATCH] USB: Create usb_hcd structures within usbcore [4/13]
This patch alters the UHCI driver, removing the routine that allocates the hcd structure and introducing inline functions to convert safely between the public and private hcd structures.
drivers/usb/host/uhci-hcd.c | 23 +++++------------------ drivers/usb/host/uhci-hcd.h | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 22 deletions(-)
drivers/usb/host/uhci-hcd.c +5 -18
@@ -1891,7 +1891,7 @@ uhci->state_end = jiffies +HZ ;outw (USBCMD_RS |USBCMD_CF |USBCMD_MAXP , io_addr +USBCMD ); - uhci->hcd.state =USB_STATE_RUNNING ; +uhci_to_hcd (uhci)->state =USB_STATE_RUNNING ;return 0 ; }
@@ -2151,7 +2151,7 @@ udev->speed =USB_SPEED_FULL ; -if (hcd_register_root (udev, &uhci->hcd) !=0 ) { +if (hcd_register_root (udev, hcd) !=0 ) {dev_err (uhci_dev (uhci),"unable to start root hub\n" ); retval = -ENOMEM ; goto err_start_root_hub;
@@ -2277,24 +2277,11 @@if ((rc =start_hc (uhci)) !=0 ) return rc; } - uhci->hcd.state =USB_STATE_RUNNING ; + hcd->state =USB_STATE_RUNNING ;return 0 ; }#endif -static struct usb_hcd *uhci_hcd_alloc (void ) -{ -struct uhci_hcd *uhci; - - uhci = (struct uhci_hcd *)kmalloc (sizeof (*uhci),GFP_KERNEL ); -if (!uhci) -return NULL ; - -memset (uhci,0 ,sizeof (*uhci)); - uhci->hcd.product_desc ="UHCI Host Controller" ; -return &uhci->hcd; -} -/* Wait until all the URBs for a particular device/endpoint are gone */ static void uhci_hcd_endpoint_disable (struct usb_hcd *hcd,struct usb_host_endpoint *ep)
@@ -2313,6 +2300,8 @@static const struct hc_driver uhci_driver = { .description = hcd_name, + .product_desc ="UHCI Host Controller" , + .hcd_priv_size =sizeof (struct uhci_hcd ),/* Generic hardware linkage */ .irq = uhci_irq,
@@ -2326,8 +2315,6 @@ .resume = uhci_resume, #endif .stop = uhci_stop, - - .hcd_alloc = uhci_hcd_alloc, .urb_enqueue = uhci_urb_enqueue, .urb_dequeue = uhci_urb_dequeue,
drivers/usb/host/uhci-hcd.h +12 -4
@@ -314,9 +314,6 @@ UHCI_RESUMING_2 }; -#define hcd_to_uhci (hcd_ptr) container_of(hcd_ptr, struct uhci_hcd, hcd) -#define uhci_dev (u) ((u)->hcd.self.controller) -/* * This describes the full uhci information. *
@@ -324,7 +321,6 @@* a subset of what the full implementation needs. */ struct uhci_hcd { -struct usb_hcd hcd;/* must come first! */ #ifdef CONFIG_PROC_FS /* procfs */
@@ -382,6 +378,18 @@wait_queue_head_t waitqh;/* endpoint_disable waiters */ }; + +/* Convert between a usb_hcd pointer and the corresponding uhci_hcd */ +static inline struct uhci_hcd *hcd_to_uhci (struct usb_hcd *hcd) +{ +return (struct uhci_hcd *) (hcd->hcd_priv); +} +static inline struct usb_hcd *uhci_to_hcd (struct uhci_hcd *uhci) +{ + return container_of((void *) uhci, struct usb_hcd, hcd_priv); +} + +#define uhci_dev (u) (uhci_to_hcd(u)->self.controller)struct urb_priv {struct list_head urb_list;
ChangeSet 1.1938.446.44, 2004/12/20 14:20:07-08:00, [email protected]
[PATCH] USB: Create usb_hcd structures within usbcore [5/13]
This patch alters the non-PCI OHCI drivers, removing the routines that allocate the hcd structures and introducing inline functions to convert safely between the public and private hcd structures.
drivers/usb/host/ohci-lh7a404.c | 43 +++----- drivers/usb/host/ohci-omap.c | 60 +++++------- drivers/usb/host/ohci-pxa27x.c | 41 +++----- drivers/usb/host/ohci-sa1111.c | 28 ++--- drivers/usb/host/sl811-hcd.c | 198 +++++++++++++++++++++------------------- drivers/usb/host/sl811.h | 8 + 6 files changed, 184 insertions(+), 194 deletions(-)
drivers/usb/host/ohci-lh7a404.c +17 -26
@@ -106,23 +106,22 @@ retval = -ENOMEM ; goto err1; } - - hcd = driver->hcd_alloc (); -if (hcd ==NULL ){ -pr_debug ("hcd_alloc failed" ); +if (dev->resource[1 ].flags !=IORESOURCE_IRQ ){ +pr_debug ("resource[1] is not IORESOURCE_IRQ" ); retval = -ENOMEM ; goto err1; } + -if (dev->resource[1 ].flags !=IORESOURCE_IRQ ){ -pr_debug ("resource[1] is not IORESOURCE_IRQ" ); + hcd =usb_create_hcd (driver); +if (hcd ==NULL ){ +pr_debug ("hcd_alloc failed" ); retval = -ENOMEM ; goto err1; } +ohci_hcd_init (hcd_to_ohci (hcd)); - hcd->driver = (struct hc_driver *) driver; - hcd->description = driver->description; hcd->irq = dev->resource[1 ].start; hcd->regs = addr; hcd->self.controller = &dev->dev;
@@ -130,27 +129,21 @@ retval =hcd_buffer_create (hcd);if (retval !=0 ) {pr_debug ("pool alloc fail" ); - goto err1; + goto err2; } retval =request_irq (hcd->irq, usb_hcd_lh7a404_hcim_irq,SA_INTERRUPT , - hcd->description, hcd); + hcd->driver->description, hcd);if (retval !=0 ) {pr_debug ("request_irq failed" ); retval = -EBUSY ; - goto err2; + goto err3; }pr_debug ("%s (LH7A404) at 0x%p, irq %d" , - hcd->description, hcd->regs, hcd->irq); + hcd->driver->description, hcd->regs, hcd->irq); -usb_bus_init (&hcd->self); - hcd->self.op = &usb_hcd_operations; - hcd->self.release = &usb_hcd_release; - hcd->self.hcpriv = (void *) hcd; hcd->self.bus_name ="lh7a404" ; - hcd->product_desc ="LH7A404 OHCI" ; -usb_register_bus (&hcd->self);if ((retval = driver->start (hcd)) <0 )
@@ -162,10 +155,11 @@ *hcd_out = hcd;return 0 ; - err2: + err3:hcd_buffer_destroy (hcd); + err2: +usb_put_hcd (hcd); err1: -kfree (hcd);lh7a404_stop_hc (dev);release_mem_region (dev->resource[0 ].start, dev->resource[0].end
@@ -226,7 +220,7 @@return ret;if ((ret =ohci_run (ohci)) <0 ) { -err ("can't start %s" , ohci->hcd.self.bus_name); +err ("can't start %s" , hcd->self.bus_name);ohci_stop (hcd);return ret; }
@@ -237,6 +231,8 @@static const struct hc_driver ohci_lh7a404_hc_driver = { .description = hcd_name, + .product_desc ="LH7A404 OHCI" , + .hcd_priv_size =sizeof (struct ohci_hcd ),/* * generic hardware linkage
@@ -253,11 +249,6 @@/* resume: ohci_lh7a404_resume, -- tbd */ #endif /*CONFIG_PM*/ .stop = ohci_stop, - -/* -* memory lifecycle (except per-request) -*/ - .hcd_alloc = ohci_hcd_alloc,/* * managing i/o requests and associated device resources
drivers/usb/host/ohci-omap.c +26 -34
164 lines not on this page · raw message
drivers/usb/host/ohci-pxa27x.c +16 -25
98 lines not on this page · raw message
drivers/usb/host/ohci-sa1111.c +12 -16
@@ -162,15 +162,14 @@sa1111_start_hc (dev); - hcd = driver->hcd_alloc (); + hcd =usb_create_hcd (driver);if (hcd ==NULL ){dbg ("hcd_alloc failed" ); retval = -ENOMEM ; goto err1; } +ohci_hcd_init (hcd_to_ohci (hcd)); - hcd->driver = (struct hc_driver *) driver; - hcd->description = driver->description; hcd->irq = dev->irq[1 ]; hcd->regs = dev->mapbase; hcd->self.controller = &dev->dev;
@@ -178,27 +177,21 @@ retval =hcd_buffer_create (hcd);if (retval !=0 ) {dbg ("pool alloc fail" ); - goto err1; + goto err2; } retval =request_irq (hcd->irq, usb_hcd_sa1111_hcim_irq,SA_INTERRUPT , - hcd->description, hcd); + hcd->driver->description, hcd);if (retval !=0 ) {dbg ("request_irq failed" ); retval = -EBUSY ; - goto err2; + goto err3; }info ("%s (SA-1111) at 0x%p, irq %d\n" , - hcd->description, hcd->regs, hcd->irq); + hcd->driver->description, hcd->regs, hcd->irq); -usb_bus_init (&hcd->self); - hcd->self.op = &usb_hcd_operations; - hcd->self.release = &usb_hcd_release; - hcd->self.hcpriv = (void *) hcd; hcd->self.bus_name ="sa1111" ; - hcd->product_desc ="SA-1111 OHCI" ; -usb_register_bus (&hcd->self);if ((retval = driver->start (hcd)) <0 )
@@ -210,10 +203,11 @@ *hcd_out = hcd;return 0 ; - err2: + err3:hcd_buffer_destroy (hcd); + err2: +usb_put_hcd (hcd); err1: -kfree (hcd);sa1111_stop_hc (dev);release_mem_region (dev->res.start, dev->res.end - dev->res.start +1 );return retval;
@@ -269,7 +263,7 @@return ret;if ((ret =ohci_run (ohci)) <0 ) { -err ("can't start %s" , ohci->hcd.self.bus_name); +err ("can't start %s" , hcd->self.bus_name);ohci_stop (hcd);return ret; }
@@ -280,6 +274,8 @@static const struct hc_driver ohci_sa1111_hc_driver = { .description = hcd_name, + .product_desc ="SA-1111 OHCI" , + .hcd_priv_size =sizeof (struct ohci_hcd ),/* * generic hardware linkage
drivers/usb/host/sl811-hcd.c +107 -91
384 lines not on this page · raw message
drivers/usb/host/sl811.h +6 -2
@@ -118,7 +118,6 @@#define PERIODIC_SIZE (1 << LOG2_PERIODIC_SIZE)struct sl811 { -struct usb_hcd hcd;spinlock_t lock;void __iomem *addr_reg;void __iomem *data_reg;
@@ -158,7 +157,12 @@static inline struct sl811 *hcd_to_sl811 (struct usb_hcd *hcd) { - return container_of(hcd, struct sl811, hcd); +return (struct sl811 *) (hcd->hcd_priv); +} + +static inline struct usb_hcd *sl811_to_hcd (struct sl811 *sl811) +{ + return container_of((void *) sl811, struct usb_hcd, hcd_priv); }struct sl811h_ep {
ChangeSet 1.1938.446.45, 2004/12/20 14:20:30-08:00, [email protected]
[PATCH] USB: Create usb_hcd structures within usbcore [6/13]
This patch alters the dummy_hcd driver, removing the routine that allocates the hcd structure and introducing inline functions to convert safely between the public and private hcd structures.
drivers/usb/gadget/dummy_hcd.c | 44 +++++++++++++---------------------------- 1 files changed, 14 insertions(+), 30 deletions(-)
drivers/usb/gadget/dummy_hcd.c +14 -30
@@ -149,7 +149,6 @@ };struct dummy { -struct usb_hcd hcd;/* must come first! */ spinlock_t lock;/*
@@ -178,12 +177,17 @@static inline struct dummy *hcd_to_dummy (struct usb_hcd *hcd) { - return container_of(hcd, struct dummy, hcd); +return (struct dummy *) (hcd->hcd_priv); +} + +static inline struct usb_hcd *dummy_to_hcd (struct dummy *dum) +{ + return container_of((void *) dum, struct usb_hcd, hcd_priv); }static inline struct device *dummy_dev (struct dummy *dum) { -return dum->hcd.self.controller; +return dummy_to_hcd (dum)->self.controller; }static inline struct dummy *ep_to_dummy (struct dummy_ep *ep)
@@ -1368,7 +1372,7 @@ ep->already_seen = ep->setup_stage =0 ;spin_unlock (&dum->lock); -usb_hcd_giveback_urb (&dum->hcd, urb,0 ); +usb_hcd_giveback_urb (dummy_to_hcd (dum), urb,0 );spin_lock (&dum->lock); goto restart;
@@ -1570,20 +1574,6 @@/*-------------------------------------------------------------------------*/ -static struct usb_hcd *dummy_alloc (void ) -{ -struct dummy *dum; - - dum =kmalloc (sizeof *dum,SLAB_KERNEL ); -if (dum ==NULL ) -return NULL ; - the_controller = dum; -memset (dum,0 ,sizeof *dum); -return &dum->hcd; -} - -/*-------------------------------------------------------------------------*/ -static inline ssize_t show_urb (char *buf,size_t size,struct urb *urb) {
@@ -1711,13 +1701,14 @@static const struct hc_driver dummy_hcd = { .description = (char *) driver_name, + .product_desc ="Dummy host controller" , + .hcd_priv_size =sizeof (struct dummy ), + .flags =HCD_USB2 , .start = dummy_start, .stop = dummy_stop, - .hcd_alloc = dummy_alloc, - .urb_enqueue = dummy_urb_enqueue, .urb_dequeue = dummy_urb_dequeue,
@@ -1737,7 +1728,7 @@dev_info (dev,"%s, driver " DRIVER_VERSION "\n" , driver_desc); - hcd =dummy_alloc (); + hcd =usb_create_hcd (&dummy_hcd);if (hcd ==NULL ) {dev_dbg (dev,"hcd_alloc failed\n" );return -ENOMEM ;
@@ -1745,9 +1736,8 @@dev_set_drvdata (dev, hcd); dum =hcd_to_dummy (hcd); + the_controller = dum; - hcd->driver = (struct hc_driver *) &dummy_hcd; - hcd->description = dummy_hcd.description; hcd->self.controller = dev;/* FIXME don't require the pci-based buffer/alloc impls;
@@ -1760,13 +1750,7 @@ goto err1; } -usb_bus_init (&hcd->self); - hcd->self.op = &usb_hcd_operations; - hcd->self.release = &usb_hcd_release; - hcd->self.hcpriv = hcd; hcd->self.bus_name = dev->bus_id; - hcd->product_desc ="Dummy host controller" ; -usb_register_bus (&hcd->self);if ((retval =dummy_start (hcd)) <0 )
@@ -1774,7 +1758,7 @@return retval; err1: -kfree (hcd); +usb_put_hcd (hcd);dev_set_drvdata (dev,NULL );return retval; }
ChangeSet 1.1938.446.46, 2004/12/20 15:00:14-08:00, [email protected]
[PATCH] USB: Hub driver: improve error checking and retries [10/13]
Here's another "cleanup" type patch, most of which was written by David Brownell. It causes the hub driver to retry a couple of different types of transfers if they timeout (which seems to help with some flakey devices), and it adds some error checking for the ep0 maxpacket value sent by the device.
From: David Brownell <[email protected]>
drivers/usb/core/hub.c | 58 ++++++++++++++++++++++++++++++++++--------------- 1 files changed, 41 insertions(+), 17 deletions(-)
drivers/usb/core/hub.c +41 -17
@@ -240,15 +240,24 @@schedule_delayed_work (&hub->leds,LED_CYCLE_PERIOD ); } +/* use a short timeout for hub/port status fetches */ +#define USB_STS_TIMEOUT 1 +#define USB_STS_RETRIES 5 +/* * USB 2.0 spec Section 11.24.2.6 */ static int get_hub_status (struct usb_device *hdev,struct usb_hub_status *data) { -return usb_control_msg (hdev,usb_rcvctrlpipe (hdev,0 ), -USB_REQ_GET_STATUS ,USB_DIR_IN |USB_RT_HUB ,0 ,0 , - data,sizeof (*data),HZ *USB_CTRL_GET_TIMEOUT ); +int i, status = -ETIMEDOUT ; + +for (i =0 ; i <USB_STS_RETRIES && status == -ETIMEDOUT ; i++) { + status =usb_control_msg (hdev,usb_rcvctrlpipe (hdev,0 ), +USB_REQ_GET_STATUS ,USB_DIR_IN |USB_RT_HUB ,0 ,0 , + data,sizeof (*data),HZ *USB_STS_TIMEOUT ); + } +return status; }/*
@@ -257,9 +266,14 @@static int get_port_status (struct usb_device *hdev,int port,struct usb_port_status *data) { -return usb_control_msg (hdev,usb_rcvctrlpipe (hdev,0 ), -USB_REQ_GET_STATUS ,USB_DIR_IN |USB_RT_PORT ,0 , port, - data,sizeof (*data),HZ *USB_CTRL_GET_TIMEOUT ); +int i, status = -ETIMEDOUT ; + +for (i =0 ; i <USB_STS_RETRIES && status == -ETIMEDOUT ; i++) { + status =usb_control_msg (hdev,usb_rcvctrlpipe (hdev,0 ), +USB_REQ_GET_STATUS ,USB_DIR_IN |USB_RT_PORT ,0 , port, + data,sizeof (*data),HZ *USB_STS_TIMEOUT ); + } +return status; }static void kick_khubd (struct usb_hub *hub)
@@ -2163,6 +2177,7 @@for (i =0 ; i <GET_DESCRIPTOR_TRIES ; (++i,msleep (100 ))) {if (USE_NEW_SCHEME (retry_counter)) {struct usb_device_descriptor *buf; +int r =0 ;#define GET_DESCRIPTOR_BUFSIZE 64 buf =kmalloc (GET_DESCRIPTOR_BUFSIZE ,GFP_NOIO );
@@ -2176,13 +2191,20 @@* so that recalcitrant full-speed devices with * 8- or 16-byte ep0-maxpackets won't slow things * down tremendously by NAKing the unexpectedly -* early status stage. +* early status stage. Also, retry on length 0 +* or stall; some devices are flakey. */ - j =usb_control_msg (udev,usb_rcvaddr0pipe (), +for (j =0 ; j <3 ; ++j) { + r =usb_control_msg (udev,usb_rcvaddr0pipe (),USB_REQ_GET_DESCRIPTOR ,USB_DIR_IN ,USB_DT_DEVICE <<8 ,0 , buf,GET_DESCRIPTOR_BUFSIZE , (i ?HZ *USB_CTRL_GET_TIMEOUT :HZ )); +if (r ==0 || r == -EPIPE ) +continue ; +if (r <0 ) +break ; + } udev->descriptor.bMaxPacketSize0 = buf->bMaxPacketSize0;kfree (buf);
@@ -2202,7 +2224,7 @@default :dev_err (&udev->dev,"device descriptor " "read/%s, error %d\n" , -"64" , j); +"64" , r); retval = -EMSGSIZE ;continue ; }
@@ -2245,14 +2267,16 @@if (retval) goto fail; -/* Should we verify that the value is valid? */ -/* (YES!) */ -if (udev->ep0.desc.wMaxPacketSize - != udev->descriptor.bMaxPacketSize0) { - udev->ep0.desc.wMaxPacketSize - = udev->descriptor.bMaxPacketSize0; -dev_dbg (&udev->dev,"ep0 maxpacket = %d\n" , - udev->ep0.desc.wMaxPacketSize); + i = udev->descriptor.bMaxPacketSize0; +if (udev->ep0.desc.wMaxPacketSize != i) { +if (udev->speed !=USB_SPEED_FULL || + !(i ==8 || i ==16 || i ==32 || i ==64 )) { +dev_err (&udev->dev,"ep0 maxpacket = %d\n" , i); + retval = -EMSGSIZE ; + goto fail; + } +dev_dbg (&udev->dev,"ep0 maxpacket = %d\n" , i); + udev->ep0.desc.wMaxPacketSize = i;ep0_reinit (udev); }
ChangeSet 1.1938.446.47, 2004/12/20 15:00:38-08:00, [email protected]
[PATCH] USB: Hub driver: several bug fixes and simplifications [11/13]
This patch adds several relatively minor bug fixes and code simplifications for the hub driver.
Perhaps most significantly, a test is added to usbfs to prevent users from unbinding the hub driver from a hub with children. That could cause some bad headaches, and it's best to avoid the situation.
Don't set unused bits in the change_bits and event_bits fields (this aids in debugging, nothing more).
Use the correct spinlock in the hub ioctl routine!
Add an argument to hub_port_disable, indicating whether the device behind the disabled port should be marked NOTATTACHED. Normally it should, but for retries during usb_reset_device it should not.
Pass the child device as an argument to hub_port_suspend and hub_port_resume rather than making them recalculate it.
Call usb_set_device_state in the suspend/resume code rather than setting udev->state directly.
Set udev->power.power_state in the suspend/resume code so that the correct values are visible in sysfs.
Recognize during hub_port_resume that the child device udev might be NULL (this will happen when a new device is plugged into a suspended port).
Don't allow hub_port_init to drop the usb_address0_sem lock while a device on the bus is still using address 0!
Make khubd acquire a reference to the hub interface rather than the hub device. This simplifies disconnect/unbind testing.
Don't print a debugging message about hub events while not holding some lock to protect the hub.
Remember to drop the reference acquired above if we fail to lock the hub.
drivers/usb/core/devio.c | 11 +++++ drivers/usb/core/hub.c | 101 +++++++++++++++++++++++++---------------------- 2 files changed, 66 insertions(+), 46 deletions(-)
drivers/usb/core/devio.c +11 -0
@@ -1122,6 +1122,7 @@int retval =0 ;struct usb_interface *intf =NULL ;struct usb_driver *driver =NULL ; +int i;/* get input parameters and alloc buffer */ if (copy_from_user (&ctrl, arg,sizeof (ctrl)))
@@ -1153,6 +1154,16 @@/* disconnect kernel driver from interface */ case USBDEVFS_DISCONNECT : + +/* don't allow the user to unbind the hub driver from +* a hub with children to manage */ +for (i =0 ; i < ps->dev->maxchild; ++i) { +if (ps->dev->children[i]) + retval = -EBUSY ; + } +if (retval) +break ; +down_write (&usb_bus_type.subsys.rwsem);if (intf->dev.driver) { driver =to_usb_driver (intf->dev.driver);
drivers/usb/core/hub.c +55 -46
277 lines not on this page · raw message
ChangeSet 1.1938.446.48, 2004/12/20 15:01:03-08:00, [email protected]
[PATCH] USB: Hub driver cleanups [12/13]
This patch does a little cleanup of the hub driver, nothing dramatic (although it is long because it touches a lot of code). The main feature is that the private hub structure is passed as an argument to internal routines rather than the hub device structure. This simplifies conversions, because it's easier to go from the private structure to the device structure than vice versa. The other change is to store a pointer to the interface's embedded struct device rather than the interface itself. This helps because that pointer is mainly used for dev_xxx log messages.
drivers/usb/core/hub.c | 202 +++++++++++++++++++++++-------------------------- drivers/usb/core/hub.h | 2 2 files changed, 99 insertions(+), 105 deletions(-)
drivers/usb/core/hub.c +98 -104
@@ -94,10 +94,10 @@ }#endif -/* for dev_info, dev_dbg, etc */ -static inline struct device *hubdev (struct usb_device *hdev) +/* Note that hdev or one of its children must be locked! */ +static inline struct usb_hub *hdev_to_hub (struct usb_device *hdev) { -return &hdev->actconfig->interface[0 ]->dev; +return usb_get_intfdata (hdev->actconfig->interface[0 ]); }/* USB 2.0 spec Section 11.24.4.5 */
@@ -148,15 +148,15 @@* for info about using port indicators */ static void set_port_led ( -struct usb_device *hdev, +struct usb_hub *hub,int port,int selector ) { -int status =set_port_feature (hdev, (selector <<8 ) | port, +int status =set_port_feature (hub->hdev, (selector <<8 ) | port,USB_PORT_FEAT_INDICATOR ); if (status < 0) - dev_dbg (hubdev (hdev), + dev_dbg (hub->intfdev, "port %d indicator %s status %d\n", port, ({ char *s; switch (selector) {
@@ -226,13 +226,13 @@ }if (selector !=HUB_LED_AUTO ) changed =1 ; -set_port_led (hdev, i +1 , selector); +set_port_led (hub, i +1 , selector); hub->indicator[i] = mode; }if (!changed && blinkenlights) { cursor++; cursor %= hub->descriptor->bNbrPorts; -set_port_led (hdev, cursor +1 ,HUB_LED_GREEN ); +set_port_led (hub, cursor +1 ,HUB_LED_GREEN ); hub->indicator[cursor] =INDICATOR_CYCLE ; changed++; }
@@ -305,7 +305,7 @@default :/* presumably an error */ /* Cause a hub reset after 10 consecutive errors */ -dev_dbg (&hub->intf->dev,"transfer --> %d\n" , urb->status); +dev_dbg (hub->intfdev,"transfer --> %d\n" , urb->status);if ((++hub->nerrors <10 ) || hub->error) goto resubmit; hub->error = urb->status;
@@ -332,7 +332,7 @@if ((status =usb_submit_urb (hub->urb,GFP_ATOMIC )) !=0 && status != -ENODEV && status != -EPERM ) -dev_err (&hub->intf->dev,"resubmit --> %d\n" , status); +dev_err (hub->intfdev,"resubmit --> %d\n" , status); }/* USB 2.0 spec Section 11.24.2.3 */
@@ -432,7 +432,7 @@/* if hub supports power switching, enable power on each port */ if ((hub->descriptor->wHubCharacteristics &HUB_CHAR_LPSM ) <2 ) { -dev_dbg (&hub->intf->dev,"enabling power on all ports\n" ); +dev_dbg (hub->intfdev,"enabling power on all ports\n" );for (i =0 ; i < hub->descriptor->bNbrPorts; i++)set_port_feature (hub->hdev, i +1 ,USB_PORT_FEAT_POWER );
@@ -460,7 +460,7 @@ hub->quiescing =0 ; status =usb_submit_urb (hub->urb,GFP_NOIO );if (status <0 ) -dev_err (&hub->intf->dev,"activate --> %d\n" , status); +dev_err (hub->intfdev,"activate --> %d\n" , status);if (hub->has_indicators && blinkenlights)schedule_delayed_work (&hub->leds,LED_CYCLE_PERIOD );
@@ -476,7 +476,7 @@ ret =get_hub_status (hub->hdev, &hub->status->hub);if (ret <0 ) -dev_err (&hub->intf->dev, +dev_err (hub->intfdev,"%s failed (err = %d)\n" , __FUNCTION__, ret);else { *status =le16_to_cpu (hub->status->hub.wHubStatus);
@@ -490,7 +490,7 @@ struct usb_endpoint_descriptor *endpoint) {struct usb_device *hdev = hub->hdev; -struct device *hub_dev = &hub->intf->dev; +struct device *hub_dev = hub->intfdev;u16 hubstatus, hubchange;unsigned int pipe;int maxp, ret;
@@ -749,18 +749,16 @@struct usb_endpoint_descriptor *endpoint;struct usb_device *hdev;struct usb_hub *hub; -struct device *hub_dev; desc = intf->cur_altsetting; hdev =interface_to_usbdev (intf); - hub_dev = &intf->dev;/* Some hubs have a subclass of 1, which AFAICT according to the */ /* specs is not defined, but it works */ if ((desc->desc.bInterfaceSubClass !=0 ) && (desc->desc.bInterfaceSubClass !=1 )) { descriptor_error: -dev_err (hub_dev,"bad descriptor, ignoring hub\n" ); +dev_err (&intf->dev,"bad descriptor, ignoring hub\n" );return -EIO ; }
@@ -780,18 +778,18 @@ goto descriptor_error;/* We found a hub */ -dev_info (hub_dev,"USB hub found\n" ); +dev_info (&intf->dev,"USB hub found\n" ); hub =kmalloc (sizeof (*hub),GFP_KERNEL );if (!hub) { -dev_dbg (hub_dev,"couldn't kmalloc hub struct\n" ); +dev_dbg (&intf->dev,"couldn't kmalloc hub struct\n" );return -ENOMEM ; }memset (hub,0 ,sizeof (*hub));INIT_LIST_HEAD (&hub->event_list); - hub->intf = intf; + hub->intfdev = &intf->dev; hub->hdev = hdev;INIT_WORK (&hub->leds, led_work, hub);
@@ -842,9 +840,9 @@ }/* caller has locked the hub device */ -static void hub_pre_reset (struct usb_device *hdev) +static void hub_pre_reset (struct usb_hub *hub) { -struct usb_hub *hub =usb_get_intfdata (hdev->actconfig->interface[0 ]); +struct usb_device *hdev = hub->hdev;int i;for (i =0 ; i < hdev->maxchild; ++i) {
@@ -855,10 +853,8 @@ }/* caller has locked the hub device */ -static void hub_post_reset (struct usb_device *hdev) +static void hub_post_reset (struct usb_hub *hub) { -struct usb_hub *hub =usb_get_intfdata (hdev->actconfig->interface[0 ]); -hub_activate (hub);hub_power_on (hub); }
@@ -1288,18 +1284,14 @@ } -static int hub_port_status (struct usb_device *hdev,int port, +static int hub_port_status (struct usb_hub *hub,int port,u16 *status,u16 *change) { -struct usb_hub *hub =usb_get_intfdata (hdev->actconfig->interface[0 ]);int ret; -if (!hub) -return -ENODEV ; - - ret =get_port_status (hdev, port +1 , &hub->status->port); + ret =get_port_status (hub->hdev, port +1 , &hub->status->port);if (ret <0 ) -dev_err (&hub->intf->dev, +dev_err (hub->intfdev,"%s failed (err = %d)\n" , __FUNCTION__, ret);else { *status =le16_to_cpu (hub->status->port.wPortStatus);
@@ -1320,7 +1312,7 @@#define HUB_LONG_RESET_TIME 200#define HUB_RESET_TIMEOUT 500 -static int hub_port_wait_reset (struct usb_device *hdev,int port, +static int hub_port_wait_reset (struct usb_hub *hub,int port,struct usb_device *udev,unsigned int delay) {int delay_time, ret;
@@ -1334,7 +1326,7 @@msleep (delay);/* read and decode port status */ - ret =hub_port_status (hdev, port, &portstatus, &portchange); + ret =hub_port_status (hub, port, &portstatus, &portchange);if (ret <0 )return ret;
@@ -1362,7 +1354,7 @@if (delay_time >=2 *HUB_SHORT_RESET_TIME ) delay =HUB_LONG_RESET_TIME ; -dev_dbg (hubdev (hdev), +dev_dbg (hub->intfdev,"port %d not reset yet, waiting %dms\n" , port +1 , delay); }
@@ -1370,27 +1362,28 @@return -EBUSY ; } -static int hub_port_reset (struct usb_device *hdev,int port, +static int hub_port_reset (struct usb_hub *hub,int port,struct usb_device *udev,unsigned int delay) {int i, status; -struct device *hub_dev =hubdev (hdev);/* Reset the port */ for (i =0 ; i <PORT_RESET_TRIES ; i++) { - status =set_port_feature (hdev, port +1 ,USB_PORT_FEAT_RESET ); + status =set_port_feature (hub->hdev, + port +1 ,USB_PORT_FEAT_RESET );if (status) -dev_err (hub_dev,"cannot reset port %d (err = %d)\n" , +dev_err (hub->intfdev, +"cannot reset port %d (err = %d)\n" , port +1 , status);else - status =hub_port_wait_reset (hdev, port, udev, delay); + status =hub_port_wait_reset (hub, port, udev, delay);/* return on disconnect or reset */ switch (status) {case 0 :case -ENOTCONN :case -ENODEV : -clear_port_feature (hdev, +clear_port_feature (hub->hdev, port +1 ,USB_PORT_FEAT_C_RESET );/* FIXME need disconnect() for NOTATTACHED device */ usb_set_device_state(udev, status
@@ -1399,21 +1392,22 @@return status; } -dev_dbg (hub_dev, +dev_dbg (hub->intfdev,"port %d not enabled, trying reset again...\n" , port +1 ); delay =HUB_LONG_RESET_TIME ; } -dev_err (hub_dev, +dev_err (hub->intfdev,"Cannot enable port %i. Maybe the USB cable is bad?\n" , port +1 );return status; } -static int hub_port_disable (struct usb_device *hdev,int port,int set_state) +static int hub_port_disable (struct usb_hub *hub,int port,int set_state) { +struct usb_device *hdev = hub->hdev;int ret;if (hdev->children[port] && set_state) {
@@ -1422,7 +1416,7 @@ } ret =clear_port_feature (hdev, port +1 ,USB_PORT_FEAT_ENABLE );if (ret) -dev_err (hubdev (hdev),"cannot disable port %d (err = %d)\n" , +dev_err (hub->intfdev,"cannot disable port %d (err = %d)\n" , port +1 , ret);return ret;
@@ -1433,12 +1427,10 @@* time later khubd will disconnect() any existing usb_device on the port * and will re-enumerate if there actually is a device attached. */ -static void hub_port_logical_disconnect (struct usb_device *hdev,int port) +static void hub_port_logical_disconnect (struct usb_hub *hub,int port) { -struct usb_hub *hub; - -dev_dbg (hubdev (hdev),"logical disconnect on port %d\n" , port +1 ); -hub_port_disable (hdev, port,1 ); +dev_dbg (hub->intfdev,"logical disconnect on port %d\n" , port +1 ); +hub_port_disable (hub, port,1 );/* FIXME let caller ask to power down the port: * - some devices won't enumerate without a VBUS power cycle
@@ -1449,7 +1441,6 @@* Powerdown must be optional, because of reset/DFU. */ - hub =usb_get_intfdata (hdev->actconfig->interface[0 ]);set_bit (port, hub->change_bits);kick_khubd (hub); }
@@ -1467,12 +1458,12 @@* tree above them to deliver data, such as a keypress or packet. In * some cases, this wakes the USB host. */ -static int hub_port_suspend (struct usb_device *hdev,int port, +static int hub_port_suspend (struct usb_hub *hub,int port,struct usb_device *udev) {int status; -// dev_dbg(hubdev(hdev), "suspend port %d\n", port + 1); +// dev_dbg(hub->intfdev, "suspend port %d\n", port + 1); /* enable remote wakeup when appropriate; this lets the device * wake up the upstream hub (including maybe the root hub).
@@ -1497,9 +1488,9 @@ }/* see 7.1.7.6 */ - status =set_port_feature (hdev, port +1 ,USB_PORT_FEAT_SUSPEND ); + status =set_port_feature (hub->hdev, port +1 ,USB_PORT_FEAT_SUSPEND );if (status) { -dev_dbg (hubdev (hdev), +dev_dbg (hub->intfdev,"can't suspend port %d, status %d\n" , port +1 , status);/* paranoia: "should not happen" */
@@ -1618,7 +1609,8 @@ }else status = -EOPNOTSUPP ; }else - status =hub_port_suspend (udev->parent, port, udev); + status =hub_port_suspend (hdev_to_hub (udev->parent), port, + udev);if (status ==0 ) udev->dev.power.power_state = state;
@@ -1746,16 +1738,17 @@ }static int -hub_port_resume (struct usb_device *hdev,int port,struct usb_device *udev) +hub_port_resume (struct usb_hub *hub,int port,struct usb_device *udev) {int status; -// dev_dbg(hubdev(hdev), "resume port %d\n", port + 1); +// dev_dbg(hub->intfdev, "resume port %d\n", port + 1); /* see 7.1.7.7; affects power usage, but not budgeting */ - status =clear_port_feature (hdev, port +1 ,USB_PORT_FEAT_SUSPEND ); + status =clear_port_feature (hub->hdev, + port +1 ,USB_PORT_FEAT_SUSPEND );if (status) { -dev_dbg (&hdev->actconfig->interface[0 ]->dev, +dev_dbg (hub->intfdev,"can't resume port %d, status %d\n" , port +1 , status); }else {
@@ -1776,13 +1769,13 @@* sequence. */ devstatus = portchange =0 ; - status =hub_port_status (hdev, port, + status =hub_port_status (hub, port, &devstatus, &portchange);if (status <0 || (devstatus &LIVE_FLAGS ) !=LIVE_FLAGS || (devstatus &USB_PORT_STAT_SUSPEND ) !=0 ) { -dev_dbg (&hdev->actconfig->interface[0 ]->dev, +dev_dbg (hub->intfdev,"port %d status %04x.%04x after resume, %d\n" , port +1 , portchange, devstatus, status); }else {
@@ -1793,7 +1786,7 @@ } }if (status <0 ) -hub_port_logical_disconnect (hdev, port); +hub_port_logical_disconnect (hub, port);return status; }
@@ -1815,7 +1808,7 @@*/ int usb_resume_device (struct usb_device *udev) { -int port, status; +int port, status; port =locktree (udev);if (port <0 )
@@ -1839,7 +1832,8 @@ } }else if (udev->state ==USB_STATE_SUSPENDED ) {// NOTE this fails if parent is also suspended... - status =hub_port_resume (udev->parent, port, udev); + status =hub_port_resume (hdev_to_hub (udev->parent), + port, udev); }else { status =0 ; }
@@ -1921,7 +1915,7 @@u16 portstat, portchange; udev = hdev->children [port]; - status =hub_port_status (hdev, port, &portstat, &portchange); + status =hub_port_status (hub, port, &portstat, &portchange);if (status ==0 ) {if (portchange &USB_PORT_STAT_C_SUSPEND ) { clear_port_feature(hdev, port + 1,
@@ -1938,13 +1932,13 @@continue ;down (&udev->serialize);if (portstat &USB_PORT_STAT_SUSPEND ) - status =hub_port_resume (hdev, port, udev); + status =hub_port_resume (hub, port, udev);else { status =finish_port_resume (udev);if (status <0 ) {dev_dbg (&intf->dev,"resume port %d --> %d\n" , port +1 , status); -hub_port_logical_disconnect (hdev, port); +hub_port_logical_disconnect (hub, port); } }up (&udev->serialize);
@@ -1998,7 +1992,7 @@#define HUB_DEBOUNCE_STEP 25#define HUB_DEBOUNCE_STABLE 100 -static int hub_port_debounce (struct usb_device *hdev,int port) +static int hub_port_debounce (struct usb_hub *hub,int port) {int ret;int total_time, stable_time =0 ;
@@ -2006,7 +2000,7 @@unsigned connection =0xffff ;for (total_time =0 ; ; total_time +=HUB_DEBOUNCE_STEP ) { - ret =hub_port_status (hdev, port, &portstatus, &portchange); + ret =hub_port_status (hub, port, &portstatus, &portchange);if (ret <0 )return ret;
@@ -2021,7 +2015,7 @@ }if (portchange &USB_PORT_STAT_C_CONNECTION ) { -clear_port_feature (hdev, port+1 , +clear_port_feature (hub->hdev, port+1 ,USB_PORT_FEAT_C_CONNECTION ); }
@@ -2030,7 +2024,7 @@msleep (HUB_DEBOUNCE_STEP ); } -dev_dbg (hubdev (hdev), +dev_dbg (hub->intfdev,"debounce: port %d: total %dms stable %dms status 0x%x\n" , port +1 , total_time, stable_time, portstatus);
@@ -2079,11 +2073,12 @@* pointers, it's not necessary to lock the device. */ static int -hub_port_init (struct usb_device *hdev,struct usb_device *udev,int port, +hub_port_init (struct usb_hub *hub,struct usb_device *udev,int port,int retry_counter) {static DECLARE_MUTEX (usb_address0_sem); +struct usb_device *hdev = hub->hdev;int i, j, retval;unsigned delay =HUB_SHORT_RESET_TIME ;enum usb_device_speed oldspeed = udev->speed;
@@ -2105,7 +2100,7 @@down (&usb_address0_sem);/* Reset the device; full speed may morph to high speed */ - retval =hub_port_reset (hdev, port, udev, delay); + retval =hub_port_reset (hub, port, udev, delay);if (retval <0 )/* error or disconnect */ goto fail;/* success, speed is known */
@@ -2156,9 +2151,6 @@ udev->ttport = hdev->ttport; }else if (udev->speed !=USB_SPEED_HIGH && hdev->speed ==USB_SPEED_HIGH ) { -struct usb_hub *hub; - - hub =usb_get_intfdata (hdev->actconfig->interface[0 ]); udev->tt = &hub->tt; udev->ttport = port +1 ; }
@@ -2210,7 +2202,7 @@ buf->bMaxPacketSize0;kfree (buf); - retval =hub_port_reset (hdev, port, udev, delay); + retval =hub_port_reset (hub, port, udev, delay);if (retval <0 )/* error or disconnect */ goto fail;if (oldspeed != udev->speed) {
@@ -2294,7 +2286,7 @@ fail:if (retval) -hub_port_disable (hdev, port,0 ); +hub_port_disable (hub, port,0 );up (&usb_address0_sem);return retval; }
@@ -2358,7 +2350,7 @@ remaining -= delta; }if (remaining <0 ) { -dev_warn (&hub->intf->dev, +dev_warn (hub->intfdev,"%dmA over power budget!\n" ,-2 * remaining); remaining =0 ;
@@ -2378,7 +2370,7 @@ u16 portstatus, u16 portchange) {struct usb_device *hdev = hub->hdev; -struct device *hub_dev = &hub->intf->dev; +struct device *hub_dev = hub->intfdev;int status, i; dev_dbg (hub_dev,
@@ -2386,7 +2378,7 @@ port + 1, portstatus, portchange, portspeed (portstatus));if (hub->has_indicators) { -set_port_led (hdev, port +1 ,HUB_LED_AUTO ); +set_port_led (hub, port +1 ,HUB_LED_AUTO ); hub->indicator[port] =INDICATOR_AUTO ; }
@@ -2402,7 +2394,7 @@#endif if (portchange &USB_PORT_STAT_C_CONNECTION ) { - status =hub_port_debounce (hdev, port); + status =hub_port_debounce (hub, port);if (status <0 ) { dev_err (hub_dev, "connect-debounce failed, port %d disabled\n",
@@ -2429,7 +2421,7 @@#ifdef CONFIG_USB_SUSPEND /* If something is connected, but the port is suspended, wake it up. */ if (portstatus &USB_PORT_STAT_SUSPEND ) { - status =hub_port_resume (hdev, port,NULL ); + status =hub_port_resume (hub, port,NULL );if (status <0 ) { dev_dbg(hub_dev, "can't clear suspend on port %d; %d\n",
@@ -2463,7 +2455,7 @@ }/* reset and get descriptor */ - status =hub_port_init (hdev, udev, port, i); + status =hub_port_init (hub, udev, port, i);if (status <0 ) goto loop;
@@ -2545,7 +2537,7 @@return ; loop_disable: -hub_port_disable (hdev, port,1 ); +hub_port_disable (hub, port,1 ); loop:ep0_reinit (udev);release_address (udev);
@@ -2555,7 +2547,7 @@ } done: -hub_port_disable (hdev, port,1 ); +hub_port_disable (hub, port,1 ); }static void hub_events (void )
@@ -2592,7 +2584,7 @@ hub = list_entry(tmp, struct usb_hub, event_list); hdev = hub->hdev; - intf = hub->intf; + intf =to_usb_interface (hub->intfdev); hub_dev = &intf->dev; dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n",
@@ -2637,7 +2629,7 @@ !connect_change)continue ; - ret =hub_port_status (hdev, i, + ret =hub_port_status (hub, i, &portstatus, &portchange);if (ret <0 )continue ;
@@ -2684,7 +2676,7 @@ connect_change =1 ; }else { ret = -ENODEV ; -hub_port_disable (hdev, i,1 ); +hub_port_disable (hub, i,1 ); } dev_dbg (hub_dev, "resume on port %d, status %d\n",
@@ -2890,10 +2882,11 @@*/ int usb_reset_device (struct usb_device *udev) { -struct usb_device *parent = udev->parent; -struct usb_device_descriptor descriptor = udev->descriptor; -int i, ret =0 , port =-1 ; -int udev_is_a_hub =0 ; +struct usb_device *parent_hdev = udev->parent; +struct usb_hub *parent_hub; +struct usb_device_descriptor descriptor = udev->descriptor; +struct usb_hub *hub =NULL ; +int i, ret =0 , port =-1 ;if (udev->state ==USB_STATE_NOTATTACHED || udev->state ==USB_STATE_SUSPENDED ) {
@@ -2902,14 +2895,14 @@return -EINVAL ; } -if (!parent) { +if (!parent_hdev) {/* this requires hcd-specific logic; see OHCI hc_restart() */ dev_dbg (&udev->dev,"%s for root hub!\n" , __FUNCTION__);return -EISDIR ; } -for (i =0 ; i < parent->maxchild; i++) -if (parent->children[i] == udev) { +for (i =0 ; i < parent_hdev->maxchild; i++) +if (parent_hdev->children[i] == udev) { port = i;break ; }
@@ -2919,13 +2912,14 @@dev_err (&udev->dev,"Can't locate device's port!\n" );return -ENOENT ; } + parent_hub =hdev_to_hub (parent_hdev);/* If we're resetting an active hub, take some special actions */ if (udev->actconfig && udev->actconfig->interface[0 ]->dev.driver == - &hub_driver.driver) { - udev_is_a_hub =1 ; -hub_pre_reset (udev); + &hub_driver.driver && + (hub =hdev_to_hub (udev)) !=NULL ) { +hub_pre_reset (hub); }for (i =0 ; i <SET_CONFIG_TRIES ; ++i) {
@@ -2933,7 +2927,7 @@/* ep0 maxpacket size may change; let the HCD know about it. * Other endpoints will be handled by re-enumeration. */ ep0_reinit (udev); - ret =hub_port_init (parent, udev, port, i); + ret =hub_port_init (parent_hub, udev, port, i);if (ret >=0 )break ; }
@@ -2984,11 +2978,11 @@ } done: -if (udev_is_a_hub) -hub_post_reset (udev); +if (hub) +hub_post_reset (hub);return 0 ; re_enumerate: -hub_port_logical_disconnect (parent, port); +hub_port_logical_disconnect (parent_hub, port);return -ENODEV ; }
drivers/usb/core/hub.h +1 -1
@@ -186,7 +186,7 @@extern void usb_hub_tt_clear_buffer (struct usb_device *dev,int pipe);struct usb_hub { -struct usb_interface *intf;/* the "real" device */ +struct device *intfdev;/* the "interface" device */ struct usb_device *hdev;struct urb *urb;/* for interrupt polling pipe */
ChangeSet 1.1938.446.49, 2004/12/20 15:01:26-08:00, [email protected]
[PATCH] USB: Another hub driver cleanup [13/13]
This patch does some more cleaning up of the hub driver. The idea is to use 1-based port numbers everywhere, in accordance with the usage of the USB spec, the values stored in USB messages, and the values printed in the system log. The downside is that we have to subtract 1 to index the children[] array, but that's a lot better than all the additions of 1 that were there before. To emphasize the nature of this change, I renamed the "port" local variable to "port1" every place it is used.
drivers/usb/core/hub.c | 280 ++++++++++++++++++++++++------------------------- drivers/usb/core/usb.c | 8 - 2 files changed, 146 insertions(+), 142 deletions(-)
drivers/usb/core/hub.c +142 -138
@@ -128,19 +128,21 @@/* * USB 2.0 spec Section 11.24.2.2 */ -static int clear_port_feature (struct usb_device *hdev,int port,int feature) +static int clear_port_feature (struct usb_device *hdev,int port1,int feature) {return usb_control_msg (hdev,usb_sndctrlpipe (hdev,0 ), -USB_REQ_CLEAR_FEATURE ,USB_RT_PORT , feature, port,NULL ,0 ,HZ ); +USB_REQ_CLEAR_FEATURE ,USB_RT_PORT , feature, port1, +NULL ,0 ,HZ ); }/* * USB 2.0 spec Section 11.24.2.13 */ -static int set_port_feature (struct usb_device *hdev,int port,int feature) +static int set_port_feature (struct usb_device *hdev,int port1,int feature) {return usb_control_msg (hdev,usb_sndctrlpipe (hdev,0 ), -USB_REQ_SET_FEATURE ,USB_RT_PORT , feature, port,NULL ,0 ,HZ ); +USB_REQ_SET_FEATURE ,USB_RT_PORT , feature, port1, +NULL ,0 ,HZ ); }/*
@@ -149,16 +151,16 @@*/ static void set_port_led (struct usb_hub *hub, -int port, +int port1,int selector ) { -int status =set_port_feature (hub->hdev, (selector <<8 ) | port, +int status =set_port_feature (hub->hdev, (selector <<8 ) | port1,USB_PORT_FEAT_INDICATOR ); if (status < 0) dev_dbg (hub->intfdev, "port %d indicator %s status %d\n", - port, + port1, ({ char *s; switch (selector) { case HUB_LED_AMBER: s = "amber"; break; case HUB_LED_GREEN: s = "green"; break;
@@ -263,14 +265,14 @@/* * USB 2.0 spec Section 11.24.2.7 */ -static int get_port_status (struct usb_device *hdev,int port, +static int get_port_status (struct usb_device *hdev,int port1,struct usb_port_status *data) {int i, status = -ETIMEDOUT ;for (i =0 ; i <USB_STS_RETRIES && status == -ETIMEDOUT ; i++) { status =usb_control_msg (hdev,usb_rcvctrlpipe (hdev,0 ), -USB_REQ_GET_STATUS ,USB_DIR_IN |USB_RT_PORT ,0 , port, +USB_REQ_GET_STATUS ,USB_DIR_IN |USB_RT_PORT ,0 , port1, data,sizeof (*data),HZ *USB_STS_TIMEOUT ); }return status;
@@ -428,13 +430,13 @@static void hub_power_on (struct usb_hub *hub) { -int i; +int port1;/* if hub supports power switching, enable power on each port */ if ((hub->descriptor->wHubCharacteristics &HUB_CHAR_LPSM ) <2 ) {dev_dbg (hub->intfdev,"enabling power on all ports\n" ); -for (i =0 ; i < hub->descriptor->bNbrPorts; i++) -set_port_feature (hub->hdev, i +1 , +for (port1 =1 ; port1 <= hub->descriptor->bNbrPorts; port1++) +set_port_feature (hub->hdev, port1,USB_PORT_FEAT_POWER ); }
@@ -688,7 +690,7 @@ hub->indicator [0 ] =INDICATOR_CYCLE ;hub_power_on (hub); - hub->change_bits[0 ] = (1UL << (hub->descriptor->bNbrPorts)) -1 ; + hub->change_bits[0 ] = (1UL << (hub->descriptor->bNbrPorts +1 )) -2 ;hub_activate (hub);return 0 ;
@@ -899,7 +901,7 @@*/ down (&udev->serialize);up (&hdev->serialize); -return t; +return t +1 ; } }usb_unlock_device (hdev);
@@ -1190,22 +1192,22 @@ udev->config[0].desc.wTotalLength, USB_DT_OTG, (void **) &desc) == 0) {if (desc->bmAttributes &USB_OTG_HNP ) { -unsigned port; +unsigned port1;struct usb_device *root = udev->parent; -for (port =0 ; port < root->maxchild; port++) { -if (root->children[port] == udev) +for (port1 =1 ; port1 <= root->maxchild; + port1++) { +if (root->children[port1-1 ] == udev)break ; } - port++;dev_info (&udev->dev,"Dual-Role OTG device on %sHNP port\n" , - (port == bus->otg_port) + (port1 == bus->otg_port) ?"" :"non-" );/* enable HNP before suspend, it's simpler */ -if (port == bus->otg_port) +if (port1 == bus->otg_port) bus->b_hnp_enable =1 ; err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
@@ -1234,9 +1236,9 @@*/ if (udev->bus->b_hnp_enable || udev->bus->is_b_host) {static int __usb_suspend_device (struct usb_device *, -int port,u32 state); +int port1,u32 state); err =__usb_suspend_device (udev, - udev->bus->otg_port -1 , + udev->bus->otg_port,PM_SUSPEND_MEM );if (err <0 )dev_dbg (&udev->dev,"HNP fail, %d\n" , err);
@@ -1284,12 +1286,12 @@ } -static int hub_port_status (struct usb_hub *hub,int port, +static int hub_port_status (struct usb_hub *hub,int port1,u16 *status,u16 *change) {int ret; - ret =get_port_status (hub->hdev, port +1 , &hub->status->port); + ret =get_port_status (hub->hdev, port1, &hub->status->port);if (ret <0 )dev_err (hub->intfdev,"%s failed (err = %d)\n" , __FUNCTION__, ret);
@@ -1312,7 +1314,7 @@#define HUB_LONG_RESET_TIME 200#define HUB_RESET_TIMEOUT 500 -static int hub_port_wait_reset (struct usb_hub *hub,int port, +static int hub_port_wait_reset (struct usb_hub *hub,int port1,struct usb_device *udev,unsigned int delay) {int delay_time, ret;
@@ -1326,7 +1328,7 @@msleep (delay);/* read and decode port status */ - ret =hub_port_status (hub, port, &portstatus, &portchange); + ret =hub_port_status (hub, port1, &portstatus, &portchange);if (ret <0 )return ret;
@@ -1356,13 +1358,13 @@dev_dbg (hub->intfdev,"port %d not reset yet, waiting %dms\n" , - port +1 , delay); + port1, delay); }return -EBUSY ; } -static int hub_port_reset (struct usb_hub *hub,int port, +static int hub_port_reset (struct usb_hub *hub,int port1,struct usb_device *udev,unsigned int delay) {int i, status;
@@ -1370,13 +1372,13 @@/* Reset the port */ for (i =0 ; i <PORT_RESET_TRIES ; i++) { status =set_port_feature (hub->hdev, - port +1 ,USB_PORT_FEAT_RESET ); + port1,USB_PORT_FEAT_RESET );if (status)dev_err (hub->intfdev,"cannot reset port %d (err = %d)\n" , - port +1 , status); + port1, status);else - status =hub_port_wait_reset (hub, port, udev, delay); + status =hub_port_wait_reset (hub, port1, udev, delay);/* return on disconnect or reset */ switch (status) {
@@ -1384,7 +1386,7 @@case -ENOTCONN :case -ENODEV :clear_port_feature (hub->hdev, - port +1 ,USB_PORT_FEAT_C_RESET ); + port1,USB_PORT_FEAT_C_RESET );/* FIXME need disconnect() for NOTATTACHED device */ usb_set_device_state(udev, status ? USB_STATE_NOTATTACHED
@@ -1394,30 +1396,30 @@dev_dbg (hub->intfdev,"port %d not enabled, trying reset again...\n" , - port +1 ); + port1); delay =HUB_LONG_RESET_TIME ; }dev_err (hub->intfdev,"Cannot enable port %i. Maybe the USB cable is bad?\n" , - port +1 ); + port1);return status; } -static int hub_port_disable (struct usb_hub *hub,int port,int set_state) +static int hub_port_disable (struct usb_hub *hub,int port1,int set_state) {struct usb_device *hdev = hub->hdev;int ret; -if (hdev->children[port] && set_state) { -usb_set_device_state (hdev->children[port], +if (hdev->children[port1-1 ] && set_state) { +usb_set_device_state (hdev->children[port1-1 ],USB_STATE_NOTATTACHED ); } - ret =clear_port_feature (hdev, port +1 ,USB_PORT_FEAT_ENABLE ); + ret =clear_port_feature (hdev, port1,USB_PORT_FEAT_ENABLE );if (ret)dev_err (hub->intfdev,"cannot disable port %d (err = %d)\n" , - port +1 , ret); + port1, ret);return ret; }
@@ -1427,10 +1429,10 @@* time later khubd will disconnect() any existing usb_device on the port * and will re-enumerate if there actually is a device attached. */ -static void hub_port_logical_disconnect (struct usb_hub *hub,int port) +static void hub_port_logical_disconnect (struct usb_hub *hub,int port1) { -dev_dbg (hub->intfdev,"logical disconnect on port %d\n" , port +1 ); -hub_port_disable (hub, port,1 ); +dev_dbg (hub->intfdev,"logical disconnect on port %d\n" , port1); +hub_port_disable (hub, port1,1 );/* FIXME let caller ask to power down the port: * - some devices won't enumerate without a VBUS power cycle
@@ -1441,7 +1443,7 @@* Powerdown must be optional, because of reset/DFU. */ -set_bit (port, hub->change_bits); +set_bit (port1, hub->change_bits);kick_khubd (hub); }
@@ -1458,12 +1460,12 @@* tree above them to deliver data, such as a keypress or packet. In * some cases, this wakes the USB host. */ -static int hub_port_suspend (struct usb_hub *hub,int port, +static int hub_port_suspend (struct usb_hub *hub,int port1,struct usb_device *udev) {int status; -// dev_dbg(hub->intfdev, "suspend port %d\n", port + 1); +// dev_dbg(hub->intfdev, "suspend port %d\n", port1); /* enable remote wakeup when appropriate; this lets the device * wake up the upstream hub (including maybe the root hub).
@@ -1488,11 +1490,11 @@ }/* see 7.1.7.6 */ - status =set_port_feature (hub->hdev, port +1 ,USB_PORT_FEAT_SUSPEND ); + status =set_port_feature (hub->hdev, port1,USB_PORT_FEAT_SUSPEND );if (status) {dev_dbg (hub->intfdev,"can't suspend port %d, status %d\n" , - port +1 , status); + port1, status);/* paranoia: "should not happen" */ (void) usb_control_msg(udev, usb_sndctrlpipe(udev, 0), USB_REQ_CLEAR_FEATURE, USB_RECIP_DEVICE,
@@ -1522,13 +1524,13 @@* Linux (2.6) currently has NO mechanisms to initiate that: no khubd * timer, no SRP, no requests through sysfs. */ -int __usb_suspend_device (struct usb_device *udev,int port,u32 state) +int __usb_suspend_device (struct usb_device *udev,int port1,u32 state) {int status;/* caller owns the udev device lock */ -if (port <0 ) -return port; +if (port1 <0 ) +return port1;if (udev->state ==USB_STATE_SUSPENDED || udev->state ==USB_STATE_NOTATTACHED ) {
@@ -1609,7 +1611,7 @@ }else status = -EOPNOTSUPP ; }else - status =hub_port_suspend (hdev_to_hub (udev->parent), port, + status =hub_port_suspend (hdev_to_hub (udev->parent), port1, udev);if (status ==0 )
@@ -1638,13 +1640,13 @@*/ int usb_suspend_device (struct usb_device *udev,u32 state) { -int port, status; +int port1, status; - port =locktree (udev); -if (port <0 ) -return port; + port1 =locktree (udev); +if (port1 <0 ) +return port1; - status =__usb_suspend_device (udev, port, state); + status =__usb_suspend_device (udev, port1, state);usb_unlock_device (udev);return status; }
@@ -1738,19 +1740,19 @@ }static int -hub_port_resume (struct usb_hub *hub,int port,struct usb_device *udev) +hub_port_resume (struct usb_hub *hub,int port1,struct usb_device *udev) {int status; -// dev_dbg(hub->intfdev, "resume port %d\n", port + 1); +// dev_dbg(hub->intfdev, "resume port %d\n", port1); /* see 7.1.7.7; affects power usage, but not budgeting */ status =clear_port_feature (hub->hdev, - port +1 ,USB_PORT_FEAT_SUSPEND ); + port1,USB_PORT_FEAT_SUSPEND );if (status) {dev_dbg (hub->intfdev,"can't resume port %d, status %d\n" , - port +1 , status); + port1, status); }else {u16 devstatus;u16 portchange;
@@ -1769,7 +1771,7 @@* sequence. */ devstatus = portchange =0 ; - status =hub_port_status (hub, port, + status =hub_port_status (hub, port1, &devstatus, &portchange);if (status <0 || (devstatus & LIVE_FLAGS) != LIVE_FLAGS
@@ -1777,7 +1779,7 @@ ) { dev_dbg(hub->intfdev, "port %d status %04x.%04x after resume, %d\n", - port + 1, portchange, devstatus, status); + port1, portchange, devstatus, status); } else {/* TRSMRCY = 10 msec */ msleep (10 );
@@ -1786,7 +1788,7 @@ } }if (status <0 ) -hub_port_logical_disconnect (hub, port); +hub_port_logical_disconnect (hub, port1);return status; }
@@ -1808,11 +1810,11 @@*/ int usb_resume_device (struct usb_device *udev) { -int port, status; +int port1, status; - port =locktree (udev); -if (port <0 ) -return port; + port1 =locktree (udev); +if (port1 <0 ) +return port1;/* "global resume" of the HC-to-USB interface (root hub), or * selective resume of one hub-to-device port
@@ -1833,7 +1835,7 @@ }else if (udev->state ==USB_STATE_SUSPENDED ) {// NOTE this fails if parent is also suspended... status =hub_port_resume (hdev_to_hub (udev->parent), - port, udev); + port1, udev); }else { status =0 ; }
@@ -1875,25 +1877,25 @@ {struct usb_hub *hub =usb_get_intfdata (intf);struct usb_device *hdev = hub->hdev; -unsigned port; +unsigned port1;int status;/* stop khubd and related activity */ hub_quiesce (hub);/* then suspend every port */ -for (port =0 ; port < hdev->maxchild; port++) { +for (port1 =1 ; port1 <= hdev->maxchild; port1++) {struct usb_device *udev; - udev = hdev->children [port]; + udev = hdev->children [port1-1 ];if (!udev)continue ;down (&udev->serialize); - status =__usb_suspend_device (udev, port, state); + status =__usb_suspend_device (udev, port1, state);up (&udev->serialize);if (status <0 )dev_dbg (&intf->dev,"suspend port %d --> %d\n" , - port, status); + port1, status); } intf->dev.power.power_state = state;
@@ -1904,21 +1906,21 @@ {struct usb_device *hdev =interface_to_usbdev (intf);struct usb_hub *hub =usb_get_intfdata (intf); -unsigned port; +unsigned port1;int status;if (intf->dev.power.power_state ==PM_SUSPEND_ON )return 0 ; -for (port =0 ; port < hdev->maxchild; port++) { +for (port1 =1 ; port1 <= hdev->maxchild; port1++) {struct usb_device *udev;u16 portstat, portchange; - udev = hdev->children [port]; - status =hub_port_status (hub, port, &portstat, &portchange); + udev = hdev->children [port1-1 ]; + status =hub_port_status (hub, port1, &portstat, &portchange);if (status ==0 ) {if (portchange &USB_PORT_STAT_C_SUSPEND ) { -clear_port_feature (hdev, port +1 , +clear_port_feature (hdev, port1,USB_PORT_FEAT_C_SUSPEND ); portchange &= ~USB_PORT_STAT_C_SUSPEND ; }
@@ -1932,13 +1934,13 @@continue ;down (&udev->serialize);if (portstat &USB_PORT_STAT_SUSPEND ) - status =hub_port_resume (hub, port, udev); + status =hub_port_resume (hub, port1, udev);else { status =finish_port_resume (udev);if (status <0 ) {dev_dbg (&intf->dev,"resume port %d --> %d\n" , - port +1 , status); -hub_port_logical_disconnect (hub, port); + port1, status); +hub_port_logical_disconnect (hub, port1); } }up (&udev->serialize);
@@ -1992,7 +1994,7 @@#define HUB_DEBOUNCE_STEP 25#define HUB_DEBOUNCE_STABLE 100 -static int hub_port_debounce (struct usb_hub *hub,int port) +static int hub_port_debounce (struct usb_hub *hub,int port1) {int ret;int total_time, stable_time =0 ;
@@ -2000,7 +2002,7 @@unsigned connection =0xffff ;for (total_time =0 ; ; total_time +=HUB_DEBOUNCE_STEP ) { - ret =hub_port_status (hub, port, &portstatus, &portchange); + ret =hub_port_status (hub, port1, &portstatus, &portchange);if (ret <0 )return ret;
@@ -2015,7 +2017,7 @@ }if (portchange &USB_PORT_STAT_C_CONNECTION ) { -clear_port_feature (hub->hdev, port+1 , +clear_port_feature (hub->hdev, port1,USB_PORT_FEAT_C_CONNECTION ); }
@@ -2026,7 +2028,7 @@dev_dbg (hub->intfdev,"debounce: port %d: total %dms stable %dms status 0x%x\n" , - port +1 , total_time, stable_time, portstatus); + port1, total_time, stable_time, portstatus);if (stable_time <HUB_DEBOUNCE_STABLE )return -ETIMEDOUT ;
@@ -2073,7 +2075,7 @@* pointers, it's not necessary to lock the device. */ static int -hub_port_init (struct usb_hub *hub,struct usb_device *udev,int port, +hub_port_init (struct usb_hub *hub,struct usb_device *udev,int port1,int retry_counter) {static DECLARE_MUTEX (usb_address0_sem);
@@ -2088,7 +2090,7 @@*/ if (!hdev->parent) { delay =HUB_ROOT_RESET_TIME ; -if (port +1 == hdev->bus->otg_port) +if (port1 == hdev->bus->otg_port) hdev->bus->b_hnp_enable =0 ; }
@@ -2100,7 +2102,7 @@down (&usb_address0_sem);/* Reset the device; full speed may morph to high speed */ - retval =hub_port_reset (hub, port, udev, delay); + retval =hub_port_reset (hub, port1, udev, delay);if (retval <0 )/* error or disconnect */ goto fail;/* success, speed is known */
@@ -2152,7 +2154,7 @@ }else if (udev->speed !=USB_SPEED_HIGH && hdev->speed ==USB_SPEED_HIGH ) { udev->tt = &hub->tt; - udev->ttport = port +1 ; + udev->ttport = port1; }/* Why interleave GET_DESCRIPTOR and SET_ADDRESS this way?
@@ -2202,7 +2204,7 @@ buf->bMaxPacketSize0;kfree (buf); - retval =hub_port_reset (hub, port, udev, delay); + retval =hub_port_reset (hub, port1, udev, delay);if (retval <0 )/* error or disconnect */ goto fail;if (oldspeed != udev->speed) {
@@ -2286,13 +2288,13 @@ fail:if (retval) -hub_port_disable (hub, port,0 ); +hub_port_disable (hub, port1,0 );up (&usb_address0_sem);return retval; }static void -check_highspeed (struct usb_hub *hub,struct usb_device *udev,int port) +check_highspeed (struct usb_hub *hub,struct usb_device *udev,int port1) {struct usb_qualifier_descriptor *qual;int status;
@@ -2308,7 +2310,7 @@ "connect to a high speed hub\n");/* hub LEDs are probably harder to miss than syslog */ if (hub->has_indicators) { - hub->indicator[port] =INDICATOR_GREEN_BLINK ; + hub->indicator[port1-1 ] =INDICATOR_GREEN_BLINK ;schedule_work (&hub->leds); } }
@@ -2366,7 +2368,7 @@* a firmware download) * caller already locked the hub */ -static void hub_port_connect_change (struct usb_hub *hub,int port, +static void hub_port_connect_change (struct usb_hub *hub,int port1,u16 portstatus,u16 portchange) {struct usb_device *hdev = hub->hdev;
@@ -2375,17 +2377,17 @@dev_dbg (hub_dev,"port %d, status %04x, change %04x, %s\n" , - port +1 , portstatus, portchange,portspeed (portstatus)); + port1, portstatus, portchange,portspeed (portstatus));if (hub->has_indicators) { -set_port_led (hub, port +1 ,HUB_LED_AUTO ); - hub->indicator[port] =INDICATOR_AUTO ; +set_port_led (hub, port1,HUB_LED_AUTO ); + hub->indicator[port1-1 ] =INDICATOR_AUTO ; }/* Disconnect any existing devices under this port */ -if (hdev->children[port]) -usb_disconnect (&hdev->children[port]); -clear_bit (port, hub->change_bits); +if (hdev->children[port1-1 ]) +usb_disconnect (&hdev->children[port1-1 ]); +clear_bit (port1, hub->change_bits);#ifdef CONFIG_USB_OTG /* during HNP, don't repeat the debounce */
@@ -2394,11 +2396,11 @@#endif if (portchange &USB_PORT_STAT_C_CONNECTION ) { - status =hub_port_debounce (hub, port); + status =hub_port_debounce (hub, port1);if (status <0 ) {dev_err (hub_dev,"connect-debounce failed, port %d disabled\n" , - port+1 ); + port1); goto done; } portstatus = status;
@@ -2411,7 +2413,7 @@if ((hub->descriptor->wHubCharacteristics &HUB_CHAR_LPSM ) <2 && !(portstatus & (1 <<USB_PORT_FEAT_POWER ))) -set_port_feature (hdev, port +1 ,USB_PORT_FEAT_POWER ); +set_port_feature (hdev, port1,USB_PORT_FEAT_POWER );if (portstatus &USB_PORT_STAT_ENABLE ) goto done;
@@ -2421,11 +2423,11 @@#ifdef CONFIG_USB_SUSPEND /* If something is connected, but the port is suspended, wake it up. */ if (portstatus &USB_PORT_STAT_SUSPEND ) { - status =hub_port_resume (hub, port,NULL ); + status =hub_port_resume (hub, port1,NULL );if (status <0 ) {dev_dbg (hub_dev,"can't clear suspend on port %d; %d\n" , - port+1 , status); + port1, status); goto done; } }
@@ -2437,10 +2439,11 @@/* reallocate for each attempt, since references * to the previous one can escape in various ways */ - udev =usb_alloc_dev (hdev, hdev->bus, port); + udev =usb_alloc_dev (hdev, hdev->bus, port1);if (!udev) {dev_err (hub_dev, -"couldn't allocate port %d usb_device\n" , port+1 ); +"couldn't allocate port %d usb_device\n" , + port1); goto done; }
@@ -2455,7 +2458,7 @@ }/* reset and get descriptor */ - status =hub_port_init (hub, udev, port, i); + status =hub_port_init (hub, udev, port1, i);if (status <0 ) goto loop;
@@ -2481,7 +2484,7 @@"can't connect bus-powered hub " "to this port\n");if (hub->has_indicators) { - hub->indicator[port] = + hub->indicator[port1-1 ] =INDICATOR_AMBER_BLINK ;schedule_work (&hub->leds); }
@@ -2494,7 +2497,7 @@if (udev->descriptor.bcdUSB >=0x0200 && udev->speed ==USB_SPEED_FULL && highspeed_hubs !=0 ) -check_highspeed (hub, udev, port); +check_highspeed (hub, udev, port1);/* Store the parent's children[] pointer. At this point * udev becomes globally accessible, although presumably
@@ -2511,7 +2514,7 @@if (hdev->state ==USB_STATE_NOTATTACHED ) status = -ENOTCONN ;else - hdev->children[port] = udev; + hdev->children[port1-1 ] = udev;spin_unlock_irq (&device_state_lock);/* Run it through the hoops (find a driver, etc) */
@@ -2519,7 +2522,7 @@ status =usb_new_device (udev);if (status) {spin_lock_irq (&device_state_lock); - hdev->children[port] =NULL ; + hdev->children[port1-1 ] =NULL ;spin_unlock_irq (&device_state_lock); } }
@@ -2537,7 +2540,7 @@return ; loop_disable: -hub_port_disable (hub, port,1 ); +hub_port_disable (hub, port1,1 ); loop:ep0_reinit (udev);release_address (udev);
@@ -2547,7 +2550,7 @@ } done: -hub_port_disable (hub, port,1 ); +hub_port_disable (hub, port1,1 ); }static void hub_events (void )
@@ -2623,9 +2626,9 @@ }/* deal with port status changes */ -for (i =0 ; i < hub->descriptor->bNbrPorts; i++) { +for (i =1 ; i <= hub->descriptor->bNbrPorts; i++) { connect_change =test_bit (i, hub->change_bits); -if (!test_and_clear_bit (i+1 , hub->event_bits) && +if (!test_and_clear_bit (i, hub->event_bits) && !connect_change)continue ;
@@ -2635,8 +2638,8 @@continue ;if (portchange &USB_PORT_STAT_C_CONNECTION ) { -clear_port_feature (hdev, - i +1 ,USB_PORT_FEAT_C_CONNECTION ); +clear_port_feature (hdev, i, +USB_PORT_FEAT_C_CONNECTION ); connect_change =1 ; }
@@ -2645,9 +2648,9 @@dev_dbg (hub_dev,"port %d enable change, " "status %08x\n" , - i +1 , portstatus); -clear_port_feature (hdev, - i +1 ,USB_PORT_FEAT_C_ENABLE ); + i, portstatus); +clear_port_feature (hdev, i, +USB_PORT_FEAT_C_ENABLE );/* * EM interference sometimes causes badly
@@ -2657,21 +2660,22 @@*/ if (!(portstatus &USB_PORT_STAT_ENABLE ) && !connect_change - && hdev->children[i]) { + && hdev->children[i-1 ]) {dev_err (hub_dev,"port %i " "disabled by hub (EMI?), " "re-enabling...\n" , - i +1 ); + i); connect_change =1 ; } }if (portchange &USB_PORT_STAT_C_SUSPEND ) { -clear_port_feature (hdev, i +1 , +clear_port_feature (hdev, i,USB_PORT_FEAT_C_SUSPEND ); -if (hdev->children[i]) { - ret =remote_wakeup (hdev->children[i]); +if (hdev->children[i-1 ]) { + ret =remote_wakeup (hdev-> + children[i-1 ]);if (ret <0 ) connect_change =1 ; }else {
@@ -2680,24 +2684,24 @@ }dev_dbg (hub_dev,"resume on port %d, status %d\n" , - i +1 , ret); + i, ret); }if (portchange &USB_PORT_STAT_C_OVERCURRENT ) {dev_err (hub_dev,"over-current change on port %d\n" , - i +1 ); -clear_port_feature (hdev, - i +1 ,USB_PORT_FEAT_C_OVER_CURRENT ); + i); +clear_port_feature (hdev, i, +USB_PORT_FEAT_C_OVER_CURRENT );hub_power_on (hub); }if (portchange &USB_PORT_STAT_C_RESET ) {dev_dbg (hub_dev,"reset change on port %d\n" , - i +1 ); -clear_port_feature (hdev, - i +1 ,USB_PORT_FEAT_C_RESET ); + i); +clear_port_feature (hdev, i, +USB_PORT_FEAT_C_RESET ); }if (connect_change)
@@ -2886,7 +2890,7 @@struct usb_hub *parent_hub;struct usb_device_descriptor descriptor = udev->descriptor;struct usb_hub *hub =NULL ; -int i, ret =0 , port =-1 ; +int i, ret =0 , port1 =-1 ;if (udev->state ==USB_STATE_NOTATTACHED || udev->state ==USB_STATE_SUSPENDED ) {
@@ -2903,11 +2907,11 @@for (i =0 ; i < parent_hdev->maxchild; i++)if (parent_hdev->children[i] == udev) { - port = i; + port1 = i +1 ;break ; } -if (port <0 ) { +if (port1 <0 ) {/* If this ever happens, it's very bad */ dev_err (&udev->dev,"Can't locate device's port!\n" );return -ENOENT ;
@@ -2927,7 +2931,7 @@/* ep0 maxpacket size may change; let the HCD know about it. * Other endpoints will be handled by re-enumeration. */ ep0_reinit (udev); - ret =hub_port_init (parent_hub, udev, port, i); + ret =hub_port_init (parent_hub, udev, port1, i);if (ret >=0 )break ; }
@@ -2983,6 +2987,6 @@return 0 ; re_enumerate: -hub_port_logical_disconnect (parent_hub, port); +hub_port_logical_disconnect (parent_hub, port1);return -ENODEV ; }
drivers/usb/core/usb.c +4 -4
@@ -655,7 +655,7 @@* usb_alloc_dev - usb device constructor (usbcore-internal) * @parent: hub to which device is connected; null to allocate a root hub * @bus: bus used to access the device -* @port: zero based index of port; ignored for root hubs +* @port1: one-based index of port; ignored for root hubs * Context: !in_interrupt () * * Only hub drivers (including virtual root hub drivers for host
@@ -664,7 +664,7 @@* This call may not be used in a non-sleeping context. */ struct usb_device * -usb_alloc_dev (struct usb_device *parent,struct usb_bus *bus,unsigned port) +usb_alloc_dev (struct usb_device *parent,struct usb_bus *bus,unsigned port1) {struct usb_device *dev;
@@ -711,10 +711,10 @@/* match any labeling on the hubs; it's one-based */ if (parent->devpath [0 ] =='0' )snprintf (dev->devpath,sizeof dev->devpath, -"%d" , port +1 ); +"%d" , port1);else snprintf (dev->devpath,sizeof dev->devpath, -"%s.%d" , parent->devpath, port +1 ); +"%s.%d" , parent->devpath, port1); dev->dev.parent = &parent->dev; sprintf (&dev->dev.bus_id[0], "%d-%s",
ChangeSet 1.2251, 2005/01/07 15:19:51-08:00, [email protected]
Fix up udev url in Documentation/Changes file
Documentation/Changes | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
Documentation/Changes +5 -5
@@ -223,10 +223,10 @@ version v0.99.0 or higher. Running old versions may cause problems with programs using shared memory. -Udev +udev ---- -Udev is a userspace application for populating /dev dynamically with -only entries for devices actually present. Udev replaces devfs. +udev is a userspace application for populating /dev dynamically with +only entries for devices actually present. udev replaces devfs. Networking ==========
@@ -373,9 +373,9 @@ ---------- o <http://powertweak.sourceforge.net/> -Udev +udev ---- -o <http://www.kernel.org/pub/linux/utils/kernel/hotplug/> +o <http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html> Networking **********
ChangeSet 1.2252, 2005/01/07 15:24:29-08:00, [email protected]
[PATCH] add feature-removal-schedule.txt documentation
Add Documentation/feature-removal-schedule.txt as a way to notify everyone when and what is going to be removed.
Documentation/feature-removal-schedule.txt | 17 +++++++++++++++++ 1 files changed, 17 insertions(+)
Documentation/feature-removal-schedule.txt new file +17 -0
@@ -0,0 +1,17 @@ +The following is a list of files and features that are going to be +removed in the kernel source tree. Every entry should contain what +exactly is going away, why it is happening, and who is going to be doing +the work. When the feature is removed from the kernel, it should also +be removed from this file. + +--------------------------- + +What: devfs +When: July 2005 +Files: fs/devfs/*, include/linux/devfs_fs*.h and assorted devfs + function calls throughout the kernel tree +Why: It has been unmaintained for a number of years, has unfixable + races, contains a naming policy within the kernel that is + against the LSB, and can be replaced by using udev. +Who: Greg Kroah-Hartman <[email protected]> +
ChangeSet 1.2253, 2005/01/07 15:29:10-08:00, [email protected]
[PATCH] add cpufreq info to Documentation/feature-removal-schedule.txt
Add 2.4.x cpufreq /proc and sysctl interface removal to the feature-removal-schedule.
Documentation/feature-removal-schedule.txt | 9 +++++++++ 1 files changed, 9 insertions(+)
Documentation/feature-removal-schedule.txt +9 -0
@@ -15,3 +15,12 @@ against the LSB, and can be replaced by using udev. Who: Greg Kroah-Hartman <[email protected]> +--------------------------- + +What: /proc/sys/cpu and the sysctl interface to cpufreq (2.4.x interfaces) +When: January 2005 +Files: drivers/cpufreq/: cpufreq_userspace.c, proc_intf.c + function calls throughout the kernel tree +Why: Deprecated, has been replaced/superseded by (what?).... +Who: Dominik Brodowski <[email protected]> +
Quoted 11 lines · Greg KH
ChangeSet 1.1938.444.33, 2004/12/22 13:50:21-08:00, [email protected]
[PATCH] driver core: Fix up vesafb failure probing.
bus.cfile invokes a probe callback for most devices in a list, then checks for-ENODEVreturn ("no such device"), if so it remains silent. However, some drivers (includingvesafb.c) may return-ENXIO("no such device or address"), which is indeed error -6.I shut up the warning with the attached patch, that basically ignores both
-ENODEVand-ENXIO.
NAK. We shouldn't have two return codes indicating the same error (or actually non-error in this case). Let's fix the drivers instead.
Quoted 10 lines · Christoph Hellwig
Quoted 9 lines · Greg KH
ChangeSet 1.1938.444.33, 2004/12/22 13:50:21-08:00, [email protected]
[PATCH] driver core: Fix up vesafb failure probing.
bus.cfile invokes a probe callback for most devices in a list, then checks for-ENODEVreturn ("no such device"), if so it remains silent. However, some drivers (includingvesafb.c) may return-ENXIO("no such device or address"), which is indeed error -6.
Quoted 5 lines
Quoted 2 lines
I shut up the warning with the attached patch, that basically ignores both
-ENODEVand-ENXIO.NAK. We shouldn't have two return codes indicating the same error (or actually non-error in this case). Let's fix the drivers instead.
Ok, David, care to send a patch to do so?
thanks,
greg k-h
Quoted 11 lines · Greg KH
Quoted 10 lines · Christoph Hellwig
Quoted 9 lines · Greg KH
ChangeSet 1.1938.444.33, 2004/12/22 13:50:21-08:00, [email protected]
[PATCH] driver core: Fix up vesafb failure probing.
bus.cfile invokes a probe callback for most devices in a list, then checks for-ENODEVreturn ("no such device"), if so it remains silent. However, some drivers (includingvesafb.c) may return-ENXIO("no such device or address"), which is indeed error -6.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I shut up the warning with the attached patch, that basically ignores both
-ENODEVand-ENXIO.NAK. We shouldn't have two return codes indicating the same error (or actually non-error in this case). Let's fix the drivers instead.
Ok, David, care to send a patch to do so?
The above would be the patch I posted here
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=125890
the reason I went for the lazy approach is mainly that I tried to look into the usage of -ENXIO vs -ENODEV, but just grepping in drivers/video/*.c turned out to be confusing rather than enlightening... should *all* -ENXIO be converted into -ENODEV ?