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 "power_state_token_clnt.h"
10 #include "osal_mem.h"
11 
PowerStateTokenClntConstruct(struct PowerStateTokenClnt * clnt,struct IPowerStateToken * tokenIf)12 static void PowerStateTokenClntConstruct(struct PowerStateTokenClnt *clnt, struct IPowerStateToken *tokenIf)
13 {
14     clnt->tokenIf = tokenIf;
15     clnt->powerState = PSM_STATE_INACTIVE;
16 }
17 
PowerStateTokenClntNewInstance(struct IPowerStateToken * tokenIf)18 struct PowerStateTokenClnt *PowerStateTokenClntNewInstance(struct IPowerStateToken *tokenIf)
19 {
20     struct PowerStateTokenClnt *tokenClnt =
21         (struct PowerStateTokenClnt *)OsalMemCalloc(sizeof(struct PowerStateTokenClnt));
22     if (tokenClnt != NULL) {
23         PowerStateTokenClntConstruct(tokenClnt, tokenIf);
24         return tokenClnt;
25     }
26     return tokenClnt;
27 }
28 
PowerStateTokenClntFreeInstance(struct PowerStateTokenClnt * tokenClnt)29 void PowerStateTokenClntFreeInstance(struct PowerStateTokenClnt *tokenClnt)
30 {
31     if (tokenClnt != NULL) {
32         OsalMemFree(tokenClnt);
33     }
34 }
35