Changeset c280d7e in mainline for uspace/lib/drv/generic/remote_usb.c
- Timestamp:
- 2018-01-20T03:02:36Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 60d3f35
- Parents:
- 3cdaa7f
- git-author:
- Ondřej Hlavatý <aearsis@…> (2018-01-20 03:02:32)
- git-committer:
- Ondřej Hlavatý <aearsis@…> (2018-01-20 03:02:36)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usb.c
r3cdaa7f rc280d7e 61 61 62 62 typedef enum { 63 IPC_M_USB_GET_MY_INTERFACE, 64 IPC_M_USB_GET_MY_DEVICE_HANDLE, 63 IPC_M_USB_GET_MY_DESCRIPTION, 65 64 } usb_iface_funcs_t; 66 65 … … 71 70 * @return Error code. 72 71 */ 73 int usb_get_my_ interface(async_exch_t *exch, int *usb_iface)72 int usb_get_my_description(async_exch_t *exch, usb_device_desc_t *desc) 74 73 { 75 74 if (!exch) 76 75 return EBADMEM; 77 sysarg_t iface_no; 78 const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE), 79 IPC_M_USB_GET_MY_INTERFACE, &iface_no); 80 if (ret == EOK && usb_iface) 81 *usb_iface = (int)iface_no; 76 77 usb_device_desc_t tmp_desc; 78 79 const int ret = async_req_1_4(exch, DEV_IFACE_ID(USB_DEV_IFACE), 80 IPC_M_USB_GET_MY_DESCRIPTION, 81 (sysarg_t *) &tmp_desc.address, 82 (sysarg_t *) &tmp_desc.speed, 83 &tmp_desc.handle, 84 (sysarg_t *) &tmp_desc.iface); 85 if (ret == EOK && desc) 86 *desc = tmp_desc; 82 87 return ret; 83 88 } 84 89 85 /** Tell devman handle of the usb device function. 86 * 87 * @param[in] exch IPC communication exchange 88 * @param[out] handle devman handle of the HC used by the target device. 89 * 90 * @return Error code. 91 * 92 */ 93 int usb_get_my_device_handle(async_exch_t *exch, devman_handle_t *handle) 94 { 95 devman_handle_t h = 0; 96 const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE), 97 IPC_M_USB_GET_MY_DEVICE_HANDLE, &h); 98 if (ret == EOK && handle) 99 *handle = (devman_handle_t)h; 100 return ret; 101 } 102 103 static void remote_usb_get_my_interface(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 104 static void remote_usb_get_my_device_handle(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 90 static void remote_usb_get_my_description(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 105 91 106 92 /** Remote USB interface operations. */ 107 93 static const remote_iface_func_ptr_t remote_usb_iface_ops [] = { 108 [IPC_M_USB_GET_MY_INTERFACE] = remote_usb_get_my_interface, 109 [IPC_M_USB_GET_MY_DEVICE_HANDLE] = remote_usb_get_my_device_handle, 94 [IPC_M_USB_GET_MY_DESCRIPTION] = remote_usb_get_my_description, 110 95 }; 111 96 … … 117 102 }; 118 103 119 void remote_usb_get_my_ interface(ddf_fun_t *fun, void *iface,104 void remote_usb_get_my_description(ddf_fun_t *fun, void *iface, 120 105 ipc_callid_t callid, ipc_call_t *call) 121 106 { 122 107 const usb_iface_t *usb_iface = (usb_iface_t *) iface; 123 108 124 if (usb_iface->get_my_ interface== NULL) {109 if (usb_iface->get_my_description == NULL) { 125 110 async_answer_0(callid, ENOTSUP); 126 111 return; 127 112 } 128 113 129 int iface_no;130 const int ret = usb_iface->get_my_ interface(fun, &iface_no);114 usb_device_desc_t desc; 115 const int ret = usb_iface->get_my_description(fun, &desc); 131 116 if (ret != EOK) { 132 117 async_answer_0(callid, ret); 133 118 } else { 134 async_answer_1(callid, EOK, iface_no); 119 async_answer_4(callid, EOK, 120 (sysarg_t) desc.address, 121 (sysarg_t) desc.speed, 122 desc.handle, 123 desc.iface); 135 124 } 136 }137 138 void remote_usb_get_my_device_handle(ddf_fun_t *fun, void *iface,139 ipc_callid_t callid, ipc_call_t *call)140 {141 const usb_iface_t *usb_iface = (usb_iface_t *) iface;142 143 if (usb_iface->get_my_device_handle == NULL) {144 async_answer_0(callid, ENOTSUP);145 return;146 }147 148 devman_handle_t handle;149 const int ret = usb_iface->get_my_device_handle(fun, &handle);150 if (ret != EOK) {151 async_answer_0(callid, ret);152 }153 154 async_answer_1(callid, EOK, (sysarg_t) handle);155 125 } 156 126
Note:
See TracChangeset
for help on using the changeset viewer.