radeon_hd: Fix tracking of device opens / closes

* Don't raise the open_count when the open fails
* Remove the kdl command on uninit
This commit is contained in:
Alexander von Gluck IV 2014-01-27 21:03:24 +00:00
parent d4474f3a28
commit 01696cd951
1 changed files with 14 additions and 6 deletions

View File

@ -123,9 +123,9 @@ device_open(const char* name, uint32 /*flags*/, void** _cookie)
mutex_lock(&gLock);
if (info->open_count++ == 0) {
// this device has been opened for the first time, so
// we allocate needed resources and initialize the structure
if (info->open_count == 0) {
// This device hasn't been initialized yet, so we
// allocate needed resources and initialize the structure
info->init_status = radeon_hd_init(*info);
if (info->init_status == B_OK) {
#ifdef DEBUG_COMMANDS
@ -135,10 +135,13 @@ device_open(const char* name, uint32 /*flags*/, void** _cookie)
}
}
mutex_unlock(&gLock);
if (info->init_status == B_OK)
if (info->init_status == B_OK) {
info->open_count++;
*_cookie = info;
} else
ERROR("%s: initilization failed!\n", __func__);
mutex_unlock(&gLock);
return info->init_status;
}
@ -163,7 +166,12 @@ device_free(void* data)
// release info structure
info->init_status = B_NO_INIT;
radeon_hd_uninit(*info);
#ifdef DEBUG_COMMANDS
remove_debugger_command("radeonhd_reg", getset_register);
#endif
}
mutex_unlock(&gLock);
return B_OK;
}