1 /*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "osal_mem.h"
17 #include "device_token_stub.h"
18 #include "hdf_base.h"
19 #include "hdf_log.h"
20
21 #define HDF_LOG_TAG device_token_stub
22
DeviceTokenStubDispatch(struct HdfObject * stub,int code,struct HdfSBuf * data,struct HdfSBuf * reply)23 int DeviceTokenStubDispatch(
24 struct HdfObject *stub, int code, struct HdfSBuf *data, struct HdfSBuf *reply)
25 {
26 (void)code;
27 (void)data;
28 (void)reply;
29 struct DeviceTokenStub *tokenStub = (struct DeviceTokenStub *)stub;
30 struct IDevHostService *super = (struct IDevHostService *)&tokenStub->super;
31 if (super == NULL) {
32 HDF_LOGE("Dispatch failed, super is null");
33 return HDF_FAILURE;
34 }
35 return HDF_SUCCESS;
36 }
37
DeviceTokenStubConstruct(struct DeviceTokenStub * inst)38 void DeviceTokenStubConstruct(struct DeviceTokenStub *inst)
39 {
40 inst->remote = NULL;
41 }
42
DeviceTokenStubCreate()43 struct HdfObject *DeviceTokenStubCreate()
44 {
45 struct DeviceTokenStub *instance =
46 (struct DeviceTokenStub *)OsalMemCalloc(sizeof(struct DeviceTokenStub));
47 if (instance != NULL) {
48 DeviceTokenStubConstruct(instance);
49 }
50 return (struct HdfObject *)instance;
51 }
52
DeviceTokenStubRelease(struct HdfObject * object)53 void DeviceTokenStubRelease(struct HdfObject *object)
54 {
55 struct DeviceTokenStub *instance = (struct DeviceTokenStub *)object;
56 if (instance != NULL) {
57 if (instance->remote != NULL) {
58 HdfRemoteServiceRecycle(instance->remote);
59 instance->remote = NULL;
60 }
61 OsalMemFree(instance);
62 }
63 }
64
65