Changeset 984a9ba in mainline for uspace/lib/drv/generic/remote_usbhid.c
- Timestamp:
- 2018-07-05T09:34:09Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 63d46341
- Parents:
- 76f566d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usbhid.c
r76f566d r984a9ba 283 283 } 284 284 285 static void remote_usbhid_get_event_length(ddf_fun_t *, void *, cap_call_handle_t,ipc_call_t *);286 static void remote_usbhid_get_event(ddf_fun_t *, void *, cap_call_handle_t,ipc_call_t *);287 static void remote_usbhid_get_report_descriptor_length(ddf_fun_t *, void *, cap_call_handle_t,ipc_call_t *);288 static void remote_usbhid_get_report_descriptor(ddf_fun_t *, void *, cap_call_handle_t,ipc_call_t *);285 static void remote_usbhid_get_event_length(ddf_fun_t *, void *, ipc_call_t *); 286 static void remote_usbhid_get_event(ddf_fun_t *, void *, ipc_call_t *); 287 static void remote_usbhid_get_report_descriptor_length(ddf_fun_t *, void *, ipc_call_t *); 288 static void remote_usbhid_get_report_descriptor(ddf_fun_t *, void *, ipc_call_t *); 289 289 290 290 /** Remote USB HID interface operations. */ … … 306 306 307 307 void remote_usbhid_get_event_length(ddf_fun_t *fun, void *iface, 308 cap_call_handle_t chandle,ipc_call_t *call)308 ipc_call_t *call) 309 309 { 310 310 printf("remote_usbhid_get_event_length()\n"); … … 314 314 if (!hid_iface->get_event_length) { 315 315 printf("Get event length not set!\n"); 316 async_answer_0(c handle, ENOTSUP);316 async_answer_0(call, ENOTSUP); 317 317 return; 318 318 } 319 319 320 320 size_t len = hid_iface->get_event_length(fun); 321 async_answer_1(c handle, EOK, len);321 async_answer_1(call, EOK, len); 322 322 } 323 323 324 324 void remote_usbhid_get_event(ddf_fun_t *fun, void *iface, 325 cap_call_handle_t chandle,ipc_call_t *call)325 ipc_call_t *call) 326 326 { 327 327 usbhid_iface_t *hid_iface = (usbhid_iface_t *) iface; 328 328 329 329 if (!hid_iface->get_event) { 330 async_answer_0(c handle, ENOTSUP);330 async_answer_0(call, ENOTSUP); 331 331 return; 332 332 } … … 334 334 unsigned int flags = DEV_IPC_GET_ARG1(*call); 335 335 336 ipc_call_t data; 336 337 size_t len; 337 cap_call_handle_t data_chandle; 338 if (!async_data_read_receive(&data_chandle, &len)) { 339 async_answer_0(chandle, EPARTY); 338 if (!async_data_read_receive(&data, &len)) { 339 async_answer_0(call, EPARTY); 340 340 return; 341 341 } 342 342 343 343 if (len == 0) { 344 async_answer_0( data_chandle, EINVAL);345 async_answer_0(c handle, EINVAL);344 async_answer_0(&data, EINVAL); 345 async_answer_0(call, EINVAL); 346 346 return; 347 347 } … … 349 349 errno_t rc; 350 350 351 uint8_t * data= malloc(len);352 if ( data== NULL) {353 async_answer_0( data_chandle, ENOMEM);354 async_answer_0(c handle, ENOMEM);351 uint8_t *event = malloc(len); 352 if (event == NULL) { 353 async_answer_0(&data, ENOMEM); 354 async_answer_0(call, ENOMEM); 355 355 return; 356 356 } … … 358 358 size_t act_length; 359 359 int event_nr; 360 rc = hid_iface->get_event(fun, data, len, &act_length, &event_nr, flags);360 rc = hid_iface->get_event(fun, event, len, &act_length, &event_nr, flags); 361 361 if (rc != EOK) { 362 free( data);363 async_answer_0( data_chandle, rc);364 async_answer_0(c handle, rc);362 free(event); 363 async_answer_0(&data, rc); 364 async_answer_0(call, rc); 365 365 return; 366 366 } … … 371 371 } 372 372 373 async_data_read_finalize( data_chandle, data, act_length);374 375 free( data);376 377 async_answer_1(c handle, EOK, event_nr);373 async_data_read_finalize(&data, event, act_length); 374 375 free(event); 376 377 async_answer_1(call, EOK, event_nr); 378 378 } 379 379 380 380 void remote_usbhid_get_report_descriptor_length(ddf_fun_t *fun, void *iface, 381 cap_call_handle_t chandle,ipc_call_t *call)381 ipc_call_t *call) 382 382 { 383 383 usbhid_iface_t *hid_iface = (usbhid_iface_t *) iface; 384 384 385 385 if (!hid_iface->get_report_descriptor_length) { 386 async_answer_0(c handle, ENOTSUP);386 async_answer_0(call, ENOTSUP); 387 387 return; 388 388 } 389 389 390 390 size_t len = hid_iface->get_report_descriptor_length(fun); 391 async_answer_1(c handle, EOK, (sysarg_t) len);391 async_answer_1(call, EOK, (sysarg_t) len); 392 392 } 393 393 394 394 void remote_usbhid_get_report_descriptor(ddf_fun_t *fun, void *iface, 395 cap_call_handle_t chandle,ipc_call_t *call)395 ipc_call_t *call) 396 396 { 397 397 usbhid_iface_t *hid_iface = (usbhid_iface_t *) iface; 398 398 399 399 if (!hid_iface->get_report_descriptor) { 400 async_answer_0(chandle, ENOTSUP); 401 return; 402 } 403 400 async_answer_0(call, ENOTSUP); 401 return; 402 } 403 404 ipc_call_t data; 404 405 size_t len; 405 cap_call_handle_t data_chandle; 406 if (!async_data_read_receive(&data_chandle, &len)) { 407 async_answer_0(chandle, EINVAL); 406 if (!async_data_read_receive(&data, &len)) { 407 async_answer_0(call, EINVAL); 408 408 return; 409 409 } 410 410 411 411 if (len == 0) { 412 async_answer_0( data_chandle, EINVAL);413 async_answer_0(c handle, EINVAL);412 async_answer_0(&data, EINVAL); 413 async_answer_0(call, EINVAL); 414 414 return; 415 415 } … … 417 417 uint8_t *descriptor = malloc(len); 418 418 if (descriptor == NULL) { 419 async_answer_0( data_chandle, ENOMEM);420 async_answer_0(c handle, ENOMEM);419 async_answer_0(&data, ENOMEM); 420 async_answer_0(call, ENOMEM); 421 421 return; 422 422 } … … 430 430 if (rc != EOK) { 431 431 free(descriptor); 432 async_answer_0( data_chandle, rc);433 async_answer_0(c handle, rc);434 return; 435 } 436 437 async_data_read_finalize( data_chandle, descriptor, act_len);438 async_answer_0(c handle, EOK);432 async_answer_0(&data, rc); 433 async_answer_0(call, rc); 434 return; 435 } 436 437 async_data_read_finalize(&data, descriptor, act_len); 438 async_answer_0(call, EOK); 439 439 440 440 free(descriptor); 441 441 } 442 443 444 442 445 443 /**
Note:
See TracChangeset
for help on using the changeset viewer.