From b3be7a4135863bcf10210ddcbb879bd822ee3a17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 25 Nov 2009 11:07:49 +0000 Subject: [PATCH] * Replaced benaphore use with a mutex. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34236 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../drivers/graphics/intel_extreme/device.cpp | 16 +++--- .../drivers/graphics/intel_extreme/driver.cpp | 55 +++++++------------ .../drivers/graphics/intel_extreme/driver.h | 36 ++++++------ 3 files changed, 47 insertions(+), 60 deletions(-) diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/device.cpp b/src/add-ons/kernel/drivers/graphics/intel_extreme/device.cpp index 3dfe9ace0a..b867fc95c6 100644 --- a/src/add-ons/kernel/drivers/graphics/intel_extreme/device.cpp +++ b/src/add-ons/kernel/drivers/graphics/intel_extreme/device.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -116,7 +116,7 @@ device_open(const char *name, uint32 /*flags*/, void **_cookie) intel_info *info = gDeviceInfo[id]; - acquire_lock(&gLock); + mutex_lock(&gLock); if (info->open_count == 0) { // this device has been opened for the first time, so @@ -132,7 +132,7 @@ device_open(const char *name, uint32 /*flags*/, void **_cookie) } } - release_lock(&gLock); + mutex_unlock(&gLock); if (info->init_status == B_OK) *_cookie = info; @@ -154,7 +154,7 @@ device_free(void *data) { struct intel_info *info = (intel_info *)data; - acquire_lock(&gLock); + mutex_lock(&gLock); if (info->open_count-- == 1) { // release info structure @@ -166,7 +166,7 @@ device_free(void *data) #endif } - release_lock(&gLock); + mutex_unlock(&gLock); return B_OK; } @@ -183,7 +183,7 @@ device_ioctl(void *data, uint32 op, void *buffer, size_t bufferLength) TRACE((DEVICE_NAME ": accelerant: %s\n", INTEL_ACCELERANT_NAME)); return B_OK; - // needed to share data between kernel and accelerant + // needed to share data between kernel and accelerant case INTEL_GET_PRIVATE_DATA: { intel_get_private_data *data = (intel_get_private_data *)buffer; @@ -268,7 +268,7 @@ device_ioctl(void *data, uint32 op, void *buffer, size_t bufferLength) static status_t device_read(void */*data*/, off_t /*pos*/, void */*buffer*/, size_t *_length) { - *_length = 0; + *_length = 0; return B_NOT_ALLOWED; } @@ -276,7 +276,7 @@ device_read(void */*data*/, off_t /*pos*/, void */*buffer*/, size_t *_length) static status_t device_write(void */*data*/, off_t /*pos*/, const void */*buffer*/, size_t *_length) { - *_length = 0; + *_length = 0; return B_NOT_ALLOWED; } diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/driver.cpp b/src/add-ons/kernel/drivers/graphics/intel_extreme/driver.cpp index c8c382cc4a..23ad13f4f8 100644 --- a/src/add-ons/kernel/drivers/graphics/intel_extreme/driver.cpp +++ b/src/add-ons/kernel/drivers/graphics/intel_extreme/driver.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -21,6 +21,7 @@ #include #include + #define TRACE_DRIVER #ifdef TRACE_DRIVER # define TRACE(x) dprintf x @@ -30,11 +31,12 @@ #define MAX_CARDS 4 + // list of supported devices const struct supported_device { uint32 device_id; int32 type; - const char *name; + const char* name; } kSupportedDevices[] = { {0x3577, INTEL_TYPE_83x, "i830GM"}, {0x2562, INTEL_TYPE_83x, "i845G"}, @@ -59,11 +61,11 @@ const struct supported_device { int32 api_version = B_CUR_DRIVER_API_VERSION; -char *gDeviceNames[MAX_CARDS + 1]; -intel_info *gDeviceInfo[MAX_CARDS]; -pci_module_info *gPCI; -agp_gart_module_info *gGART; -lock gLock; +char* gDeviceNames[MAX_CARDS + 1]; +intel_info* gDeviceInfo[MAX_CARDS]; +pci_module_info* gPCI; +agp_gart_module_info* gGART; +mutex gLock; static status_t @@ -129,32 +131,27 @@ init_driver(void) { TRACE((DEVICE_NAME ": init_driver()\n")); - status_t status = get_module(B_PCI_MODULE_NAME, (module_info **)&gPCI); + status_t status = get_module(B_PCI_MODULE_NAME, (module_info**)&gPCI); if (status != B_OK) { TRACE((DEVICE_NAME ": pci module unavailable\n")); return status; } - status = get_module(B_AGP_GART_MODULE_NAME, (module_info **)&gGART); + status = get_module(B_AGP_GART_MODULE_NAME, (module_info**)&gGART); if (status != B_OK) { TRACE((DEVICE_NAME ": AGP GART module unavailable\n")); put_module(B_PCI_MODULE_NAME); return status; } - status = init_lock(&gLock, "intel extreme ksync"); - if (status < B_OK) { - put_module(B_AGP_GART_MODULE_NAME); - put_module(B_PCI_MODULE_NAME); - return status; - } + mutex_init(&gLock, "intel extreme ksync"); // find devices int32 found = 0; for (int32 cookie = 0; found < MAX_CARDS;) { - pci_info *info = (pci_info *)malloc(sizeof(pci_info)); + pci_info* info = (pci_info*)malloc(sizeof(pci_info)); if (info == NULL) break; @@ -176,7 +173,7 @@ init_driver(void) if (gDeviceNames[found] == NULL) break; - gDeviceInfo[found] = (intel_info *)malloc(sizeof(intel_info)); + gDeviceInfo[found] = (intel_info*)malloc(sizeof(intel_info)); if (gDeviceInfo[found] == NULL) { free(gDeviceNames[found]); break; @@ -201,7 +198,7 @@ init_driver(void) gDeviceNames[found] = NULL; if (found == 0) { - uninit_lock(&gLock); + mutex_destroy(&gLock); put_module(B_AGP_GART_MODULE_NAME); put_module(B_PCI_MODULE_NAME); return ENODEV; @@ -216,10 +213,10 @@ uninit_driver(void) { TRACE((DEVICE_NAME ": uninit_driver()\n")); - uninit_lock(&gLock); + mutex_destroy(&gLock); // free device related structures - char *name; + char* name; for (int32 index = 0; (name = gDeviceNames[index]) != NULL; index++) { free(gDeviceInfo[index]); free(name); @@ -230,8 +227,8 @@ uninit_driver(void) } -extern "C" device_hooks * -find_device(const char *name) +extern "C" device_hooks* +find_device(const char* name) { int index; @@ -245,17 +242,3 @@ find_device(const char *name) return NULL; } -/* -extern "C" void -wake_driver(void) -{ - // for compatibility with Dano, only -} - - -extern "C" void -suspend_driver(void) -{ - // for compatibility with Dano, only -} -*/ diff --git a/src/add-ons/kernel/drivers/graphics/intel_extreme/driver.h b/src/add-ons/kernel/drivers/graphics/intel_extreme/driver.h index 57208dbe4f..68d851f57f 100644 --- a/src/add-ons/kernel/drivers/graphics/intel_extreme/driver.h +++ b/src/add-ons/kernel/drivers/graphics/intel_extreme/driver.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -12,37 +12,41 @@ #include #include +#include + #include "intel_extreme_private.h" // PCI Communications -#define read8(address) (*((volatile uint8 *)(address))) -#define read16(address) (*((volatile uint16 *)(address))) -#define read32(address) (*((volatile uint32 *)(address))) -#define write8(address, data) (*((volatile uint8 *)(address)) = (data)) -#define write16(address, data) (*((volatile uint16 *)(address)) = (data)) -#define write32(address, data) (*((volatile uint32 *)(address)) = (data)) +#define read8(address) (*((volatile uint8*)(address))) +#define read16(address) (*((volatile uint16*)(address))) +#define read32(address) (*((volatile uint32*)(address))) +#define write8(address, data) (*((volatile uint8*)(address)) = (data)) +#define write16(address, data) (*((volatile uint16*)(address)) = (data)) +#define write32(address, data) (*((volatile uint32*)(address)) = (data)) -extern char *gDeviceNames[]; -extern intel_info *gDeviceInfo[]; -extern pci_module_info *gPCI; -extern agp_gart_module_info *gGART; -extern struct lock gLock; +extern char* gDeviceNames[]; +extern intel_info* gDeviceInfo[]; +extern pci_module_info* gPCI; +extern agp_gart_module_info* gGART; +extern mutex gLock; static inline uint32 -get_pci_config(pci_info *info, uint8 offset, uint8 size) +get_pci_config(pci_info* info, uint8 offset, uint8 size) { - return gPCI->read_pci_config(info->bus, info->device, info->function, offset, size); + return gPCI->read_pci_config(info->bus, info->device, info->function, + offset, size); } static inline void -set_pci_config(pci_info *info, uint8 offset, uint8 size, uint32 value) +set_pci_config(pci_info* info, uint8 offset, uint8 size, uint32 value) { - gPCI->write_pci_config(info->bus, info->device, info->function, offset, size, value); + gPCI->write_pci_config(info->bus, info->device, info->function, offset, + size, value); } #endif /* DRIVER_H */