3 * (C) Copyright 1999 Randy Dunlap.
4 * (C) Copyright 1999, 2000 Thomas Sailer <sailer@ife.ee.ethz.ch>. (proc file per device)
5 * (C) Copyright 1999 Deti Fliegl (new USB architecture)
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *************************************************************
25 * 1999-12-16: Thomas Sailer <sailer@ife.ee.ethz.ch>
26 * Converted the whole proc stuff to real
27 * read methods. Now not the whole device list needs to fit
28 * into one page, only the device list for one bus.
29 * Added a poll method to /proc/bus/usb/devices, to wake
31 * 2000-01-04: Thomas Sailer <sailer@ife.ee.ethz.ch>
32 * Turned into its own filesystem
34 * $Id: drivers.c,v 1.3 2000/01/11 13:58:24 tom Exp $
39 #include <linux/usb.h>
40 #include <linux/usbdevice_fs.h>
41 #include <asm/uaccess.h>
43 /*****************************************************************/
46 * Dump usb_driver_list.
48 * We now walk the list of registered USB drivers.
50 static ssize_t usb_driver_read(struct file *file, char *buf, size_t nbytes, loff_t *ppos)
52 struct list_head *tmp = usb_driver_list.next;
53 char *page, *start, *end;
56 unsigned int pos = n, len;
62 if (!access_ok(VERIFY_WRITE, buf, nbytes))
64 if (!(page = (char*) __get_free_page(GFP_KERNEL)))
67 end = page + (PAGE_SIZE - 100);
68 for (; tmp != &usb_driver_list; tmp = tmp->next) {
69 struct usb_driver *driver = list_entry(tmp, struct usb_driver, driver_list);
70 int minor = driver->fops ? driver->minor : -1;
72 start += sprintf (start, " %s\n", driver->name);
74 start += sprintf (start, "%3d-%3d: %s\n", minor, minor + 15, driver->name);
76 start += sprintf(start, "(truncated)\n");
81 start += sprintf(start, "(none)\n");
88 if (copy_to_user(buf, page + pos, len))
93 free_page((unsigned long)page);
97 static loff_t usb_driver_lseek(struct file * file, loff_t offset, int orig)
101 file->f_pos = offset;
105 file->f_pos += offset;
116 struct file_operations usbdevfs_drivers_fops = {
117 llseek: usb_driver_lseek,
118 read: usb_driver_read,