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