1 /*
2  * Copyright (c) 2021-2022 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 "usb_request.h"
17 #include "usb_common.h"
18 #include "usb_srv_client.h"
19 
20 namespace OHOS {
21 namespace USB {
Initialize(const USBDevicePipe & pipe,const USBEndpoint & endpoint)22 int32_t UsbRequest::Initialize(const USBDevicePipe &pipe, const USBEndpoint &endpoint)
23 {
24     this->pipe_ = pipe;
25     this->endpoint_ = endpoint;
26     int32_t ret = UsbSrvClient::GetInstance().RequestInitialize(*this);
27     if (ret != ERR_OK) {
28         USB_HILOGE(MODULE_USB_INNERKIT, "RequestInitialize failed with ret = %{public}d.", ret);
29     }
30     return ret;
31 }
32 
Queue()33 int32_t UsbRequest::Queue()
34 {
35     int32_t ret = UsbSrvClient::GetInstance().RequestQueue(*this);
36     if (ret != ERR_OK) {
37         USB_HILOGE(MODULE_USB_INNERKIT, "RequestQueue failed with ret = %{public}d.", ret);
38     }
39     return ret;
40 }
41 
Free()42 int32_t UsbRequest::Free()
43 {
44     int32_t ret = UsbSrvClient::GetInstance().RequestFree(*this);
45     if (ret != ERR_OK) {
46         USB_HILOGE(MODULE_USB_INNERKIT, "RequestFree failed with ret = %{public}d.", ret);
47     }
48     return ret;
49 }
50 
Abort()51 int32_t UsbRequest::Abort()
52 {
53     int32_t ret = UsbSrvClient::GetInstance().RequestAbort(*this);
54     if (ret != ERR_OK) {
55         USB_HILOGE(MODULE_USB_INNERKIT, "RequestAbort failed with ret = %{public}d.", ret);
56     }
57     return ret;
58 }
59 } // namespace USB
60 } // namespace OHOS
61