4 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
22 #include <hal/hal-common-interface.h>
23 #include <hal/device/hal-common-interface.h>
24 #include <hal/device/hal-usb_gadget-interface.h>
28 static int usb_gadget_init(void **data)
30 hal_backend_usb_gadget_funcs *usb_gadget_funcs;
35 usb_gadget_funcs = calloc(1, sizeof(hal_backend_usb_gadget_funcs));
36 if (!usb_gadget_funcs)
39 // usb_gadget_translator
40 if (simple_translator_open(usb_gadget_funcs)) {
41 _E("No USB gadget translator");
42 goto error_translator_open;
46 if (hw_cfs_gadget_open(usb_gadget_funcs)) {
48 goto error_gadget_open;
51 *data = (void *)usb_gadget_funcs;
56 simple_translator_close(usb_gadget_funcs);
58 error_translator_open:
59 free(usb_gadget_funcs);
64 static int usb_gadget_exit(void *data)
66 hal_backend_usb_gadget_funcs *usb_gadget_funcs = (hal_backend_usb_gadget_funcs *)data;
68 if (usb_gadget_funcs) {
69 hw_cfs_gadget_close(usb_gadget_funcs);
70 simple_translator_close(usb_gadget_funcs);
71 free(usb_gadget_funcs);
77 hal_backend EXPORT hal_backend_device_usb_gadget_data = {
80 .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
81 .init = usb_gadget_init,
82 .exit = usb_gadget_exit,