patch-2.3.99-pre4 linux/drivers/usb/mdc800.c

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

diff -u --recursive --new-file v2.3.99-pre3/linux/drivers/usb/mdc800.c linux/drivers/usb/mdc800.c
@@ -26,11 +26,19 @@
  * To use the Camera you must support the USB Protocoll of the camera
  * to the Kernel Node.
  * The Driver uses a misc device Node. Create it with :
- * mknod /dev/mustek c 10 171
+ * mknod /dev/mustek c 180 32
  *
  * The driver supports only one camera.
  *
  * version 0.7.1
+ * MOD_INC and MOD_DEC are changed in usb_probe to prevent load/unload
+ * problems when compiled as Module.
+ * (04/04/2000)
+ *
+ * The mdc800 driver gets assigned the USB Minor 32-47. The Registration
+ * was updated to use these values.
+ * (26/03/2000)
+ *
  * The Init und Exit Module Function are updated.
  * (01/03/2000)
  *
@@ -57,7 +65,6 @@
 #include <linux/signal.h>
 #include <linux/spinlock.h>
 #include <linux/errno.h>
-#include <linux/miscdevice.h>
 #include <linux/random.h>
 #include <linux/poll.h>
 #include <linux/init.h>
@@ -67,22 +74,22 @@
 #include <linux/usb.h>
 
 #define VERSION 		"0.7.1"
-#define RELEASE_DATE "(01/03/2000)"
+#define RELEASE_DATE "(26/03/2000)"
 
 /* Vendor and Product Information */
 #define MDC800_VENDOR_ID 	0x055f
 #define MDC800_PRODUCT_ID	0xa800
 
 /* Timeouts (msec) */
-#define TO_READ_FROM_IRQ 			4000
+#define TO_READ_FROM_IRQ 		4000
 #define TO_GET_READY				2000
-#define TO_DOWNLOAD_GET_READY			1500
-#define TO_DOWNLOAD_GET_BUSY			1500
-#define TO_WRITE_GET_READY			3000
-#define TO_DEFAULT_COMMAND			5000
+#define TO_DOWNLOAD_GET_READY	1500
+#define TO_DOWNLOAD_GET_BUSY	1500
+#define TO_WRITE_GET_READY		3000
+#define TO_DEFAULT_COMMAND		5000
 
-/* Minor Number of the device (create with mknod /dev/mustek c 10 171) */
-#define MDC800_DEVICE_MINOR 171
+/* Minor Number of the device (create with mknod /dev/mustek c 180 32) */
+#define MDC800_DEVICE_MINOR_BASE 32
 
 
 /**************************************************************************
@@ -514,11 +521,20 @@
 static int mdc800_device_open (struct inode* inode, struct file *file)
 {
 	int retval=0;
+	
+	MOD_INC_USE_COUNT;
+	
 	if (mdc800->state == NOT_CONNECTED)
+	{
+		MOD_DEC_USE_COUNT;
 		return -EBUSY;
+	}
 
 	if (mdc800->open)
+	{
+		MOD_DEC_USE_COUNT;
 		return -EBUSY;
+	}
 
 	mdc800->rw_lock=0;
 	mdc800->in_count=0;
@@ -535,10 +551,10 @@
 	if (usb_submit_urb (mdc800->irq_urb))
 	{
 		err ("request USB irq fails (submit_retval=%i urb_status=%i).",retval, mdc800->irq_urb->status);
+		MOD_DEC_USE_COUNT;
 		return -EIO;
 	}
 
-	MOD_INC_USE_COUNT;
 	mdc800->open=1;
 
 	dbg ("Mustek MDC800 device opened.");
@@ -792,21 +808,6 @@
 	Init and Cleanup this driver (Structs and types)
 ****************************************************************************/
 
-
-/*
- * USB Driver Struct for this device
- */
-static struct usb_driver mdc800_usb_driver =
-{
-	"mdc800",
-	mdc800_usb_probe,
-	mdc800_usb_disconnect,
-	{ 0,0 },
-	0,
-	0
-};
-
-
 /* File Operations of this drivers */
 static struct file_operations mdc800_device_ops =
 {
@@ -828,17 +829,22 @@
 };
 
 
+
 /*
- * The Misc Device Configuration Struct
+ * USB Driver Struct for this device
  */
-static struct miscdevice mdc800_device =
+static struct usb_driver mdc800_usb_driver =
 {
-	MDC800_DEVICE_MINOR,
-	"USB Mustek MDC800 Camera",
-	&mdc800_device_ops
+	"mdc800",
+	mdc800_usb_probe,
+	mdc800_usb_disconnect,
+	{ 0,0 },
+	&mdc800_device_ops,
+	MDC800_DEVICE_MINOR_BASE
 };
 
 
+
 /************************************************************************
 	Init and Cleanup this driver (Main Functions)
 *************************************************************************/
@@ -872,8 +878,6 @@
 	/* Register the driver */
 	if (usb_register (&mdc800_usb_driver) < 0)
 		goto cleanup_on_fail;
-	if (misc_register (&mdc800_device) < 0)
-		goto cleanup_on_misc_register_fail;
 
 	info ("Mustek Digital Camera Driver " VERSION " (MDC800)");
 	info (RELEASE_DATE " Henning Zabel <henning@uni-paderborn.de>");
@@ -882,9 +886,6 @@
 
 	/* Clean driver up, when something fails */
 
-cleanup_on_misc_register_fail:
-	usb_deregister (&mdc800_usb_driver);
-
 cleanup_on_fail:
 
 	if (mdc800 != 0)
@@ -909,7 +910,6 @@
 void __exit usb_mdc800_cleanup (void)
 {
 	usb_deregister (&mdc800_usb_driver);
-	misc_deregister (&mdc800_device);
 
 	usb_free_urb (mdc800->irq_urb);
 	usb_free_urb (mdc800->download_urb);

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