summaryrefslogtreecommitdiffstats
path: root/4a-hal/4a-hal-utilities
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-06-09 17:56:08 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-10-08 15:52:51 +0200
commitcfd7792c40232af1cb14ea4d0efd93bc8ca0d983 (patch)
treea1cd133a0dd2d65bb4f85320a5f58c1aea62b6ee /4a-hal/4a-hal-utilities
parent957ccad167159cecf6fa7e33c75ec9692ce6af29 (diff)
Change paramters in functions handling hal data
Change paramters in functions handling hal data structure. Now, the only thing you need to add/search for/remove something in hal data structure list is the address of the first element of the list instead of the address of the whole hal manager data structure. Change-Id: Iafa7428735c3aa418a6ef6564f9acde8f44e7dfe Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to '4a-hal/4a-hal-utilities')
-rw-r--r--4a-hal/4a-hal-utilities/4a-hal-utilities-data.c38
-rw-r--r--4a-hal/4a-hal-utilities/4a-hal-utilities-data.h10
2 files changed, 25 insertions, 23 deletions
diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.c b/4a-hal/4a-hal-utilities/4a-hal-utilities-data.c
index 335a8b7..d585f5d 100644
--- a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.c
+++ b/4a-hal/4a-hal-utilities/4a-hal-utilities-data.c
@@ -25,6 +25,8 @@
#include "4a-hal-utilities-data.h"
+#include "../4a-hal-controllers/4a-hal-controllers-alsacore-link.h"
+
/*******************************************************************************
* Specfic Hal controller streams data handling functions *
******************************************************************************/
@@ -53,21 +55,21 @@ uint8_t HalUtlRemoveAllCtlHalStreamsData(struct CtlHalStreamsDataT *ctlHalStream
* Specfic Hal data handling functions *
******************************************************************************/
-struct SpecificHalData *HalUtlAddHalApiToHalList(struct HalMgrData *HalMgrGlobalData)
+struct SpecificHalData *HalUtlAddHalApiToHalList(struct SpecificHalData **firstHalData)
{
struct SpecificHalData *currentApi;
- if(! HalMgrGlobalData)
+ if(! firstHalData)
return NULL;
- currentApi = HalMgrGlobalData->first;
+ currentApi = *firstHalData;
if(! currentApi) {
currentApi = (struct SpecificHalData *) calloc(1, sizeof(struct SpecificHalData));
if(! currentApi)
return NULL;
- HalMgrGlobalData->first = currentApi;
+ *firstHalData = currentApi;
}
else {
while(currentApi->next)
@@ -85,17 +87,17 @@ struct SpecificHalData *HalUtlAddHalApiToHalList(struct HalMgrData *HalMgrGlobal
return currentApi;
}
-uint8_t HalUtlRemoveSelectedHalFromList(struct HalMgrData *HalMgrGlobalData, struct SpecificHalData *apiToRemove)
+uint8_t HalUtlRemoveSelectedHalFromList(struct SpecificHalData **firstHalData, struct SpecificHalData *apiToRemove)
{
struct SpecificHalData *currentApi, *matchingApi;
- if(! HalMgrGlobalData || ! apiToRemove)
+ if(! firstHalData || ! apiToRemove)
return -1;
- currentApi = HalMgrGlobalData->first;
+ currentApi = *firstHalData;
if(currentApi == apiToRemove) {
- HalMgrGlobalData->first = currentApi->next;
+ *firstHalData = currentApi->next;
matchingApi = currentApi;
}
else {
@@ -132,13 +134,13 @@ uint8_t HalUtlRemoveSelectedHalFromList(struct HalMgrData *HalMgrGlobalData, str
return 0;
}
-uint64_t HalUtlRemoveAllHalFromList(struct HalMgrData *HalMgrGlobalData)
+uint64_t HalUtlRemoveAllHalFromList(struct SpecificHalData **firstHalData)
{
uint8_t ret;
uint64_t CtlHalApiRemoved = 0;
- while(HalMgrGlobalData->first) {
- ret = HalUtlRemoveSelectedHalFromList(HalMgrGlobalData, HalMgrGlobalData->first);
+ while(*firstHalData) {
+ ret = HalUtlRemoveSelectedHalFromList(firstHalData, *firstHalData);
if(ret)
return (uint64_t) ret;
@@ -148,15 +150,15 @@ uint64_t HalUtlRemoveAllHalFromList(struct HalMgrData *HalMgrGlobalData)
return CtlHalApiRemoved;
}
-uint64_t HalUtlGetNumberOfHalInList(struct HalMgrData *HalMgrGlobalData)
+uint64_t HalUtlGetNumberOfHalInList(struct SpecificHalData **firstHalData)
{
uint64_t numberOfCtlHal = 0;
struct SpecificHalData *currentApi;
- if(! HalMgrGlobalData)
+ if(! firstHalData)
return -1;
- currentApi = HalMgrGlobalData->first;
+ currentApi = *firstHalData;
while(currentApi) {
currentApi = currentApi->next;
@@ -166,14 +168,14 @@ uint64_t HalUtlGetNumberOfHalInList(struct HalMgrData *HalMgrGlobalData)
return numberOfCtlHal;
}
-struct SpecificHalData *HalUtlSearchHalDataByApiName(struct HalMgrData *HalMgrGlobalData, char *apiName)
+struct SpecificHalData *HalUtlSearchHalDataByApiName(struct SpecificHalData **firstHalData, char *apiName)
{
struct SpecificHalData *currentApi;
- if(! HalMgrGlobalData || ! apiName)
+ if(! firstHalData || ! apiName)
return NULL;
- currentApi = HalMgrGlobalData->first;
+ currentApi = *firstHalData;
while(currentApi) {
if(! strcmp(apiName, currentApi->apiName))
@@ -214,7 +216,7 @@ void HalUtlRemoveHalMgrData(struct HalMgrData *HalMgrGlobalData)
return;
if(HalMgrGlobalData->first)
- HalUtlRemoveAllHalFromList(HalMgrGlobalData);
+ HalUtlRemoveAllHalFromList(&HalMgrGlobalData->first);
free(HalMgrGlobalData->apiName);
free(HalMgrGlobalData->info);
diff --git a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.h b/4a-hal/4a-hal-utilities/4a-hal-utilities-data.h
index e6b99f4..16befde 100644
--- a/4a-hal/4a-hal-utilities/4a-hal-utilities-data.h
+++ b/4a-hal/4a-hal-utilities/4a-hal-utilities-data.h
@@ -91,11 +91,11 @@ struct HalMgrData {
};
// Exported verbs for 'struct SpecificHalData' handling
-struct SpecificHalData *HalUtlAddHalApiToHalList(struct HalMgrData *HalMgrGlobalData);
-uint8_t HalUtlRemoveSelectedHalFromList(struct HalMgrData *HalMgrGlobalData, struct SpecificHalData *ApiToRemove);
-uint64_t HalUtlRemoveAllHalFromList(struct HalMgrData *HalMgrGlobalData);
-uint64_t HalUtlGetNumberOfHalInList(struct HalMgrData *HalMgrGlobalData);
-struct SpecificHalData *HalUtlSearchHalDataByApiName(struct HalMgrData *HalMgrGlobalData, char *apiName);
+struct SpecificHalData *HalUtlAddHalApiToHalList(struct SpecificHalData **firstHalData);
+uint8_t HalUtlRemoveSelectedHalFromList(struct SpecificHalData **firstHalData, struct SpecificHalData *ApiToRemove);
+uint64_t HalUtlRemoveAllHalFromList(struct SpecificHalData **firstHalData);
+uint64_t HalUtlGetNumberOfHalInList(struct SpecificHalData **firstHalData);
+struct SpecificHalData *HalUtlSearchHalDataByApiName(struct SpecificHalData **firstHalData, char *apiName);
// Exported verbs for 'struct HalMgrData' handling
uint8_t HalUtlInitializeHalMgrData(AFB_ApiT apiHandle, struct HalMgrData *HalMgrGlobalData, char *apiName, char *info);