From 66f27bce6355cc7df978a9d7a6bc725542057a01 Mon Sep 17 00:00:00 2001 From: Jonathan Aillet Date: Fri, 14 Jun 2019 17:59:20 +0200 Subject: Refactoring 'probed devices' linked list Refactoring 'probed devices' linked list code using liburcu. BUG-AGL: SPEC-2329 Change-Id: I4d0255bc020733b1abbea1f3e6195c73cf8da8f6 Signed-off-by: Jonathan Aillet --- lib/4a-hal-utilities/4a-hal-utilities-data.h | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'lib/4a-hal-utilities/4a-hal-utilities-data.h') diff --git a/lib/4a-hal-utilities/4a-hal-utilities-data.h b/lib/4a-hal-utilities/4a-hal-utilities-data.h index c051373..8ac4c25 100644 --- a/lib/4a-hal-utilities/4a-hal-utilities-data.h +++ b/lib/4a-hal-utilities/4a-hal-utilities-data.h @@ -20,6 +20,8 @@ #include +#include + #include #include @@ -32,6 +34,11 @@ #define HAL_STREAM_UPDATES_EVENT_NAME "stream-updates" +// Enum for linked list type +enum LinkedListType { + LINKED_LIST_FOR_DEPENDENCIES_DATA = 0 +}; + // Enum for hal status enum HalStatus { HAL_STATUS_UNAVAILABLE = 0, @@ -83,7 +90,7 @@ struct InternalHalProbedDevice { struct InternalHalDeviceData *deviceData; - struct InternalHalProbedDevice *next; + struct cds_list_head node; }; // Structure to store stream data @@ -102,7 +109,7 @@ struct InternalHalData { char *prefix; json_object *halMixerJ; - struct InternalHalProbedDevice *probedDevicesList; + struct cds_list_head probedDevicesListHead; struct InternalHalMixerData *streamsData; afb_event_t streamUpdates; @@ -146,26 +153,26 @@ struct HalMgrData { // Internal Hal - Probed devices structure handling functions enum ProbedDeviceClasses HalUtlGetProbedDeviceClassFromString(char *probedDeviceString); char *HalUtlGetProbedDeviceClassString(enum ProbedDeviceClasses deviceClass); -struct InternalHalProbedDevice *HalUtlAddProbedDeviceToProbedDeviceList(struct InternalHalProbedDevice **probedDevicesList); -int HalUtlRemoveSelectedProbedDeviceFromList(struct InternalHalProbedDevice **probedDevicesList, +struct InternalHalProbedDevice *HalUtlAddProbedDeviceToProbedDeviceList(struct cds_list_head *probedDevicesListHead); +int HalUtlRemoveSelectedProbedDeviceFromList(struct cds_list_head *probedDevicesListHead, struct InternalHalProbedDevice *probedDeviceToRemove); -int HalUtlRemoveAllProbedDevicesFromList(struct InternalHalProbedDevice **probedDevicesList); -int HalUtlGetNumberOfProbedDevicesInList(struct InternalHalProbedDevice **probedDevicesList); -struct InternalHalProbedDevice *HalUtlSearchProbedDeviceDataById(struct InternalHalProbedDevice **probedDevicesList, +int HalUtlRemoveAllProbedDevicesFromList(struct cds_list_head *probedDevicesListHead); +int HalUtlGetNumberOfProbedDevicesInList(struct cds_list_head *probedDevicesListHead); +struct InternalHalProbedDevice *HalUtlSearchProbedDeviceDataById(struct cds_list_head *probedDevicesListHead, char *uid); struct InternalHalDeviceData *HalUtlAllocateAndFillProbedDeviceDataUsingInfoGetResponse(json_object *responseJ); json_object *HalUtlGetJsonForSpecificDependencies(afb_api_t apiHandle, struct InternalHalProbedDevice *requestedProbedDevice, enum DependencyInfoJsonFormat jsonFormat); json_object *HalUtlGetJsonForSpecificDependenciesUsingUid(afb_api_t apiHandle, - struct InternalHalProbedDevice **probedDevicesList, + struct cds_list_head *probedDevicesListHead, char *uid, enum DependencyInfoJsonFormat jsonFormat); json_object *HalUtlGetJsonArrayForAvailableDependencies(afb_api_t apiHandle, - struct InternalHalProbedDevice **probedDevicesList, + struct cds_list_head *probedDevicesListHead, enum DependencyInfoJsonFormat jsonFormat); json_object *HalUtlGetJsonArrayForAllDependencies(afb_api_t apiHandle, - struct InternalHalProbedDevice **probedDevicesList, + struct cds_list_head *probedDevicesListHead, enum DependencyInfoJsonFormat jsonFormat); // Internal Hal - Streams data handling functions -- cgit 1.2.3-korg