Hi,

in 2.4 video_unregister_device() has lost its magic properties
breaking most USB v4l drivers. IMHO they should be converted
to delayed freeing resources just like ordinary character devices.
Here's the change for vicam.c. Joe, could you test whether it works?

        Regards
                Oliver


You can import this changeset into BK by piping this whole message to:
'| bk receive [path to repository]' or apply the patch as usual.

===================================================================


[EMAIL PROTECTED], 2003-06-27 21:50:46+02:00, [EMAIL PROTECTED]
  - adapt to changed v4l device unregistering


 vicam.c |   43 +++++++++++++++++++++++++++++++++----------
 1 files changed, 33 insertions(+), 10 deletions(-)


diff -Nru a/drivers/usb/vicam.c b/drivers/usb/vicam.c
--- a/drivers/usb/vicam.c       Fri Jun 27 21:51:42 2003
+++ b/drivers/usb/vicam.c       Fri Jun 27 21:51:42 2003
@@ -354,7 +354,8 @@
        struct semaphore busy_lock;     // guard against SMP multithreading
 
        bool is_initialized;
-       u8 open_count;
+       bool is_removed;
+       bool is_opened;
        u8 bulkEndpoint;
        bool needsDummyRead;
 
@@ -684,6 +685,7 @@
 {
        struct vicam_camera *cam =
            (struct vicam_camera *) dev->priv;
+       int intr;
        DBG("open\n");
 
        if (!cam) {
@@ -691,9 +693,11 @@
                       "vicam video_device improperly initialized");
        }
 
-       down_interruptible(&cam->busy_lock);
+       intr = down_interruptible(&cam->busy_lock);
+       if (intr)
+               return -EINTR;
 
-       if (cam->open_count > 0) {
+       if (cam->is_opened) {
                printk(KERN_INFO
                       "vicam_open called on already opened camera");
                up(&cam->busy_lock);
@@ -728,7 +732,7 @@
        set_camera_power(cam, 1);
 
        cam->needsDummyRead = 1;
-       cam->open_count++;
+       cam->is_opened = 1;
 
        up(&cam->busy_lock);
 
@@ -739,9 +743,13 @@
 vicam_close(struct video_device *dev)
 {
        DBG("close\n");
-       set_camera_power((struct vicam_camera *) dev->priv, 0);
+       struct vicam_camera *cam = (struct vicam_camera *) dev->priv;
 
-       ((struct vicam_camera *) dev->priv)->open_count--;
+       set_camera_power(cam, 0);
+       if (cam->is_removed)
+               vicam_purge(cam);
+       else
+               cam->is_opened = 0;
 }
 
 inline int pin(int x)
@@ -752,7 +760,7 @@
 inline void writepixel(char *rgb, int Y, int Cr, int Cb)
 {
        Y = 1160 * (Y - 16);
-       
+
        rgb[2] = pin( ( ( Y + ( 1594 * Cr ) ) + 500 ) / 1300 );
        rgb[1] = pin( ( ( Y - (  392 * Cb ) - ( 813 * Cr ) ) + 500 ) / 1000 );
        rgb[0] = pin( ( ( Y + ( 2017 * Cb ) ) + 500 ) / 900 );
@@ -919,6 +927,7 @@
                 unsigned long count, int noblock)
 {
        struct vicam_camera *cam = dev->priv;
+       int intr;
        DBG("read %d bytes.\n", (int) count);
 
        if (!buf)
@@ -955,7 +964,9 @@
                }
        }
 
-       down_interruptible(&cam->busy_lock);
+       intr = down_interruptible(&cam->busy_lock);
+       if (intr)
+               return -EINTR;
 
        if (cam->needsDummyRead) {
                read_frame(cam, 0);
@@ -1286,10 +1297,10 @@
        return cam;
 }
 
+
 static void
-vicam_disconnect(struct usb_device *dev, void *ptr)
+vicam_purge(struct vicam_camera *cam)
 {
-       struct vicam_camera *cam = ptr;
        video_unregister_device(&cam->vdev);
 
 #ifdef CONFIG_PROC_FS
@@ -1305,6 +1316,18 @@
        kfree(cam);
 
        printk(KERN_DEBUG "ViCam-based WebCam disconnected\n");
+}
+
+static void
+vicam_disconnect(struct usb_device *dev, void *ptr)
+{
+       struct vicam_camera *cam = ptr;
+
+       if (cam->is_opened) {
+               cam->is_removed = 1;
+       } else {
+               vicam_purge(cam);
+       }
 }
 
 /*

===================================================================


This BitKeeper patch contains the following changesets:
1.1103
## Wrapped with gzip_uu ##


begin 664 bkpatch13454
M'XL([EMAIL PROTECTED];8_:1A#^[/T5(T6JCDN`??$+YL3IVA"EJ%%[NB:[EMAIL PROTECTED]
M>P#WC-=:VZ!3N/^>V35W]!HN:JL$L`8\SSP[\\QC\0(^U&C&GB[R+1KV`G[6
M=3/VZ/NFS;`<E-C>MIN!-BO*W6A-N>%:;W#8%0S?&\1ZV-:+;9ZAECXCV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````
`
end



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to