diff --git a/src/add-ons/kernel/drivers/input/usb_hid/DeviceList.cpp b/src/add-ons/kernel/drivers/input/hid_shared/DeviceList.cpp similarity index 100% rename from src/add-ons/kernel/drivers/input/usb_hid/DeviceList.cpp rename to src/add-ons/kernel/drivers/input/hid_shared/DeviceList.cpp diff --git a/src/add-ons/kernel/drivers/input/usb_hid/DeviceList.h b/src/add-ons/kernel/drivers/input/hid_shared/DeviceList.h similarity index 100% rename from src/add-ons/kernel/drivers/input/usb_hid/DeviceList.h rename to src/add-ons/kernel/drivers/input/hid_shared/DeviceList.h diff --git a/src/add-ons/kernel/drivers/input/i2c_elan/DeviceList.cpp b/src/add-ons/kernel/drivers/input/i2c_elan/DeviceList.cpp deleted file mode 100644 index e9939355ed..0000000000 --- a/src/add-ons/kernel/drivers/input/i2c_elan/DeviceList.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - Generic device list for use in drivers. - Copyright (C) 2008 Michael Lotz - Distributed under the terms of the MIT license. -*/ -#include "DeviceList.h" -#include -#include -#include -#include - -struct device_list_entry { - char * name; - void * device; - device_list_entry * next; -}; - - -DeviceList::DeviceList() - : fDeviceList(NULL), - fDeviceCount(0) -{ -} - - -DeviceList::~DeviceList() -{ - device_list_entry *current = fDeviceList; - while (current) { - device_list_entry *next = current->next; - free(current->name); - delete current; - current = next; - } -} - - -status_t -DeviceList::AddDevice(const char *name, void *device) -{ - device_list_entry *entry = new(std::nothrow) device_list_entry; - if (entry == NULL) - return B_NO_MEMORY; - - entry->name = strdup(name); - if (entry->name == NULL) { - delete entry; - return B_NO_MEMORY; - } - - entry->device = device; - entry->next = NULL; - - if (fDeviceList == NULL) - fDeviceList = entry; - else { - device_list_entry *current = fDeviceList; - while (current) { - if (current->next == NULL) { - current->next = entry; - break; - } - - current = current->next; - } - } - - fDeviceCount++; - return B_OK; -} - - -status_t -DeviceList::RemoveDevice(const char *name, void *device) -{ - if (name == NULL && device == NULL) - return B_BAD_VALUE; - - device_list_entry *previous = NULL; - device_list_entry *current = fDeviceList; - while (current) { - if ((name != NULL && strcmp(current->name, name) == 0) - || (device != NULL && current->device == device)) { - if (previous == NULL) - fDeviceList = current->next; - else - previous->next = current->next; - - free(current->name); - delete current; - fDeviceCount--; - return B_OK; - } - - previous = current; - current = current->next; - } - - return B_ENTRY_NOT_FOUND; -} - - -void * -DeviceList::FindDevice(const char *name, void *device) -{ - if (name == NULL && device == NULL) - return NULL; - - device_list_entry *current = fDeviceList; - while (current) { - if ((name != NULL && strcmp(current->name, name) == 0) - || (device != NULL && current->device == device)) - return current->device; - - current = current->next; - } - - return NULL; -} - - -int32 -DeviceList::CountDevices(const char *baseName) -{ - if (baseName == NULL) - return fDeviceCount; - - int32 count = 0; - int32 baseNameLength = strlen(baseName); - device_list_entry *current = fDeviceList; - while (current) { - if (strncmp(current->name, baseName, baseNameLength) == 0) - count++; - - current = current->next; - } - - return count; -} - - -void * -DeviceList::DeviceAt(int32 index) -{ - device_list_entry *current = fDeviceList; - while (current) { - if (index-- == 0) - return current->device; - - current = current->next; - } - - return NULL; -} - diff --git a/src/add-ons/kernel/drivers/input/i2c_elan/DeviceList.h b/src/add-ons/kernel/drivers/input/i2c_elan/DeviceList.h deleted file mode 100644 index 2df3e83ad0..0000000000 --- a/src/add-ons/kernel/drivers/input/i2c_elan/DeviceList.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - Generic device list for use in drivers. - Copyright (C) 2008 Michael Lotz - Distributed under the terms of the MIT license. -*/ -#ifndef _DEVICE_LIST_H_ -#define _DEVICE_LIST_H_ - -#include - -struct device_list_entry; - -class DeviceList { -public: - DeviceList(); - ~DeviceList(); - - status_t AddDevice(const char *name, void *device); - status_t RemoveDevice(const char *name, void *device = NULL); - void * FindDevice(const char *name, void *device = NULL); - - int32 CountDevices(const char *baseName = NULL); - void * DeviceAt(int32 index); - -private: - device_list_entry * fDeviceList; - int32 fDeviceCount; -}; - -#endif // _DEVICE_LIST_H_ diff --git a/src/add-ons/kernel/drivers/input/i2c_elan/Jamfile b/src/add-ons/kernel/drivers/input/i2c_elan/Jamfile index 9368236d45..8f9cf4ba7d 100644 --- a/src/add-ons/kernel/drivers/input/i2c_elan/Jamfile +++ b/src/add-ons/kernel/drivers/input/i2c_elan/Jamfile @@ -8,6 +8,8 @@ SubDirSysHdrs $(SUBDIR) $(DOTDOT) hid_shared ; UsePrivateHeaders [ FDirName kernel util ] input drivers device i2c ; UsePrivateKernelHeaders ; +SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons kernel drivers input hid_shared ] ; + KernelAddon i2c_elan : DeviceList.cpp Driver.cpp diff --git a/src/add-ons/kernel/drivers/input/i2c_hid/DeviceList.cpp b/src/add-ons/kernel/drivers/input/i2c_hid/DeviceList.cpp deleted file mode 100644 index e9939355ed..0000000000 --- a/src/add-ons/kernel/drivers/input/i2c_hid/DeviceList.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - Generic device list for use in drivers. - Copyright (C) 2008 Michael Lotz - Distributed under the terms of the MIT license. -*/ -#include "DeviceList.h" -#include -#include -#include -#include - -struct device_list_entry { - char * name; - void * device; - device_list_entry * next; -}; - - -DeviceList::DeviceList() - : fDeviceList(NULL), - fDeviceCount(0) -{ -} - - -DeviceList::~DeviceList() -{ - device_list_entry *current = fDeviceList; - while (current) { - device_list_entry *next = current->next; - free(current->name); - delete current; - current = next; - } -} - - -status_t -DeviceList::AddDevice(const char *name, void *device) -{ - device_list_entry *entry = new(std::nothrow) device_list_entry; - if (entry == NULL) - return B_NO_MEMORY; - - entry->name = strdup(name); - if (entry->name == NULL) { - delete entry; - return B_NO_MEMORY; - } - - entry->device = device; - entry->next = NULL; - - if (fDeviceList == NULL) - fDeviceList = entry; - else { - device_list_entry *current = fDeviceList; - while (current) { - if (current->next == NULL) { - current->next = entry; - break; - } - - current = current->next; - } - } - - fDeviceCount++; - return B_OK; -} - - -status_t -DeviceList::RemoveDevice(const char *name, void *device) -{ - if (name == NULL && device == NULL) - return B_BAD_VALUE; - - device_list_entry *previous = NULL; - device_list_entry *current = fDeviceList; - while (current) { - if ((name != NULL && strcmp(current->name, name) == 0) - || (device != NULL && current->device == device)) { - if (previous == NULL) - fDeviceList = current->next; - else - previous->next = current->next; - - free(current->name); - delete current; - fDeviceCount--; - return B_OK; - } - - previous = current; - current = current->next; - } - - return B_ENTRY_NOT_FOUND; -} - - -void * -DeviceList::FindDevice(const char *name, void *device) -{ - if (name == NULL && device == NULL) - return NULL; - - device_list_entry *current = fDeviceList; - while (current) { - if ((name != NULL && strcmp(current->name, name) == 0) - || (device != NULL && current->device == device)) - return current->device; - - current = current->next; - } - - return NULL; -} - - -int32 -DeviceList::CountDevices(const char *baseName) -{ - if (baseName == NULL) - return fDeviceCount; - - int32 count = 0; - int32 baseNameLength = strlen(baseName); - device_list_entry *current = fDeviceList; - while (current) { - if (strncmp(current->name, baseName, baseNameLength) == 0) - count++; - - current = current->next; - } - - return count; -} - - -void * -DeviceList::DeviceAt(int32 index) -{ - device_list_entry *current = fDeviceList; - while (current) { - if (index-- == 0) - return current->device; - - current = current->next; - } - - return NULL; -} - diff --git a/src/add-ons/kernel/drivers/input/i2c_hid/DeviceList.h b/src/add-ons/kernel/drivers/input/i2c_hid/DeviceList.h deleted file mode 100644 index 2df3e83ad0..0000000000 --- a/src/add-ons/kernel/drivers/input/i2c_hid/DeviceList.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - Generic device list for use in drivers. - Copyright (C) 2008 Michael Lotz - Distributed under the terms of the MIT license. -*/ -#ifndef _DEVICE_LIST_H_ -#define _DEVICE_LIST_H_ - -#include - -struct device_list_entry; - -class DeviceList { -public: - DeviceList(); - ~DeviceList(); - - status_t AddDevice(const char *name, void *device); - status_t RemoveDevice(const char *name, void *device = NULL); - void * FindDevice(const char *name, void *device = NULL); - - int32 CountDevices(const char *baseName = NULL); - void * DeviceAt(int32 index); - -private: - device_list_entry * fDeviceList; - int32 fDeviceCount; -}; - -#endif // _DEVICE_LIST_H_