1 Index: linux-2.6.25.4/drivers/usb/host/adm5120.h
2 ===================================================================
3 --- linux-2.6.25.4.orig/drivers/usb/host/adm5120.h
4 +++ linux-2.6.25.4/drivers/usb/host/adm5120.h
5 @@ -431,6 +431,13 @@ struct admhcd {
6 #define OHCI_QUIRK_BE_MMIO 0x10 /* BE registers */
7 #define OHCI_QUIRK_ZFMICRO 0x20 /* Compaq ZFMicro chipset*/
8 // there are also chip quirks/bugs in init logic
11 + struct dentry *debug_dir;
12 + struct dentry *debug_async;
13 + struct dentry *debug_periodic;
14 + struct dentry *debug_registers;
18 /* convert between an hcd pointer and the corresponding ahcd_hcd */
19 Index: linux-2.6.25.4/drivers/usb/host/adm5120-hcd.c
20 ===================================================================
21 --- linux-2.6.25.4.orig/drivers/usb/host/adm5120-hcd.c
22 +++ linux-2.6.25.4/drivers/usb/host/adm5120-hcd.c
24 #include <linux/dma-mapping.h>
25 #include <linux/dmapool.h>
26 #include <linux/reboot.h>
27 +#include <linux/debugfs.h>
31 @@ -799,6 +800,14 @@ static int __init admhc_hcd_mod_init(voi
32 pr_info("%s: block sizes: ed %Zd td %Zd\n", hcd_name,
33 sizeof (struct ed), sizeof (struct td));
36 + admhc_debug_root = debugfs_create_dir("admhc", NULL);
37 + if (!admhc_debug_root) {
43 #ifdef PLATFORM_DRIVER
44 ret = platform_driver_register(&PLATFORM_DRIVER);
46 @@ -811,6 +820,12 @@ static int __init admhc_hcd_mod_init(voi
47 platform_driver_unregister(&PLATFORM_DRIVER);
52 + debugfs_remove(admhc_debug_root);
53 + admhc_debug_root = NULL;
58 module_init(admhc_hcd_mod_init);
59 @@ -818,6 +833,9 @@ module_init(admhc_hcd_mod_init);
60 static void __exit admhc_hcd_mod_exit(void)
62 platform_driver_unregister(&PLATFORM_DRIVER);
64 + debugfs_remove(admhc_debug_root);
67 module_exit(admhc_hcd_mod_exit);
69 Index: linux-2.6.25.4/drivers/usb/host/adm5120-dbg.c
70 ===================================================================
71 --- linux-2.6.25.4.orig/drivers/usb/host/adm5120-dbg.c
72 +++ linux-2.6.25.4/drivers/usb/host/adm5120-dbg.c
73 @@ -390,6 +390,42 @@ static inline void remove_debug_files(st
77 +static int debug_async_open(struct inode *, struct file *);
78 +static int debug_periodic_open(struct inode *, struct file *);
79 +static int debug_registers_open(struct inode *, struct file *);
80 +static int debug_async_open(struct inode *, struct file *);
81 +static ssize_t debug_output(struct file*, char __user*, size_t, loff_t*);
82 +static int debug_close(struct inode *, struct file *);
84 +static const struct file_operations debug_async_fops = {
85 + .owner = THIS_MODULE,
86 + .open = debug_async_open,
87 + .read = debug_output,
88 + .release = debug_close,
90 +static const struct file_operations debug_periodic_fops = {
91 + .owner = THIS_MODULE,
92 + .open = debug_periodic_open,
93 + .read = debug_output,
94 + .release = debug_close,
96 +static const struct file_operations debug_registers_fops = {
97 + .owner = THIS_MODULE,
98 + .open = debug_registers_open,
99 + .read = debug_output,
100 + .release = debug_close,
103 +static struct dentry *admhc_debug_root;
105 +struct debug_buffer {
106 + ssize_t (*fill_func)(struct debug_buffer *); /* fill method */
107 + struct device *dev;
108 + struct mutex mutex; /* protect filling of buffer */
109 + size_t count; /* number of characters filled into buffer */
114 show_list(struct admhcd *ahcd, char *buf, size_t count, struct ed *ed)
116 @@ -455,8 +491,7 @@ show_list(struct admhcd *ahcd, char *buf
121 -show_async(struct device *dev, struct device_attribute *attr, char *buf)
122 +static ssize_t fill_async_buffer(struct debug_buffer *buf)
126 @@ -464,24 +499,22 @@ show_async(struct device *dev, struct de
130 - bus = dev_get_drvdata(dev);
131 + bus = dev_get_drvdata(buf->dev);
132 hcd = bus_to_hcd(bus);
133 ahcd = hcd_to_admhcd(hcd);
135 /* display control and bulk lists together, for simplicity */
136 spin_lock_irqsave(&ahcd->lock, flags);
137 - temp = show_list(ahcd, buf, PAGE_SIZE, ahcd->ed_head);
138 + temp = show_list(ahcd, buf->page, buf->count, ahcd->ed_head);
139 spin_unlock_irqrestore(&ahcd->lock, flags);
143 -static DEVICE_ATTR(async, S_IRUGO, show_async, NULL);
146 #define DBG_SCHED_LIMIT 64
149 -show_periodic(struct device *dev, struct device_attribute *attr, char *buf)
150 +static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
154 @@ -496,10 +529,10 @@ show_periodic(struct device *dev, struct
158 - bus = dev_get_drvdata(dev);
159 + bus = dev_get_drvdata(buf->dev);
160 hcd = bus_to_hcd(bus);
161 ahcd = hcd_to_admhcd(hcd);
166 temp = scnprintf(next, size, "size = %d\n", NUM_INTS);
167 @@ -574,13 +607,11 @@ show_periodic(struct device *dev, struct
169 return PAGE_SIZE - size;
171 -static DEVICE_ATTR(periodic, S_IRUGO, show_periodic, NULL);
174 #undef DBG_SCHED_LIMIT
177 -show_registers(struct device *dev, struct device_attribute *attr, char *buf)
178 +static ssize_t fill_registers_buffer(struct debug_buffer *buf)
182 @@ -591,11 +622,11 @@ show_registers(struct device *dev, struc
186 - bus = dev_get_drvdata(dev);
187 + bus = dev_get_drvdata(buf->dev);
188 hcd = bus_to_hcd(bus);
189 ahcd = hcd_to_admhcd(hcd);
195 spin_lock_irqsave(&ahcd->lock, flags);
196 @@ -656,27 +687,154 @@ done:
197 spin_unlock_irqrestore(&ahcd->lock, flags);
198 return PAGE_SIZE - size;
200 -static DEVICE_ATTR(registers, S_IRUGO, show_registers, NULL);
203 -static inline void create_debug_files (struct admhcd *ahcd)
204 +static struct debug_buffer *alloc_buffer(struct device *dev,
205 + ssize_t (*fill_func)(struct debug_buffer *))
207 - struct device *dev = admhcd_to_hcd(ahcd)->self.dev;
209 + struct debug_buffer *buf;
211 - retval = device_create_file(dev, &dev_attr_async);
212 - retval = device_create_file(dev, &dev_attr_periodic);
213 - retval = device_create_file(dev, &dev_attr_registers);
214 - admhc_dbg(ahcd, "created debug files\n");
215 + buf = kzalloc(sizeof(struct debug_buffer), GFP_KERNEL);
219 + buf->fill_func = fill_func;
220 + mutex_init(&buf->mutex);
226 +static int fill_buffer(struct debug_buffer *buf)
231 + buf->page = (char *)get_zeroed_page(GFP_KERNEL);
238 + ret = buf->fill_func(buf);
249 +static ssize_t debug_output(struct file *file, char __user *user_buf,
250 + size_t len, loff_t *offset)
252 + struct debug_buffer *buf = file->private_data;
255 + mutex_lock(&buf->mutex);
256 + if (buf->count == 0) {
257 + ret = fill_buffer(buf);
259 + mutex_unlock(&buf->mutex);
263 + mutex_unlock(&buf->mutex);
265 + ret = simple_read_from_buffer(user_buf, len, offset,
266 + buf->page, buf->count);
272 +static int debug_close(struct inode *inode, struct file *file)
274 + struct debug_buffer *buf = file->private_data;
278 + free_page((unsigned long)buf->page);
285 -static inline void remove_debug_files (struct admhcd *ahcd)
286 +static int debug_async_open(struct inode *inode, struct file *file)
288 - struct device *dev = admhcd_to_hcd(ahcd)->self.dev;
289 + file->private_data = alloc_buffer(inode->i_private, fill_async_buffer);
291 + return file->private_data ? 0 : -ENOMEM;
294 +static int debug_periodic_open(struct inode *inode, struct file *file)
296 + file->private_data = alloc_buffer(inode->i_private,
297 + fill_periodic_buffer);
299 + return file->private_data ? 0 : -ENOMEM;
302 - device_remove_file(dev, &dev_attr_async);
303 - device_remove_file(dev, &dev_attr_periodic);
304 - device_remove_file(dev, &dev_attr_registers);
305 +static int debug_registers_open(struct inode *inode, struct file *file)
307 + file->private_data = alloc_buffer(inode->i_private,
308 + fill_registers_buffer);
310 + return file->private_data ? 0 : -ENOMEM;
313 +static inline void create_debug_files(struct admhcd *ahcd)
315 + struct usb_bus *bus = &admhcd_to_hcd(ahcd)->self;
316 + struct device *dev = bus->dev;
318 + ahcd->debug_dir = debugfs_create_dir(bus->bus_name, admhc_debug_root);
319 + if (!ahcd->debug_dir)
322 + ahcd->debug_async = debugfs_create_file("async", S_IRUGO,
323 + ahcd->debug_dir, dev,
324 + &debug_async_fops);
325 + if (!ahcd->debug_async)
328 + ahcd->debug_periodic = debugfs_create_file("periodic", S_IRUGO,
329 + ahcd->debug_dir, dev,
330 + &debug_periodic_fops);
331 + if (!ahcd->debug_periodic)
332 + goto periodic_error;
334 + ahcd->debug_registers = debugfs_create_file("registers", S_IRUGO,
335 + ahcd->debug_dir, dev,
336 + &debug_registers_fops);
337 + if (!ahcd->debug_registers)
338 + goto registers_error;
340 + admhc_dbg(ahcd, "created debug files\n");
344 + debugfs_remove(ahcd->debug_periodic);
346 + debugfs_remove(ahcd->debug_async);
348 + debugfs_remove(ahcd->debug_dir);
350 + ahcd->debug_periodic = NULL;
351 + ahcd->debug_async = NULL;
352 + ahcd->debug_dir = NULL;
355 +static inline void remove_debug_files(struct admhcd *ahcd)
357 + debugfs_remove(ahcd->debug_registers);
358 + debugfs_remove(ahcd->debug_periodic);
359 + debugfs_remove(ahcd->debug_async);
360 + debugfs_remove(ahcd->debug_dir);