ChangeSet 1.858, 2002/11/14 13:47:36-08:00, david-b@pacbell.net

[PATCH] ohci-hcd, driverfs files work again, less debug output

This fixes a problem from Chris' patch, letting the driverfs files
work again.  The root cause was a duplicate "parent_dev" field,
now gone.  This also adds minor cleanup in the hcd glue, renaming
the value being duplicated as the "controller" that the HCD is
driving.  (A "parent" should rarely be used, but the "controller"
has reasonable uses all over the place ... like in dev_dbg calls!)
It's initted by the PCI bus glue, or by the SA-1111 bus glue.

Also makes some OHCI debug messages appear only when VERBOSE debug
is (manually) enabled.  This was self-defense, otherwise running
the link/unlink "usbtest" cases could fill up the log filesystem
(with debug enabled).


diff -Nru a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
--- a/drivers/usb/core/hcd-pci.c	Thu Nov 14 14:11:57 2002
+++ b/drivers/usb/core/hcd-pci.c	Thu Nov 14 14:11:57 2002
@@ -138,6 +138,7 @@
 	hcd->pdev = dev;
 	hcd->self.bus_name = dev->slot_name;
 	hcd->product_desc = dev->name;
+	hcd->controller = &dev->dev;
 
 	if ((retval = hcd_buffer_create (hcd)) != 0) {
 clean_3:
diff -Nru a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
--- a/drivers/usb/core/hcd.h	Thu Nov 14 14:11:57 2002
+++ b/drivers/usb/core/hcd.h	Thu Nov 14 14:11:57 2002
@@ -74,10 +74,10 @@
 	struct hc_driver	*driver;	/* hw-specific hooks */
 	int			irq;		/* irq allocated */
 	void			*regs;		/* device memory/io */
+	struct device		*controller;	/* handle to hardware */
 
 	/* a few non-PCI controllers exist, mostly for OHCI */
 	struct pci_dev		*pdev;		/* pci is typical */
-	struct device		*parent;	/* parent device driver */
 #ifdef	CONFIG_PCI
 	int			region;		/* pci region for regs */
 	u32			pci_state [16];	/* for PM state save */
diff -Nru a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
--- a/drivers/usb/host/ohci-dbg.c	Thu Nov 14 14:11:57 2002
+++ b/drivers/usb/host/ohci-dbg.c	Thu Nov 14 14:11:57 2002
@@ -24,7 +24,8 @@
 /* debug| print the main components of an URB     
  * small: 0) header + data packets 1) just header
  */
-static void urb_print (struct urb * urb, char * str, int small)
+static void __attribute__((unused))
+urb_print (struct urb * urb, char * str, int small)
 {
 	unsigned int pipe= urb->pipe;
 	
@@ -204,10 +205,6 @@
 
 	// dumps some of the state we know about
 	ohci_dump_status (controller);
-#ifdef OHCI_VERBOSE_DEBUG
-	if (verbose)
-		ohci_dump_periodic (controller, "hcca");
-#endif
 	if (controller->hcca)
 		dbg ("hcca frame #%04x", controller->hcca->frame_no);
 	ohci_dump_roothub (controller, 1);
@@ -510,16 +507,16 @@
 
 static inline void create_debug_files (struct ohci_hcd *bus)
 {
-	device_create_file (bus->hcd.parent, &dev_attr_async);
-	device_create_file (bus->hcd.parent, &dev_attr_periodic);
+	device_create_file (bus->hcd.controller, &dev_attr_async);
+	device_create_file (bus->hcd.controller, &dev_attr_periodic);
 	// registers
 	dbg ("%s: created debug files", bus->hcd.self.bus_name);
 }
 
 static inline void remove_debug_files (struct ohci_hcd *bus)
 {
-	device_remove_file (bus->hcd.parent, &dev_attr_async);
-	device_remove_file (bus->hcd.parent, &dev_attr_periodic);
+	device_remove_file (bus->hcd.controller, &dev_attr_async);
+	device_remove_file (bus->hcd.controller, &dev_attr_periodic);
 }
 
 #else /* empty stubs for creating those files */
diff -Nru a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
--- a/drivers/usb/host/ohci-hcd.c	Thu Nov 14 14:11:57 2002
+++ b/drivers/usb/host/ohci-hcd.c	Thu Nov 14 14:11:57 2002
@@ -271,7 +271,7 @@
 	struct ohci_hcd		*ohci = hcd_to_ohci (hcd);
 	unsigned long		flags;
 	
-#ifdef DEBUG
+#ifdef OHCI_VERBOSE_DEBUG
 	urb_print (urb, "UNLINK", 1);
 #endif		  
 
@@ -514,7 +514,7 @@
 
 	usb_connect (udev);
 	udev->speed = USB_SPEED_FULL;
-	if (usb_register_root_hub (udev, ohci->parent_dev) != 0) {
+	if (usb_register_root_hub (udev, ohci->hcd.controller) != 0) {
 		usb_free_dev (udev);
 		ohci->hcd.self.root_hub = NULL;
 		disable (ohci);
diff -Nru a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
--- a/drivers/usb/host/ohci-pci.c	Thu Nov 14 14:11:57 2002
+++ b/drivers/usb/host/ohci-pci.c	Thu Nov 14 14:11:57 2002
@@ -80,8 +80,6 @@
 	}
 	ohci->regs = hcd->regs;
 
-	ohci->parent_dev = &ohci->hcd.pdev->dev;
-
 	if (hc_reset (ohci) < 0) {
 		ohci_stop (hcd);
 		return -ENODEV;
diff -Nru a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
--- a/drivers/usb/host/ohci-q.c	Thu Nov 14 14:11:57 2002
+++ b/drivers/usb/host/ohci-q.c	Thu Nov 14 14:11:57 2002
@@ -110,10 +110,12 @@
 {
 	unsigned	i;
 
+#ifdef OHCI_VERBOSE_DEBUG
 	dbg ("%s: link %sed %p branch %d [%dus.], interval %d",
 		ohci->hcd.self.bus_name,
 		(ed->hwINFO & ED_ISO) ? "iso " : "",
 		ed, ed->branch, ed->load, ed->interval);
+#endif
 
 	for (i = ed->branch; i < NUM_INTS; i += ed->interval) {
 		struct ed	**prev = &ohci->periodic [i];
@@ -244,10 +246,12 @@
 	}	
 	ohci->hcd.self.bandwidth_allocated -= ed->load / ed->interval;
 
+#ifdef OHCI_VERBOSE_DEBUG
 	dbg ("%s: unlink %sed %p branch %d [%dus.], interval %d",
 		ohci->hcd.self.bus_name,
 		(ed->hwINFO & ED_ISO) ? "iso " : "",
 		ed, ed->branch, ed->load, ed->interval);
+#endif
 }
 
 /* unlink an ed from one of the HC chains. 
@@ -414,7 +418,6 @@
 			}
 		}
 		ed->hwINFO = info;
-
 	}
 
 done:
diff -Nru a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c
--- a/drivers/usb/host/ohci-sa1111.c	Thu Nov 14 14:11:57 2002
+++ b/drivers/usb/host/ohci-sa1111.c	Thu Nov 14 14:11:57 2002
@@ -176,7 +176,7 @@
 	hcd->irq = dev->irq[1];
 	hcd->regs = dev->mapbase;
 	hcd->pdev = SA1111_FAKE_PCIDEV;
-	hcd->parent = &dev->dev;
+	hcd->controller = &dev->dev;
 
 	retval = hcd_buffer_create (hcd);
 	if (retval != 0) {
@@ -291,8 +291,6 @@
 		return ret;
 	}
 	ohci->regs = hcd->regs;
-
-	ohci->parent_dev = hcd->parent;
 
 	if (hc_reset (ohci) < 0) {
 		ohci_stop (hcd);
diff -Nru a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h
--- a/drivers/usb/host/ohci.h	Thu Nov 14 14:11:57 2002
+++ b/drivers/usb/host/ohci.h	Thu Nov 14 14:11:57 2002
@@ -349,11 +349,6 @@
 struct ohci_hcd {
 	spinlock_t		lock;
 
-        /*
-	 * parent device
-	 */
-        struct device		*parent_dev;
-
 	/*
 	 * I/O memory used to communicate with the HC (dma-consistent)
 	 */