ChangeSet 1.944, 2003/01/13 13:53:41-08:00, cobra@compuserve.com

[PATCH] ohci/ehci debug updates for 2.5.56

  These two files needed to be touched after the recent changes to
DRIVER_ATTR/driver_attribute structure members in 2.5.56.  Personally,
it doesn't look to me like the size parameter should be removed, as now
users will need to hardcode PAGE_SIZE into their functions, rather than
it being passed from the place of allocation.  But I'm not familiar with
the driverfs changes, so can't really say.

These changes, or something similar, are needed to make ohci-dbg and
ehci-dbg work at all in 2.5.56.  ehci is untested, but compiles here.
I've tested the ohci changes and they appear to work.


diff -Nru a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
--- a/drivers/usb/host/ehci-dbg.c	Mon Jan 13 14:24:04 2003
+++ b/drivers/usb/host/ehci-dbg.c	Mon Jan 13 14:24:04 2003
@@ -325,7 +325,7 @@
 }
 
 static ssize_t
-show_async (struct device *dev, char *buf, size_t count, loff_t off)
+show_async (struct device *dev, char *buf)
 {
 	struct pci_dev		*pdev;
 	struct ehci_hcd		*ehci;
@@ -334,13 +334,10 @@
 	char			*next;
 	struct ehci_qh		*qh;
 
-	if (off != 0)
-		return 0;
-
 	pdev = container_of (dev, struct pci_dev, dev);
 	ehci = container_of (pci_get_drvdata (pdev), struct ehci_hcd, hcd);
 	next = buf;
-	size = count;
+	size = PAGE_SIZE;
 
 	/* dumps a snapshot of the async schedule.
 	 * usually empty except for long-term bulk reads, or head.
@@ -358,14 +355,14 @@
 	}
 	spin_unlock_irqrestore (&ehci->lock, flags);
 
-	return count - size;
+	return PAGE_SIZE - size;
 }
 static DEVICE_ATTR (async, S_IRUGO, show_async, NULL);
 
 #define DBG_SCHED_LIMIT 64
 
 static ssize_t
-show_periodic (struct device *dev, char *buf, size_t count, loff_t off)
+show_periodic (struct device *dev, char *buf)
 {
 	struct pci_dev		*pdev;
 	struct ehci_hcd		*ehci;
@@ -375,8 +372,6 @@
 	char			*next;
 	unsigned		i, tag;
 
-	if (off != 0)
-		return 0;
 	if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, SLAB_ATOMIC)))
 		return 0;
 	seen_count = 0;
@@ -384,7 +379,7 @@
 	pdev = container_of (dev, struct pci_dev, dev);
 	ehci = container_of (pci_get_drvdata (pdev), struct ehci_hcd, hcd);
 	next = buf;
-	size = count;
+	size = PAGE_SIZE;
 
 	temp = snprintf (next, size, "size = %d\n", ehci->periodic_size);
 	size -= temp;
@@ -468,14 +463,14 @@
 	spin_unlock_irqrestore (&ehci->lock, flags);
 	kfree (seen);
 
-	return count - size;
+	return PAGE_SIZE - size;
 }
 static DEVICE_ATTR (periodic, S_IRUGO, show_periodic, NULL);
 
 #undef DBG_SCHED_LIMIT
 
 static ssize_t
-show_registers (struct device *dev, char *buf, size_t count, loff_t off)
+show_registers (struct device *dev, char *buf)
 {
 	struct pci_dev		*pdev;
 	struct ehci_hcd		*ehci;
@@ -485,14 +480,11 @@
 	static char		fmt [] = "%*s\n";
 	static char		label [] = "";
 
-	if (off != 0)
-		return 0;
-
 	pdev = container_of (dev, struct pci_dev, dev);
 	ehci = container_of (pci_get_drvdata (pdev), struct ehci_hcd, hcd);
 
 	next = buf;
-	size = count;
+	size = PAGE_SIZE;
 
 	spin_lock_irqsave (&ehci->lock, flags);
 
@@ -568,7 +560,7 @@
 
 	spin_unlock_irqrestore (&ehci->lock, flags);
 
-	return count - size;
+	return PAGE_SIZE - size;
 }
 static DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL);
 
diff -Nru a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
--- a/drivers/usb/host/ohci-dbg.c	Mon Jan 13 14:24:04 2003
+++ b/drivers/usb/host/ohci-dbg.c	Mon Jan 13 14:24:04 2003
@@ -9,7 +9,7 @@
  */
  
 /*-------------------------------------------------------------------------*/
- 
+
 #ifdef DEBUG
 
 #define edstring(ed_type) ({ char *temp; \
@@ -396,24 +396,21 @@
 }
 
 static ssize_t
-show_async (struct device *dev, char *buf, size_t count, loff_t off)
+show_async (struct device *dev, char *buf)
 {
 	struct ohci_hcd		*ohci;
 	size_t			temp;
 	unsigned long		flags;
 
-	if (off != 0)
-		return 0;
-
 	ohci = dev_to_ohci(dev);
 
 	/* display control and bulk lists together, for simplicity */
 	spin_lock_irqsave (&ohci->lock, flags);
-	temp = show_list (ohci, buf, count, ohci->ed_controltail);
-	count = show_list (ohci, buf + temp, count - temp, ohci->ed_bulktail);
+	temp = show_list (ohci, buf, PAGE_SIZE, ohci->ed_controltail);
+	temp += show_list (ohci, buf + temp, PAGE_SIZE - temp, ohci->ed_bulktail);
 	spin_unlock_irqrestore (&ohci->lock, flags);
 
-	return temp + count;
+	return temp;
 }
 static DEVICE_ATTR (async, S_IRUGO, show_async, NULL);
 
@@ -421,7 +418,7 @@
 #define DBG_SCHED_LIMIT 64
 
 static ssize_t
-show_periodic (struct device *dev, char *buf, size_t count, loff_t off)
+show_periodic (struct device *dev, char *buf)
 {
 	struct ohci_hcd		*ohci;
 	struct ed		**seen, *ed;
@@ -430,15 +427,13 @@
 	char			*next;
 	unsigned		i;
 
-	if (off != 0)
-		return 0;
 	if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, SLAB_ATOMIC)))
 		return 0;
 	seen_count = 0;
 
 	ohci = dev_to_ohci(dev);
 	next = buf;
-	size = count;
+	size = PAGE_SIZE;
 
 	temp = snprintf (next, size, "size = %d\n", NUM_INTS);
 	size -= temp;
@@ -506,9 +501,10 @@
 	spin_unlock_irqrestore (&ohci->lock, flags);
 	kfree (seen);
 
-	return count - size;
+	return PAGE_SIZE - size;
 }
 static DEVICE_ATTR (periodic, S_IRUGO, show_periodic, NULL);
+
 
 #undef DBG_SCHED_LIMIT
 
