Commit e8d1d9de authored by Michael Hunold's avatar Michael Hunold Committed by Linus Torvalds

[PATCH] multiple device *read* opens support

 - allow multiple read device opens
parent 38beb0c0
...@@ -870,6 +870,7 @@ dvb_register_frontend (int (*ioctl) (struct dvb_frontend *frontend, ...@@ -870,6 +870,7 @@ dvb_register_frontend (int (*ioctl) (struct dvb_frontend *frontend,
static const struct dvb_device dvbdev_template = { static const struct dvb_device dvbdev_template = {
.users = ~0, .users = ~0,
.writers = 1, .writers = 1,
.readers = (~0)-1,
.fops = &dvb_frontend_fops, .fops = &dvb_frontend_fops,
.kernel_ioctl = dvb_frontend_ioctl .kernel_ioctl = dvb_frontend_ioctl
}; };
......
...@@ -112,7 +112,11 @@ int dvb_generic_open(struct inode *inode, struct file *file) ...@@ -112,7 +112,11 @@ int dvb_generic_open(struct inode *inode, struct file *file)
if (!dvbdev->users) if (!dvbdev->users)
return -EBUSY; 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) if (!dvbdev->writers)
return -EBUSY; return -EBUSY;
dvbdev->writers--; dvbdev->writers--;
...@@ -130,8 +134,11 @@ int dvb_generic_release(struct inode *inode, struct file *file) ...@@ -130,8 +134,11 @@ int dvb_generic_release(struct inode *inode, struct file *file)
if (!dvbdev) if (!dvbdev)
return -ENODEV; return -ENODEV;
if ((file->f_flags & O_ACCMODE) != O_RDONLY) if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
dvbdev->readers++;
} else {
dvbdev->writers++; dvbdev->writers++;
}
dvbdev->users++; dvbdev->users++;
return 0; return 0;
......
...@@ -55,12 +55,18 @@ struct dvb_adapter { ...@@ -55,12 +55,18 @@ struct dvb_adapter {
struct dvb_device { struct dvb_device {
struct list_head list_head; struct list_head list_head;
struct file_operations *fops; struct file_operations *fops;
struct dvb_adapter *adapter; struct dvb_adapter *adapter;
int type; int type;
u32 id; 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 writers;
int users;
/* don't really need those !? -- FIXME: use video_usercopy */ /* don't really need those !? -- FIXME: use video_usercopy */
int (*kernel_ioctl)(struct inode *inode, struct file *file, int (*kernel_ioctl)(struct inode *inode, struct file *file,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment