2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <hal/hal-common-interface.h>
21 #include <hal/device/hal-usb_gadget-interface.h>
23 #include </hal/include/device/hal-backend-common-usb_gadget.h>
24 #include </hal/include/device/hal-backend-common.h>
26 static int usb_gadget_init(void **data)
28 hal_backend_usb_gadget_funcs *usb_gadget_funcs;
33 usb_gadget_funcs = calloc(1, sizeof(hal_backend_usb_gadget_funcs));
34 if (!usb_gadget_funcs)
37 // usb_gadget_translator
38 if (simple_translator_open(usb_gadget_funcs)) {
39 _E("No USB gadget translator");
40 goto error_translator_open;
44 if (hw_legacy_gadget_open(usb_gadget_funcs)) {
46 goto error_gadget_open;
49 *data = (void *)usb_gadget_funcs;
54 simple_translator_close(usb_gadget_funcs);
56 error_translator_open:
57 free(usb_gadget_funcs);
62 static int usb_gadget_exit(void *data)
64 hal_backend_usb_gadget_funcs *usb_gadget_funcs = (hal_backend_usb_gadget_funcs *)data;
66 if (usb_gadget_funcs) {
67 hw_legacy_gadget_close(usb_gadget_funcs);
68 simple_translator_close(usb_gadget_funcs);
69 free(usb_gadget_funcs);
75 hal_backend EXPORT hal_backend_device_usb_gadget_data = {
78 .abi_version = HAL_ABI_VERSION_TIZEN_7_0,
79 .init = usb_gadget_init,
80 .exit = usb_gadget_exit,