Changeset 0f12c17 in mainline for uspace/drv/bus/usb/usbhid/mouse/mousedev.c
- Timestamp:
- 2011-11-07T10:54:01Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f750345
- Parents:
- 4578a6e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhid/mouse/mousedev.c
r4578a6e r0f12c17 296 296 return true; 297 297 } 298 299 /*----------------------------------------------------------------------------*/ 300 298 /*----------------------------------------------------------------------------*/ 299 #define FUN_UNBIND_DESTROY(fun) \ 300 if (fun) { \ 301 if (ddf_fun_unbind((fun)) == EOK) { \ 302 (fun)->driver_data = NULL; \ 303 ddf_fun_destroy((fun)); \ 304 } else { \ 305 usb_log_error("Could not unbind function `%s', it " \ 306 "will not be destroyed.\n", (fun)->name); \ 307 } \ 308 } else (void)0 309 /*----------------------------------------------------------------------------*/ 301 310 static int usb_mouse_create_function(usb_hid_dev_t *hid_dev, usb_mouse_t *mouse) 302 311 { … … 306 315 /* Create the exposed function. */ 307 316 usb_log_debug("Creating DDF function %s...\n", HID_MOUSE_FUN_NAME); 308 ddf_fun_t *fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed, 317 ddf_fun_t *fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed, 309 318 HID_MOUSE_FUN_NAME); 310 319 if (fun == NULL) { 311 usb_log_error("Could not create DDF function node.\n"); 320 usb_log_error("Could not create DDF function node `%s'.\n", 321 HID_MOUSE_FUN_NAME); 312 322 return ENOMEM; 313 323 } … … 318 328 int rc = ddf_fun_bind(fun); 319 329 if (rc != EOK) { 320 usb_log_error("Could not bind DDF function : %s.\n",321 str_error(rc));330 usb_log_error("Could not bind DDF function `%s': %s.\n", 331 fun->name, str_error(rc)); 322 332 fun->driver_data = NULL; 323 333 ddf_fun_destroy(fun); … … 325 335 } 326 336 327 usb_log_debug("Adding DDF function to category %s...\n",328 HID_MOUSE_CATEGORY);337 usb_log_debug("Adding DDF function `%s' to category %s...\n", 338 fun->name, HID_MOUSE_CATEGORY); 329 339 rc = ddf_fun_add_to_category(fun, HID_MOUSE_CATEGORY); 330 340 if (rc != EOK) { … … 332 342 "Could not add DDF function to category %s: %s.\n", 333 343 HID_MOUSE_CATEGORY, str_error(rc)); 334 ddf_fun_unbind(fun); 335 fun->driver_data = NULL; 336 ddf_fun_destroy(fun); 344 FUN_UNBIND_DESTROY(fun); 337 345 return rc; 338 346 } … … 347 355 HID_MOUSE_WHEEL_FUN_NAME); 348 356 if (fun == NULL) { 349 usb_log_error("Could not create DDF function node.\n"); 350 ddf_fun_unbind(mouse->mouse_fun); 351 mouse->mouse_fun->driver_data = NULL; 352 ddf_fun_destroy(mouse->mouse_fun); 357 usb_log_error("Could not create DDF function node `%s'.\n", 358 HID_MOUSE_WHEEL_FUN_NAME); 359 FUN_UNBIND_DESTROY(mouse->mouse_fun); 353 360 mouse->mouse_fun = NULL; 354 361 return ENOMEM; … … 364 371 rc = ddf_fun_bind(fun); 365 372 if (rc != EOK) { 366 usb_log_error("Could not bind DDF function: %s.\n", 367 str_error(rc)); 368 ddf_fun_unbind(mouse->mouse_fun); 369 mouse->mouse_fun->driver_data = NULL; 370 ddf_fun_destroy(mouse->mouse_fun); 373 usb_log_error("Could not bind DDF function `%s': %s.\n", 374 fun->name, str_error(rc)); 375 FUN_UNBIND_DESTROY(mouse->mouse_fun); 371 376 mouse->mouse_fun = NULL; 377 372 378 fun->driver_data = NULL; 373 379 ddf_fun_destroy(fun); … … 382 388 "Could not add DDF function to category %s: %s.\n", 383 389 HID_MOUSE_WHEEL_CATEGORY, str_error(rc)); 384 ddf_fun_unbind(mouse->mouse_fun); 385 mouse->mouse_fun->driver_data = NULL; 386 ddf_fun_destroy(mouse->mouse_fun); 390 391 FUN_UNBIND_DESTROY(mouse->mouse_fun); 387 392 mouse->mouse_fun = NULL; 388 ddf_fun_unbind(fun); 389 fun->driver_data = NULL; 390 ddf_fun_destroy(fun); 393 FUN_UNBIND_DESTROY(fun); 391 394 return rc; 392 395 } … … 437 440 return highest_button; 438 441 } 439 440 /*----------------------------------------------------------------------------*/ 441 442 /*----------------------------------------------------------------------------*/ 442 443 int usb_mouse_init(usb_hid_dev_t *hid_dev, void **data) 443 444 { … … 492 493 return EOK; 493 494 } 494 495 /*----------------------------------------------------------------------------*/ 496 495 /*----------------------------------------------------------------------------*/ 497 496 bool usb_mouse_polling_callback(usb_hid_dev_t *hid_dev, void *data) 498 497 { … … 507 506 return usb_mouse_process_report(hid_dev, mouse_dev); 508 507 } 509 510 /*----------------------------------------------------------------------------*/ 511 508 /*----------------------------------------------------------------------------*/ 512 509 void usb_mouse_deinit(usb_hid_dev_t *hid_dev, void *data) 513 510 { … … 532 529 } 533 530 534 /* We might be called before being completely initialized */ 535 if (mouse_dev->mouse_fun) { 536 const int ret = ddf_fun_unbind(mouse_dev->mouse_fun); 537 if (ret != EOK) { 538 usb_log_error("Failed to unbind mouse function.\n"); 539 } else { 540 /* driver_data(mouse_dev) will be freed explicitly */ 541 mouse_dev->mouse_fun->driver_data = NULL; 542 ddf_fun_destroy(mouse_dev->mouse_fun); 543 } 544 } 545 546 /* We might be called before being completely initialized */ 547 if (mouse_dev->mouse_fun) { 548 const int ret = ddf_fun_unbind(mouse_dev->wheel_fun); 549 if (ret != EOK) { 550 usb_log_error("Failed to unbind wheel function.\n"); 551 } else { 552 /* driver_data(mouse_dev) will be freed explicitly */ 553 mouse_dev->wheel_fun->driver_data = NULL; 554 ddf_fun_destroy(mouse_dev->wheel_fun); 555 } 556 } 531 FUN_UNBIND_DESTROY(mouse_dev->mouse_fun); 532 FUN_UNBIND_DESTROY(mouse_dev->wheel_fun); 533 557 534 free(mouse_dev->buttons); 558 535 free(mouse_dev); 559 536 } 560 561 /*----------------------------------------------------------------------------*/ 562 537 /*----------------------------------------------------------------------------*/ 563 538 int usb_mouse_set_boot_protocol(usb_hid_dev_t *hid_dev) 564 539 {
Note:
See TracChangeset
for help on using the changeset viewer.