mirror of
https://github.com/DigitalDevices/dddvb.git
synced 2023-10-10 13:37:43 +02:00
make ddbridge device access count atomic
This commit is contained in:
parent
b946de7e44
commit
aa1b5369ac
@ -3340,7 +3340,7 @@ static int ddb_release(struct inode *inode, struct file *file)
|
|||||||
{
|
{
|
||||||
struct ddb *dev = file->private_data;
|
struct ddb *dev = file->private_data;
|
||||||
|
|
||||||
dev->ddb_dev_users--;
|
atomic_inc(&dev->ddb_dev_users);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3348,9 +3348,10 @@ static int ddb_open(struct inode *inode, struct file *file)
|
|||||||
{
|
{
|
||||||
struct ddb *dev = ddbs[iminor(inode)];
|
struct ddb *dev = ddbs[iminor(inode)];
|
||||||
|
|
||||||
if (dev->ddb_dev_users)
|
if (!atomic_dec_and_test(&dev->ddb_dev_users)) {
|
||||||
|
atomic_inc(&dev->ddb_dev_users);
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
dev->ddb_dev_users++;
|
}
|
||||||
file->private_data = dev;
|
file->private_data = dev;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -4278,6 +4279,7 @@ static int ddb_device_create(struct ddb *dev)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
mutex_lock(&ddb_mutex);
|
mutex_lock(&ddb_mutex);
|
||||||
dev->nr = ddb_num;
|
dev->nr = ddb_num;
|
||||||
|
atomic_set(&dev->ddb_dev_users, 1);
|
||||||
ddbs[dev->nr] = dev;
|
ddbs[dev->nr] = dev;
|
||||||
dev->ddb_dev = device_create(&ddb_class, dev->dev,
|
dev->ddb_dev = device_create(&ddb_class, dev->dev,
|
||||||
MKDEV(ddb_major, dev->nr),
|
MKDEV(ddb_major, dev->nr),
|
||||||
|
@ -450,7 +450,7 @@ struct ddb {
|
|||||||
struct ddb_dma odma[DDB_MAX_OUTPUT];
|
struct ddb_dma odma[DDB_MAX_OUTPUT];
|
||||||
|
|
||||||
struct device *ddb_dev;
|
struct device *ddb_dev;
|
||||||
u32 ddb_dev_users;
|
atomic_t ddb_dev_users;
|
||||||
u32 nr;
|
u32 nr;
|
||||||
u8 iobuf[1028];
|
u8 iobuf[1028];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user