On Thu, Jun 07, 2001 at 04:46:11PM -0700, Greg KH wrote:
> On Thu, Jun 07, 2001 at 04:42:45PM -0700, Tom Rini wrote:
> >
> > I changed that in the version I use but forgot to do that here as well,
> > sorry. Want me to re-sent w/o this or can you just edit it out? It would
> > be nice if this made it upstream :)
>
> That's up to the current maintainer of the USB scanner driver, not me :)
Good point. David, the attached is vs 2.4.3ish but should apply cleanly to
anything later then that. It adds devfs support to the USB scanner driver,
and only prints as a debug msg if this failed so it shouldn't create any
noise on !devfs systems.
--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/
===== scanner.c 1.4 vs edited =====
--- 1.4/drivers/usb/scanner.c Fri Apr 20 10:17:25 2001
+++ edited/scanner.c Mon May 14 14:29:50 2001
@@ -362,7 +362,7 @@
}
scn = p_scn_table[scn_minor];
-
+ devfs_unregister(scn->devfs);
scn->isopen = 0;
file->private_data = NULL;
@@ -579,6 +579,17 @@
return ret ? ret : bytes_read;
}
+static struct
+file_operations usb_scanner_fops = {
+ read: read_scanner,
+ write: write_scanner,
+#ifdef SCN_IOCTL
+ ioctl: ioctl_scanner,
+#endif /* SCN_IOCTL */
+ open: open_scanner,
+ release: close_scanner,
+};
+
static void *
probe_scanner(struct usb_device *dev, unsigned int ifnum,
const struct usb_device_id *id)
@@ -594,6 +605,7 @@
char valid_device = 0;
char have_bulk_in, have_bulk_out, have_intr;
+ char name[10];
if (vendor != -1 && product != -1) {
info("probe_scanner: User specified USB scanner -- Vendor:Product -
%x:%x", vendor, product);
@@ -811,6 +823,16 @@
scn->scn_minor = scn_minor;
scn->isopen = 0;
+ sprintf(name, "scanner%d", scn->scn_minor);
+
+ scn->devfs = devfs_register(usb_devfs_handle, name,
+ DEVFS_FL_DEFAULT, USB_MAJOR,
+ SCN_BASE_MNR + scn->scn_minor,
+ S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP |
+ S_IWGRP | S_IROTH, &usb_scanner_fops, NULL);
+ if (scn->devfs == NULL)
+ dbg("scanner%d: device node registration failed", scn_minor);
+
init_MUTEX(&(scn->gen_lock));
return p_scn_table[scn_minor] = scn;
@@ -832,6 +854,7 @@
kfree(scn->obuf);
dbg("disconnect_scanner: De-allocating minor:%d", scn->scn_minor);
+ devfs_unregister(scn->devfs);
p_scn_table[scn->scn_minor] = NULL;
kfree (scn);
}
@@ -914,17 +937,6 @@
return 0;
}
#endif /* SCN_IOCTL */
-
-static struct
-file_operations usb_scanner_fops = {
- read: read_scanner,
- write: write_scanner,
-#ifdef SCN_IOCTL
- ioctl: ioctl_scanner,
-#endif /* SCN_IOCTL */
- open: open_scanner,
- release: close_scanner,
-};
static struct
usb_driver scanner_driver = {
===== scanner.h 1.3 vs edited =====
--- 1.3/drivers/usb/scanner.h Mon Mar 5 04:29:01 2001
+++ edited/scanner.h Mon May 14 14:29:50 2001
@@ -31,6 +31,7 @@
#include <linux/ioctl.h>
#include <linux/sched.h>
#include <linux/smp_lock.h>
+#include <linux/devfs_fs_kernel.h>
// #define DEBUG
@@ -168,6 +169,7 @@
struct scn_usb_data {
struct usb_device *scn_dev;
+ devfs_handle_t devfs; /* devfs device */
struct urb scn_irq;
unsigned int ifnum; /* Interface number of the USB device */
kdev_t scn_minor; /* Scanner minor - used in disconnect() */
@@ -180,6 +182,8 @@
struct semaphore gen_lock; /* lock to prevent concurrent reads or writes */
unsigned int rd_nak_timeout; /* Seconds to wait before read() timeout. */
};
+
+extern devfs_handle_t usb_devfs_handle;
static struct scn_usb_data *p_scn_table[SCN_MAX_MNR] = { NULL, /* ... */};