aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c2
-rw-r--r--4a-hal/4a-hal-manager/4a-hal-manager-cb.c8
-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
4 files changed, 30 insertions, 28 deletions
diff --git a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c
index 404ecd2..61b0657 100644
--- a/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c
+++ b/4a-hal/4a-hal-controllers/4a-hal-controllers-api-loader.c
@@ -174,7 +174,7 @@ int HalCtlsCreateApi(AFB_ApiT apiHandle, char *path, struct HalMgrData *HalMgrGl
}
// Allocation of current hal controller data
- currentCtlHalData = HalUtlAddHalApiToHalList(HalMgrGlobalData);
+ currentCtlHalData = HalUtlAddHalApiToHalList(&HalMgrGlobalData->first);
if(! currentCtlHalData)
return -4;
diff --git a/4a-hal/4a-hal-manager/4a-hal-manager-cb.c b/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
index cdb50b7..f0ab0bd 100644
--- a/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
+++ b/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
@@ -90,7 +90,7 @@ void HalMgrLoaded(AFB_ReqT request)
return;
}
- numberOfLoadedApi = HalUtlGetNumberOfHalInList(HalMgrGlobalData);
+ numberOfLoadedApi = HalUtlGetNumberOfHalInList(&HalMgrGlobalData->first);
if(! numberOfLoadedApi) {
AFB_ReqSuccess(request, NULL, "No Hal Api loaded");
return;
@@ -191,7 +191,7 @@ void HalMgrLoad(AFB_ReqT request)
return;
}
- addedHal = HalUtlAddHalApiToHalList(HalMgrGlobalData);
+ addedHal = HalUtlAddHalApiToHalList(&HalMgrGlobalData->first);
addedHal->internal = false;
// TBD JAI : initialize external to unavailable once event from external hal will be handled
@@ -252,7 +252,7 @@ void HalMgrUnload(AFB_ReqT request)
return;
}
- HalToRemove = HalUtlSearchHalDataByApiName(HalMgrGlobalData, apiName);
+ HalToRemove = HalUtlSearchHalDataByApiName(&HalMgrGlobalData->first, apiName);
if(! HalToRemove) {
AFB_ReqFail(request, "requested_api", "Can't find api to remove");
return;
@@ -263,7 +263,7 @@ void HalMgrUnload(AFB_ReqT request)
return;
}
- if(HalUtlRemoveSelectedHalFromList(HalMgrGlobalData, HalToRemove)) {
+ if(HalUtlRemoveSelectedHalFromList(&HalMgrGlobalData->first, HalToRemove)) {
AFB_ReqFail(request, "unregister_error", "Didn't succeed to remove specified api");
return;
}
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);