From ae7fa495c10106e58c1597fe97fe64d0bb169ecb Mon Sep 17 00:00:00 2001 From: Roland Stoll Date: Mon, 11 Feb 2008 13:00:34 -0300 Subject: [PATCH] --- yaml --- r: 85757 b: refs/heads/master c: 27d0fe189437803d5ad146d508ec2fd77252c73f h: refs/heads/master i: 85755: bc88dc45bd51c053e7be3148454958c6b744fa83 v: v3 --- [refs] | 2 +- trunk/drivers/media/video/cx88/cx88-mpeg.c | 16 ++++++++++++---- trunk/drivers/media/video/cx88/cx88.h | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 1f55c9b42be0..8a7ee5280879 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 968fb08912880e34a05a0cca7907392bac920aa2 +refs/heads/master: 27d0fe189437803d5ad146d508ec2fd77252c73f diff --git a/trunk/drivers/media/video/cx88/cx88-mpeg.c b/trunk/drivers/media/video/cx88/cx88-mpeg.c index 0aedbeaf94cd..f12733d6bf72 100644 --- a/trunk/drivers/media/video/cx88/cx88-mpeg.c +++ b/trunk/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/trunk/drivers/media/video/cx88/cx88.h b/trunk/drivers/media/video/cx88/cx88.h index 4e823f2a539a..37e6d2e4002f 100644 --- a/trunk/drivers/media/video/cx88/cx88.h +++ b/trunk/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;