From: Jonathan Nieder <jrnieder@gmail.com>
To: linux-media@vger.kernel.org
Cc: Huber Andreas <hobrom@corax.at>,
Mauro Carvalho Chehab <mchehab@redhat.com>,
Hans Verkuil <hverkuil@xs4all.nl>,
linux-kernel@vger.kernel.org, Ben Hutchings <ben@decadent.org.uk>,
Steven Toth <stoth@kernellabs.com>
Subject: [PATCH 6/7] [media] cx88: don't use atomic_t for core->mpeg_users
Date: Mon, 4 Apr 2011 22:30:35 -0500 [thread overview]
Message-ID: <20110405033035.GG4498@elie> (raw)
In-Reply-To: <20110405032014.GA4498@elie>
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.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
drivers/media/video/cx88/cx88-blackbird.c | 11 ++++++-----
drivers/media/video/cx88/cx88.h | 2 +-
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index fa8e347..11e49bb 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -1073,7 +1073,7 @@ static int mpeg_open(struct file *file)
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);
mutex_unlock(&dev->core->lock);
return -EINVAL;
@@ -1101,7 +1101,7 @@ static int mpeg_open(struct file *file)
cx88_set_scale(dev->core, dev->width, dev->height,
fh->mpegq.field);
- atomic_inc(&dev->core->mpeg_users);
+ dev->core->mpeg_users++;
mutex_unlock(&dev->core->lock);
return 0;
}
@@ -1112,7 +1112,9 @@ static int mpeg_release(struct file *file)
struct cx8802_dev *dev = fh->dev;
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);
cx8802_cancel_buffers(fh->dev);
@@ -1121,7 +1123,6 @@ static int mpeg_release(struct file *file)
videobuf_mmap_free(&fh->mpegq);
- mutex_lock(&dev->core->lock);
file->private_data = NULL;
kfree(fh);
@@ -1131,7 +1132,7 @@ static int mpeg_release(struct file *file)
if (drv)
drv->request_release(drv);
- atomic_dec(&dev->core->mpeg_users);
+ dev->core->mpeg_users--;
mutex_unlock(&dev->core->lock);
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 3d32f4a..9e8176e 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -390,7 +390,7 @@ struct cx88_core {
/* various v4l controls */
u32 freq;
atomic_t users;
- atomic_t mpeg_users;
+ int mpeg_users;
/* cx88-video needs to access cx8802 for hybrid tuner pll access. */
struct cx8802_dev *dvbdev;
--
1.7.5.rc0
next prev parent reply other threads:[~2011-04-05 3:30 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20110327150610.4029.95961.reportbug@xen.corax.at>
2011-03-27 15:28 ` [linux-dvb] cx88-blackbird broken (since 2.6.37) Jonathan Nieder
2011-04-02 9:38 ` [RFC/PATCH 0/3] locking fixes for cx88 Jonathan Nieder
2011-04-02 9:41 ` [PATCH 1/3] [media] cx88: protect per-device driver list with device lock Jonathan Nieder
2011-04-02 9:41 ` [PATCH 2/3] [media] cx88: fix locking of sub-driver operations Jonathan Nieder
2011-04-02 9:44 ` [PATCH 3/3] [media] cx88: use a mutex to protect cx8802_devlist Jonathan Nieder
[not found] ` <4D971B8D.4040305@corax.at>
2011-04-02 19:29 ` Jonathan Nieder
2011-04-02 20:13 ` Andreas Huber
2011-04-04 2:12 ` Andreas Huber
2011-04-05 1:16 ` Jonathan Nieder
2011-04-02 14:05 ` [RFC/PATCH 0/3] locking fixes for cx88 Andreas Huber
2011-04-02 15:19 ` Ben Hutchings
2011-04-02 18:30 ` Jonathan Nieder
2011-04-05 3:20 ` [RFC/PATCH v2 0/7] " Jonathan Nieder
2011-04-05 3:22 ` [PATCH 1/7] [media] cx88: protect per-device driver list with device lock Jonathan Nieder
2011-04-05 3:25 ` [PATCH 2/7] [media] cx88: fix locking of sub-driver operations Jonathan Nieder
2011-04-05 3:27 ` [PATCH 3/7] [media] cx88: hold device lock during sub-driver initialization Jonathan Nieder
2011-04-05 3:27 ` [PATCH 4/7] [media] cx88: use a mutex to protect cx8802_devlist Jonathan Nieder
2011-04-05 3:29 ` [PATCH 5/7] [media] cx88: gracefully reject attempts to use unregistered cx88-blackbird driver Jonathan Nieder
2011-04-05 3:30 ` Jonathan Nieder [this message]
2011-04-05 3:31 ` [PATCH 7/7] [mpeg] cx88: don't use atomic_t for core->users Jonathan Nieder
2011-04-05 3:41 ` Jonathan Nieder
2011-04-05 18:17 ` [RFC/PATCH v2 0/7] locking fixes for cx88 Jonathan Nieder
2011-05-01 9:17 [PATCH v2.6.38 resend 0/7] cx88 deadlock and data races Jonathan Nieder
2011-05-01 9:31 ` [PATCH 6/7] [media] cx88: don't use atomic_t for core->mpeg_users Jonathan Nieder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110405033035.GG4498@elie \
--to=jrnieder@gmail.com \
--cc=ben@decadent.org.uk \
--cc=hobrom@corax.at \
--cc=hverkuil@xs4all.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@redhat.com \
--cc=stoth@kernellabs.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.