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));
}
{
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));
}