Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 376496
b: refs/heads/master
c: 4ad1f70
h: refs/heads/master
v: v3
  • Loading branch information
Al Viro committed May 31, 2013
1 parent f180351 commit 2a31a66
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 448293aadb54ab38b9c053bf9f1eecafdc0ed214
refs/heads/master: 4ad1f70ebcdb69393ce083f514bf4a4a3a3e65cb
2 changes: 1 addition & 1 deletion trunk/drivers/media/pci/zoran/zoran.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ struct zoran_fh;

struct zoran_mapping {
struct zoran_fh *fh;
int count;
atomic_t count;
};

struct zoran_buffer {
Expand Down
15 changes: 8 additions & 7 deletions trunk/drivers/media/pci/zoran/zoran_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2803,8 +2803,7 @@ static void
zoran_vm_open (struct vm_area_struct *vma)
{
struct zoran_mapping *map = vma->vm_private_data;

map->count++;
atomic_inc(&map->count);
}

static void
Expand All @@ -2815,7 +2814,7 @@ zoran_vm_close (struct vm_area_struct *vma)
struct zoran *zr = fh->zr;
int i;

if (--map->count > 0)
if (!atomic_dec_and_mutex_lock(&map->count, &zr->resource_lock))
return;

dprintk(3, KERN_INFO "%s: %s - munmap(%s)\n", ZR_DEVNAME(zr),
Expand All @@ -2828,14 +2827,16 @@ zoran_vm_close (struct vm_area_struct *vma)
kfree(map);

/* Any buffers still mapped? */
for (i = 0; i < fh->buffers.num_buffers; i++)
if (fh->buffers.buffer[i].map)
for (i = 0; i < fh->buffers.num_buffers; i++) {
if (fh->buffers.buffer[i].map) {
mutex_unlock(&zr->resource_lock);
return;
}
}

dprintk(3, KERN_INFO "%s: %s - free %s buffers\n", ZR_DEVNAME(zr),
__func__, mode_name(fh->map_mode));

mutex_lock(&zr->resource_lock);

if (fh->map_mode == ZORAN_MAP_MODE_RAW) {
if (fh->buffers.active != ZORAN_FREE) {
Expand Down Expand Up @@ -2939,7 +2940,7 @@ zoran_mmap (struct file *file,
goto mmap_unlock_and_return;
}
map->fh = fh;
map->count = 1;
atomic_set(&map->count, 1);

vma->vm_ops = &zoran_vm_ops;
vma->vm_flags |= VM_DONTEXPAND;
Expand Down

0 comments on commit 2a31a66

Please sign in to comment.