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,
static const struct dvb_device dvbdev_template = {
.users = ~0,
.writers = 1,
.readers = (~0)-1,
.fops = &dvb_frontend_fops,
.kernel_ioctl = dvb_frontend_ioctl
};
......
......@@ -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;
......
......@@ -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,
......
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