• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-2021 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 "hdf_device_info.h"
10 #include "hdf_log.h"
11 #include "osal_mem.h"
12 
13 #define HDF_LOG_TAG device_info
14 
HdfDeviceInfoConstruct(struct HdfDeviceInfo * deviceInfo)15 void HdfDeviceInfoConstruct(struct HdfDeviceInfo *deviceInfo)
16 {
17     if (deviceInfo == NULL) {
18         return;
19     }
20     deviceInfo->isDynamic = false;
21     deviceInfo->status = HDF_SERVICE_UNUSABLE;
22     deviceInfo->deviceType = HDF_DEV_LOCAL_SERVICE;
23     deviceInfo->deviceId = 0;
24     deviceInfo->policy = SERVICE_POLICY_INVALID;
25     deviceInfo->priority = 0;
26     deviceInfo->preload = DEVICE_PRELOAD_ENABLE;
27     deviceInfo->permission = 0;
28     deviceInfo->svcName = NULL;
29     deviceInfo->moduleName = NULL;
30     deviceInfo->deviceMatchAttr = NULL;
31 }
32 
HdfDeviceInfoNewInstance(void)33 struct HdfDeviceInfo *HdfDeviceInfoNewInstance(void)
34 {
35     struct HdfDeviceInfo *deviceInfo =
36             (struct HdfDeviceInfo*)OsalMemCalloc(sizeof(struct HdfDeviceInfo));
37     if (deviceInfo != NULL) {
38         HdfDeviceInfoConstruct(deviceInfo);
39         return deviceInfo;
40     }
41     HDF_LOGE("failed to create deviceInfo, oom");
42     return NULL;
43 }
44 
HdfDeviceInfoFreeInstance(struct HdfDeviceInfo * deviceInfo)45 void HdfDeviceInfoFreeInstance(struct HdfDeviceInfo *deviceInfo)
46 {
47     if (deviceInfo != NULL) {
48         OsalMemFree(deviceInfo);
49     }
50 }
51 
HdfDeviceInfoDelete(struct HdfSListNode * listEntry)52 void HdfDeviceInfoDelete(struct HdfSListNode *listEntry)
53 {
54     struct HdfDeviceInfo *deviceInfo = (struct HdfDeviceInfo *)listEntry;
55     HdfDeviceInfoFreeInstance(deviceInfo);
56 }
57 
58