[PATCH] cpia 2.4.20-rc2 fix camera registration bug introduced in 2.4.13

From: Duncan Haldane (f.duncan.m.haldane@worldnet.att.net)
Date: Mon Nov 18 2002 - 20:42:10 EST


Hi
I'm the cpia driver maintainer.
If it is still possible to get this small patch into 2.4.20...it would be good.

Perhaps Alan could suggest to Marcelo to include this in 2.4.20?

It fixes a bug that someone inadvertently introduced into the cpia driver when
doing spin_locking changes in 2.4.13. (only a local copy of the camera list
was modified after that bug was introduced). This fix restores the pre-2.4.13
behavior. (The cam list will be implementation will be replaced by LIST_HEAD()
in the future).

An incorrectly-placed spin_unlock() is also moved, as is a request_module().
(The incorrect spin_unlock placement caused a core dump in 2.5.4x. when
the cpia_pp module was unloaded, I don't know if it did bad things in 2.4.x)

Duncan Haldane

(patch is attached as well)
diff -uNr linux-2.4.20-rc2/drivers/media/video/cpia.c
linux-2.4.20-rc2-cpia_fix/drivers/media/video/cpia.c
--- linux-2.4.20-rc2/drivers/media/video/cpia.c Sun Nov 10 11:34:28 2002
+++ linux-2.4.20-rc2-cpia_fix/drivers/media/video/cpia.c Mon Nov 18
16:43:37 2002
@@ -3313,9 +3313,6 @@
        proc_cpia_create();
 #endif
 
-#ifdef CONFIG_VIDEO_CPIA_PP
- cpia_pp_init();
-#endif
 #ifdef CONFIG_KMOD
 #ifdef CONFIG_VIDEO_CPIA_PP_MODULE
        request_module("cpia_pp");
@@ -3325,6 +3322,10 @@
        request_module("cpia_usb");
 #endif
 #endif /* CONFIG_KMOD */
+
+#ifdef CONFIG_VIDEO_CPIA_PP
+ cpia_pp_init();
+#endif
 #ifdef CONFIG_VIDEO_CPIA_USB
        cpia_usb_init();
 #endif
diff -uNr linux-2.4.20-rc2/drivers/media/video/cpia.h
linux-2.4.20-rc2-cpia_fix/drivers/media/video/cpia.h
--- linux-2.4.20-rc2/drivers/media/video/cpia.h Sun Nov 10 11:34:28 2002
+++ linux-2.4.20-rc2-cpia_fix/drivers/media/video/cpia.h Mon Nov 18
16:43:38 2002
@@ -400,15 +400,20 @@
       (p)&0x80?1:0, (p)&0x40?1:0, (p)&0x20?1:0, (p)&0x10?1:0,\
         (p)&0x08?1:0, (p)&0x04?1:0, (p)&0x02?1:0, (p)&0x01?1:0);
 
-static inline void cpia_add_to_list(struct cam_data* l, struct cam_data* drv)
+static inline void cpia_add_to_list(struct cam_data** l, struct cam_data**
drv_p)
 {
- drv->next = l;
- drv->previous = &l;
- l = drv;
+ struct cam_data* drv;
+ drv = *drv_p;
+ drv->next = *l;
+ drv->previous = l;
+ *l = drv;
 }
 
-static inline void cpia_remove_from_list(struct cam_data* drv)
+
+static inline void cpia_remove_from_list(struct cam_data** drv_p)
 {
+ struct cam_data* drv;
+ drv = *drv_p;
        if (drv->previous != NULL) {
                if (drv->next != NULL)
                        drv->next->previous = drv->previous;
diff -uNr linux-2.4.20-rc2/drivers/media/video/cpia_pp.c
linux-2.4.20-rc2-cpia_fix/drivers/media/video/cpia_pp.c
--- linux-2.4.20-rc2/drivers/media/video/cpia_pp.c Sun Nov 10 11:34:28 2002
+++ linux-2.4.20-rc2-cpia_fix/drivers/media/video/cpia_pp.c Mon Nov 18
16:43:38 2002
@@ -566,7 +566,7 @@
                return -ENXIO;
        }
        spin_lock( &cam_list_lock_pp );
- cpia_add_to_list(cam_list, cpia);
+ cpia_add_to_list(&cam_list, &cpia);
        spin_unlock( &cam_list_lock_pp );
 
        return 0;
@@ -580,8 +580,7 @@
        for(cpia = cam_list; cpia != NULL; cpia = cpia->next) {
                struct pp_cam_entry *cam = cpia->lowlevel_data;
                if (cam && cam->port->number == port->number) {
- cpia_remove_from_list(cpia);
- spin_unlock( &cam_list_lock_pp );
+ cpia_remove_from_list(&cpia);
                        cpia_unregister_camera(cpia);
                        
                        if(cam->open_count > 0) {
@@ -595,6 +594,7 @@
                        break;
                }
        }
+ spin_unlock( &cam_list_lock_pp );
 }
 
 static void cpia_pp_attach (struct parport *port)
diff -uNr linux-2.4.20-rc2/drivers/media/video/cpia_usb.c
linux-2.4.20-rc2-cpia_fix/drivers/media/video/cpia_usb.c
--- linux-2.4.20-rc2/drivers/media/video/cpia_usb.c Sun Nov 10 11:34:28 2002
+++ linux-2.4.20-rc2-cpia_fix/drivers/media/video/cpia_usb.c Mon Nov 18
16:43:39 2002
@@ -540,7 +540,7 @@
        }
 
        spin_lock( &cam_list_lock_usb );
- cpia_add_to_list(cam_list, cam);
+ cpia_add_to_list(&cam_list, &cam);
        spin_unlock( &cam_list_lock_usb );
 
        return cam;
@@ -587,7 +587,7 @@
        struct usb_cpia *ucpia = (struct usb_cpia *) cam->lowlevel_data;
   
        spin_lock( &cam_list_lock_usb );
- cpia_remove_from_list(cam);
+ cpia_remove_from_list(&cam);
        spin_unlock( &cam_list_lock_usb );
        
        /* Don't even try to reset the altsetting if we're disconnected */

----------------------------------
E-Mail: Duncan Haldane <f.duncan.m.haldane@worldnet.att.net>
Date: 18-Nov-2002
Time: 16:52:46

This message was sent by XFMail
----------------------------------



End of MIME message
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Nov 23 2002 - 22:00:26 EST