From 01696cd9513825140ddd1d888cd2b677a837eb4d Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Mon, 27 Jan 2014 21:03:24 +0000 Subject: [PATCH] radeon_hd: Fix tracking of device opens / closes * Don't raise the open_count when the open fails * Remove the kdl command on uninit --- .../drivers/graphics/radeon_hd/device.cpp | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/add-ons/kernel/drivers/graphics/radeon_hd/device.cpp b/src/add-ons/kernel/drivers/graphics/radeon_hd/device.cpp index 41c4778b40..1b93612394 100644 --- a/src/add-ons/kernel/drivers/graphics/radeon_hd/device.cpp +++ b/src/add-ons/kernel/drivers/graphics/radeon_hd/device.cpp @@ -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; }