vesa: Fix tracking of device opens / closes
* Don't raise the open_count when the open fails
This commit is contained in:
@@ -51,13 +51,12 @@ device_open(const char* name, uint32 flags, void** _cookie)
|
|||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
vesa_info* info = gDeviceInfo[id];
|
vesa_info* info = gDeviceInfo[id];
|
||||||
*_cookie = info;
|
|
||||||
|
|
||||||
mutex_lock(&gLock);
|
mutex_lock(&gLock);
|
||||||
|
|
||||||
status_t status = B_OK;
|
status_t status = B_OK;
|
||||||
|
|
||||||
if (info->open_count++ == 0) {
|
if (info->open_count == 0) {
|
||||||
// this device has been opened for the first time, so
|
// this device has been opened for the first time, so
|
||||||
// we allocate needed resources and initialize the structure
|
// we allocate needed resources and initialize the structure
|
||||||
if (status == B_OK)
|
if (status == B_OK)
|
||||||
@@ -66,6 +65,11 @@ device_open(const char* name, uint32 flags, void** _cookie)
|
|||||||
info->id = id;
|
info->id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (status == B_OK) {
|
||||||
|
info->open_count++;
|
||||||
|
*_cookie = info;
|
||||||
|
}
|
||||||
|
|
||||||
mutex_unlock(&gLock);
|
mutex_unlock(&gLock);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user