Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=27d0fe189437803d5ad146d508ec2fd77252c73f
Commit:     27d0fe189437803d5ad146d508ec2fd77252c73f
Parent:     968fb08912880e34a05a0cca7907392bac920aa2
Author:     Roland Stoll <[EMAIL PROTECTED]>
AuthorDate: Mon Feb 11 13:00:34 2008 -0300
Committer:  Mauro Carvalho Chehab <[EMAIL PROTECTED]>
CommitDate: Mon Feb 18 11:15:19 2008 -0300

    V4L/DVB (7194): cx88-mpeg: Allow concurrent access to cx88-mpeg devices
    
    It currently isn't possible to open the frontend device of cx88-mpeg devices
    (DVB or Blackbird) multiple times concurrently. (for instance, to attach a
    signal monitoring tool while reading a stream, or to send a frequency change
    ioctl) This patch fixes that condition.
    
    Signed-off-by: Roland Stoll <[EMAIL PROTECTED]>
    Signed-off-by: Ricardo Cerqueira <[EMAIL PROTECTED]>
    Reviewed-by: Michael Krufky <[EMAIL PROTECTED]>
    Signed-off-by: Mauro Carvalho Chehab <[EMAIL PROTECTED]>
---
 drivers/media/video/cx88/cx88-mpeg.c |   16 ++++++++++++----
 drivers/media/video/cx88/cx88.h      |    1 +
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/media/video/cx88/cx88-mpeg.c 
b/drivers/media/video/cx88/cx88-mpeg.c
index 0aedbea..f12733d 100644
--- a/drivers/media/video/cx88/cx88-mpeg.c
+++ b/drivers/media/video/cx88/cx88-mpeg.c
@@ -609,13 +609,19 @@ static int cx8802_request_acquire(struct cx8802_driver 
*drv)
        struct cx88_core *core = drv->core;
 
        /* Fail a request for hardware if the device is busy. */
-       if (core->active_type_id != CX88_BOARD_NONE)
+       if (core->active_type_id != CX88_BOARD_NONE &&
+           core->active_type_id != drv->type_id)
                return -EBUSY;
 
        if (drv->advise_acquire)
        {
-               core->active_type_id = drv->type_id;
-               drv->advise_acquire(drv);
+               core->active_ref++;
+               mutex_lock(&drv->core->lock);
+               if (core->active_type_id == CX88_BOARD_NONE) {
+                       core->active_type_id = drv->type_id;
+                       drv->advise_acquire(drv);
+               }
+               mutex_unlock(&drv->core->lock);
 
                mpeg_dbg(1,"%s() Post acquire GPIO=%x\n", __FUNCTION__, 
cx_read(MO_GP0_IO));
        }
@@ -628,10 +634,12 @@ static int cx8802_request_release(struct cx8802_driver 
*drv)
 {
        struct cx88_core *core = drv->core;
 
-       if (drv->advise_release)
+       if (drv->advise_release && --core->active_ref == 0)
        {
+               mutex_lock(&drv->core->lock);
                drv->advise_release(drv);
                core->active_type_id = CX88_BOARD_NONE;
+               mutex_unlock(&drv->core->lock);
                mpeg_dbg(1,"%s() Post release GPIO=%x\n", __FUNCTION__, 
cx_read(MO_GP0_IO));
        }
 
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 4e823f2..37e6d2e 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -336,6 +336,7 @@ struct cx88_core {
        /* cx88-video needs to access cx8802 for hybrid tuner pll access. */
        struct cx8802_dev          *dvbdev;
        enum cx88_board_type       active_type_id;
+       int                        active_ref;
 };
 
 struct cx8800_dev;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to