patch-2.4.10 linux/drivers/usb/dc2xx.c

Next file: linux/drivers/usb/devices.c
Previous file: linux/drivers/usb/dabusb.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.9/linux/drivers/usb/dc2xx.c linux/drivers/usb/dc2xx.c
@@ -63,6 +63,7 @@
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/module.h>
+#include <linux/devfs_fs_kernel.h>
 
 #ifdef CONFIG_USB_DEBUG
 	#define DEBUG
@@ -72,6 +73,9 @@
 #include <linux/usb.h>
 
 
+/* /dev/usb dir. */
+extern devfs_handle_t usb_devfs_handle;			
+
 /*
  * Version Information
  */
@@ -137,11 +141,12 @@
 	/* this is non-null iff the device is open */
 	char			*buf;		/* buffer for I/O */
 
+	devfs_handle_t		devfs;		/* devfs device */
+
 	/* always valid */
 	wait_queue_head_t	wait;		/* for timed waits */
 };
 
-
 /* Support multiple cameras, possibly of different types.  */
 static struct camera_state *minor_data [MAX_CAMERAS];
 
@@ -368,8 +373,10 @@
 	struct usb_interface_descriptor	*interface;
 	struct usb_endpoint_descriptor	*endpoint;
 	int				direction, ep;
+	char name[8];
 	struct camera_state		*camera = NULL;
 
+
 	/* these have one config, one interface */
 	if (dev->descriptor.bNumConfigurations != 1
 			|| dev->config[0].bNumInterfaces != 1) {
@@ -446,6 +453,15 @@
 
 	camera->dev = dev;
 	usb_inc_dev_use (dev);
+
+	/* If we have devfs, register the device */
+	sprintf(name, "dc2xx%d", camera->subminor);
+	camera->devfs = devfs_register(usb_devfs_handle, name,
+				       DEVFS_FL_DEFAULT, USB_MAJOR,
+				       USB_CAMERA_MINOR_BASE + camera->subminor,
+				       S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP |
+				       S_IWGRP, &usb_camera_fops, NULL);
+
 	goto bye;
 
 error:
@@ -465,6 +481,8 @@
 	down (&state_table_mutex);
 	down (&camera->sem);
 
+	devfs_unregister(camera->devfs); 
+
 	/* If camera's not opened, we can clean up right away.
 	 * Else apps see a disconnect on next I/O; the release cleans.
 	 */
@@ -513,4 +531,5 @@
 
 MODULE_AUTHOR( DRIVER_AUTHOR );
 MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_LICENSE("GPL");
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)