On Thu, Jun 07, 2001 at 11:21:11AM -0400, Pavel Roskin wrote:
> I've made a patch for devfs support in USB scanners (against 2.4.5-ac9).
> It can be found here:
>
> http://www.red-bean.com/~proski/linux/scanner-devfs.diff
It looks almost like the one I sent a few weeks ago. :) Hopefully this
one will get picked up.. BTW, it sort of looks like yours misses a few
things, look at the attached.. (I basically took what printer.c did and
moved it into scanner.[ch]
--
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)
+ err("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, /* ... */};