Commit f4bd4be8 authored by Jonathan Nieder's avatar Jonathan Nieder Committed by Mauro Carvalho Chehab

[media] cx88: don't use atomic_t for core->mpeg_users

mpeg_users is always read or written with core->lock held except
in mpeg_release (where it looks like a bug).  A plain int is simpler
and faster.
Tested-by: default avatarAndi Huber <hobrom@gmx.at>
Tested-by: default avatarMarlon de Boer <marlon@hyves.nl>
Signed-off-by: default avatarJonathan Nieder <jrnieder@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 579b2b45
...@@ -1073,7 +1073,7 @@ static int mpeg_open(struct file *file) ...@@ -1073,7 +1073,7 @@ static int mpeg_open(struct file *file)
return err; return err;
} }
if (!atomic_read(&dev->core->mpeg_users) && blackbird_initialize_codec(dev) < 0) { if (!dev->core->mpeg_users && blackbird_initialize_codec(dev) < 0) {
drv->request_release(drv); drv->request_release(drv);
mutex_unlock(&dev->core->lock); mutex_unlock(&dev->core->lock);
return -EINVAL; return -EINVAL;
...@@ -1101,7 +1101,7 @@ static int mpeg_open(struct file *file) ...@@ -1101,7 +1101,7 @@ static int mpeg_open(struct file *file)
cx88_set_scale(dev->core, dev->width, dev->height, cx88_set_scale(dev->core, dev->width, dev->height,
fh->mpegq.field); fh->mpegq.field);
atomic_inc(&dev->core->mpeg_users); dev->core->mpeg_users++;
mutex_unlock(&dev->core->lock); mutex_unlock(&dev->core->lock);
return 0; return 0;
} }
...@@ -1112,7 +1112,9 @@ static int mpeg_release(struct file *file) ...@@ -1112,7 +1112,9 @@ static int mpeg_release(struct file *file)
struct cx8802_dev *dev = fh->dev; struct cx8802_dev *dev = fh->dev;
struct cx8802_driver *drv = NULL; struct cx8802_driver *drv = NULL;
if (dev->mpeg_active && atomic_read(&dev->core->mpeg_users) == 1) mutex_lock(&dev->core->lock);
if (dev->mpeg_active && dev->core->mpeg_users == 1)
blackbird_stop_codec(dev); blackbird_stop_codec(dev);
cx8802_cancel_buffers(fh->dev); cx8802_cancel_buffers(fh->dev);
...@@ -1121,7 +1123,6 @@ static int mpeg_release(struct file *file) ...@@ -1121,7 +1123,6 @@ static int mpeg_release(struct file *file)
videobuf_mmap_free(&fh->mpegq); videobuf_mmap_free(&fh->mpegq);
mutex_lock(&dev->core->lock);
file->private_data = NULL; file->private_data = NULL;
kfree(fh); kfree(fh);
...@@ -1131,7 +1132,7 @@ static int mpeg_release(struct file *file) ...@@ -1131,7 +1132,7 @@ static int mpeg_release(struct file *file)
if (drv) if (drv)
drv->request_release(drv); drv->request_release(drv);
atomic_dec(&dev->core->mpeg_users); dev->core->mpeg_users--;
mutex_unlock(&dev->core->lock); mutex_unlock(&dev->core->lock);
......
...@@ -390,7 +390,7 @@ struct cx88_core { ...@@ -390,7 +390,7 @@ struct cx88_core {
/* various v4l controls */ /* various v4l controls */
u32 freq; u32 freq;
atomic_t users; atomic_t users;
atomic_t mpeg_users; int mpeg_users;
/* cx88-video needs to access cx8802 for hybrid tuner pll access. */ /* cx88-video needs to access cx8802 for hybrid tuner pll access. */
struct cx8802_dev *dvbdev; struct cx8802_dev *dvbdev;
......
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