Changes in uspace/lib/drv/generic/remote_usbhc.c [99172baf:50b581d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usbhc.c
r99172baf r50b581d 37 37 #include <errno.h> 38 38 #include <assert.h> 39 #include <macros.h>40 39 41 40 #include "usbhc_iface.h" … … 166 165 { 167 166 if (!exch || !address) 168 return E BADMEM;167 return EINVAL; 169 168 sysarg_t new_address; 170 169 const int ret = async_req_4_1(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), … … 174 173 return ret; 175 174 } 176 175 /*----------------------------------------------------------------------------*/ 177 176 int usbhc_bind_address(async_exch_t *exch, usb_address_t address, 178 177 devman_handle_t handle) 179 178 { 180 179 if (!exch) 181 return E BADMEM;180 return EINVAL; 182 181 return async_req_3_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 183 182 IPC_M_USBHC_BIND_ADDRESS, address, handle); 184 183 } 185 184 /*----------------------------------------------------------------------------*/ 186 185 int usbhc_get_handle(async_exch_t *exch, usb_address_t address, 187 186 devman_handle_t *handle) 188 187 { 189 188 if (!exch) 190 return E BADMEM;189 return EINVAL; 191 190 sysarg_t h; 192 191 const int ret = async_req_2_1(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), … … 196 195 return ret; 197 196 } 198 197 /*----------------------------------------------------------------------------*/ 199 198 int usbhc_release_address(async_exch_t *exch, usb_address_t address) 200 199 { 201 200 if (!exch) 202 return E BADMEM;201 return EINVAL; 203 202 return async_req_2_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 204 203 IPC_M_USBHC_RELEASE_ADDRESS, address); 205 204 } 206 205 /*----------------------------------------------------------------------------*/ 207 206 int usbhc_register_endpoint(async_exch_t *exch, usb_address_t address, 208 207 usb_endpoint_t endpoint, usb_transfer_type_t type, … … 210 209 { 211 210 if (!exch) 212 return E BADMEM;211 return EINVAL; 213 212 const usb_target_t target = 214 213 {{ .address = address, .endpoint = endpoint }}; … … 221 220 #undef _PACK2 222 221 } 223 222 /*----------------------------------------------------------------------------*/ 224 223 int usbhc_unregister_endpoint(async_exch_t *exch, usb_address_t address, 225 224 usb_endpoint_t endpoint, usb_direction_t direction) 226 225 { 227 226 if (!exch) 228 return E BADMEM;227 return EINVAL; 229 228 return async_req_4_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), 230 229 IPC_M_USBHC_UNREGISTER_ENDPOINT, address, endpoint, direction); 231 230 } 232 231 /*----------------------------------------------------------------------------*/ 233 232 int usbhc_read(async_exch_t *exch, usb_address_t address, 234 233 usb_endpoint_t endpoint, uint64_t setup, void *data, size_t size, 235 234 size_t *rec_size) 236 235 { 237 if (!exch)238 return EBADMEM;239 240 236 if (size == 0 && setup == 0) 241 237 return EOK; 242 238 239 if (!exch) 240 return EINVAL; 243 241 const usb_target_t target = 244 242 {{ .address = address, .endpoint = endpoint }}; … … 286 284 return EOK; 287 285 } 288 286 /*----------------------------------------------------------------------------*/ 289 287 int usbhc_write(async_exch_t *exch, usb_address_t address, 290 288 usb_endpoint_t endpoint, uint64_t setup, const void *data, size_t size) 291 289 { 292 if (!exch)293 return EBADMEM;294 295 290 if (size == 0 && setup == 0) 296 291 return EOK; 297 292 293 if (!exch) 294 return EINVAL; 298 295 const usb_target_t target = 299 296 {{ .address = address, .endpoint = endpoint }}; … … 322 319 return (int) opening_request_rc; 323 320 } 324 321 /*----------------------------------------------------------------------------*/ 325 322 326 323 static void remote_usbhc_request_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); … … 335 332 336 333 /** Remote USB host controller interface operations. */ 337 static constremote_iface_func_ptr_t remote_usbhc_iface_ops[] = {334 static remote_iface_func_ptr_t remote_usbhc_iface_ops[] = { 338 335 [IPC_M_USBHC_REQUEST_ADDRESS] = remote_usbhc_request_address, 339 336 [IPC_M_USBHC_RELEASE_ADDRESS] = remote_usbhc_release_address, … … 350 347 /** Remote USB host controller interface structure. 351 348 */ 352 const remote_iface_t remote_usbhc_iface = { 353 .method_count = ARRAY_SIZE(remote_usbhc_iface_ops), 349 remote_iface_t remote_usbhc_iface = { 350 .method_count = sizeof(remote_usbhc_iface_ops) / 351 sizeof(remote_usbhc_iface_ops[0]), 354 352 .methods = remote_usbhc_iface_ops 355 353 }; … … 363 361 static void async_transaction_destroy(async_transaction_t *trans) 364 362 { 365 if (trans == NULL) 366 return; 367 368 if (trans->buffer != NULL) 363 if (trans == NULL) { 364 return; 365 } 366 if (trans->buffer != NULL) { 369 367 free(trans->buffer); 370 368 } 369 371 370 free(trans); 372 371 } … … 385 384 return trans; 386 385 } 387 386 /*----------------------------------------------------------------------------*/ 388 387 void remote_usbhc_request_address(ddf_fun_t *fun, void *iface, 389 388 ipc_callid_t callid, ipc_call_t *call) … … 407 406 } 408 407 } 409 408 /*----------------------------------------------------------------------------*/ 410 409 void remote_usbhc_bind_address(ddf_fun_t *fun, void *iface, 411 410 ipc_callid_t callid, ipc_call_t *call) … … 424 423 async_answer_0(callid, ret); 425 424 } 426 425 /*----------------------------------------------------------------------------*/ 427 426 void remote_usbhc_get_handle(ddf_fun_t *fun, void *iface, 428 427 ipc_callid_t callid, ipc_call_t *call) … … 445 444 } 446 445 } 447 446 /*----------------------------------------------------------------------------*/ 448 447 void remote_usbhc_release_address(ddf_fun_t *fun, void *iface, 449 448 ipc_callid_t callid, ipc_call_t *call) … … 461 460 async_answer_0(callid, ret); 462 461 } 463 462 /*----------------------------------------------------------------------------*/ 464 463 static void callback_out(ddf_fun_t *fun, 465 464 int outcome, void *arg) … … 471 470 async_transaction_destroy(trans); 472 471 } 473 472 /*----------------------------------------------------------------------------*/ 474 473 static void callback_in(ddf_fun_t *fun, 475 474 int outcome, size_t actual_size, void *arg) … … 495 494 async_transaction_destroy(trans); 496 495 } 497 496 /*----------------------------------------------------------------------------*/ 498 497 void remote_usbhc_register_endpoint(ddf_fun_t *fun, void *iface, 499 498 ipc_callid_t callid, ipc_call_t *call) … … 584 583 async_answer_0(callid, ENOMEM); 585 584 async_transaction_destroy(trans); 586 return;587 585 } 588 586 … … 596 594 } 597 595 } 598 596 /*----------------------------------------------------------------------------*/ 599 597 void remote_usbhc_write( 600 598 ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
Note:
See TracChangeset
for help on using the changeset viewer.