summaryrefslogtreecommitdiffstats
path: root/4a-hal
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
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')
-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);