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