1 /*
2  * Copyright (c) 2020-2022 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #include "wifi_module.h"
10 
11 #define HDF_LOG_TAG HDF_WIFI_CORE
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
AddFeature(struct WifiModule * module,uint16_t featureType,struct WifiFeature * feature)17 int32_t AddFeature(struct WifiModule *module, uint16_t featureType, struct WifiFeature *feature)
18 {
19     if ((module == NULL) || (feature == NULL) || (featureType >= HDF_WIFI_FEATURE_NUM)) {
20         HDF_LOGE("%s: para error", __func__);
21         return HDF_FAILURE;
22     }
23     module->feList.fe[featureType] = (struct WifiFeature *)feature;
24     if (feature->init != NULL) {
25         HDF_LOGD("%s: AddFeature finished!", __func__);
26         return feature->init(feature);
27     }
28 
29     HDF_LOGE("%s: feature has no init", __func__);
30     return HDF_FAILURE;
31 }
32 
DelFeature(struct WifiModule * module,uint16_t featureType)33 int32_t DelFeature(struct WifiModule *module, uint16_t featureType)
34 {
35     struct WifiFeature *featureData = NULL;
36     if ((module == NULL) || (featureType >= HDF_WIFI_FEATURE_NUM)) {
37         HDF_LOGE("%s: para error", __func__);
38         return HDF_FAILURE;
39     }
40 
41     featureData = module->feList.fe[featureType];
42     if ((featureData != NULL) && (featureData->deInit != NULL)) {
43         featureData->deInit(module->feList.fe[featureType]);
44         featureData = NULL;
45         HDF_LOGD("%s: DelFeature finished!", __func__);
46         return HDF_SUCCESS;
47     }
48     HDF_LOGE("%s: DelFeature fail!", __func__);
49     return HDF_FAILURE;
50 }
51 
52 #ifdef __cplusplus
53 }
54 #endif
55