]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] multiple device *read* opens support
authorMichael Hunold <hunold@linuxtv.org>
Wed, 8 Oct 2003 01:47:02 +0000 (18:47 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Wed, 8 Oct 2003 01:47:02 +0000 (18:47 -0700)
 - allow multiple read device opens

drivers/media/dvb/dvb-core/dvb_frontend.c
drivers/media/dvb/dvb-core/dvbdev.c
drivers/media/dvb/dvb-core/dvbdev.h

index fc4c01309c80f1b04bd4cfd38840ac1e09faa726..f5e38f1e1ba2614b0a8d9df163bb230b224badaa 100644 (file)
@@ -870,6 +870,7 @@ dvb_register_frontend (int (*ioctl) (struct dvb_frontend *frontend,
        static const struct dvb_device dvbdev_template = {
                .users = ~0,
                .writers = 1,
+               .readers = (~0)-1,
                .fops = &dvb_frontend_fops,
                .kernel_ioctl = dvb_frontend_ioctl
        };
index 77ee97465c78611a7184303682d8972a7e3c0905..22dcdcb7dc0532c85767ec0073e8cc9cd78ec7c3 100644 (file)
@@ -112,7 +112,11 @@ int dvb_generic_open(struct inode *inode, struct file *file)
        if (!dvbdev->users)
                 return -EBUSY;
 
-       if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
+       if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
+                if (!dvbdev->readers)
+                       return -EBUSY;
+               dvbdev->readers--;
+       } else {
                 if (!dvbdev->writers)
                        return -EBUSY;
                dvbdev->writers--;
@@ -130,8 +134,11 @@ int dvb_generic_release(struct inode *inode, struct file *file)
        if (!dvbdev)
                 return -ENODEV;
 
-       if ((file->f_flags & O_ACCMODE) != O_RDONLY)
+       if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
+               dvbdev->readers++;
+       } else {
                dvbdev->writers++;
+       }
 
        dvbdev->users++;
        return 0;
index 137a8dd4d04258a8dcd69da38a6093cc30b8fb91..92963f90f359f8ea8c0e14d3141063a2b95299e6 100644 (file)
@@ -55,12 +55,18 @@ struct dvb_adapter {
 struct dvb_device {
        struct list_head list_head;
        struct file_operations *fops;
        struct dvb_adapter *adapter;
        int type;
        u32 id;
 
-       int users;
+       /* in theory, 'users' can vanish now,
+          but I don't want to change too much now... */
+       int readers;
        int writers;
+       int users;
 
         /* don't really need those !? -- FIXME: use video_usercopy  */
         int (*kernel_ioctl)(struct inode *inode, struct file *file,