Changes in uspace/srv/devman/main.c [ebcb05a:9b415c9] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/main.c
rebcb05a r9b415c9 73 73 driver_t *driver = NULL; 74 74 75 log_msg(LVL_DEBUG, "devman_driver_register ");75 log_msg(LVL_DEBUG, "devman_driver_register\n"); 76 76 77 77 iid = async_get_call(&icall); … … 90 90 } 91 91 92 log_msg(LVL_DEBUG, "The `%s' driver is trying to register. ",92 log_msg(LVL_DEBUG, "The `%s' driver is trying to register.\n", 93 93 drv_name); 94 94 … … 97 97 98 98 if (driver == NULL) { 99 log_msg(LVL_ERROR, "No driver named `%s' was found. ", drv_name);99 log_msg(LVL_ERROR, "No driver named `%s' was found.\n", drv_name); 100 100 free(drv_name); 101 101 drv_name = NULL; … … 108 108 109 109 /* Create connection to the driver. */ 110 log_msg(LVL_DEBUG, "Creating connection to the `%s' driver. ",110 log_msg(LVL_DEBUG, "Creating connection to the `%s' driver.\n", 111 111 driver->name); 112 112 ipc_call_t call; … … 122 122 123 123 log_msg(LVL_NOTE, 124 "The `%s' driver was successfully registered as running. ",124 "The `%s' driver was successfully registered as running.\n", 125 125 driver->name); 126 126 … … 147 147 if (DEVMAN_ADD_MATCH_ID != IPC_GET_IMETHOD(call)) { 148 148 log_msg(LVL_ERROR, 149 "Invalid protocol when trying to receive match id. ");149 "Invalid protocol when trying to receive match id.\n"); 150 150 async_answer_0(callid, EINVAL); 151 151 delete_match_id(match_id); … … 154 154 155 155 if (match_id == NULL) { 156 log_msg(LVL_ERROR, "Failed to allocate match id. ");156 log_msg(LVL_ERROR, "Failed to allocate match id.\n"); 157 157 async_answer_0(callid, ENOMEM); 158 158 return ENOMEM; … … 168 168 if (rc != EOK) { 169 169 delete_match_id(match_id); 170 log_msg(LVL_ERROR, "Failed to receive match id string: %s. ",170 log_msg(LVL_ERROR, "Failed to receive match id string: %s.\n", 171 171 str_error(rc)); 172 172 return rc; … … 175 175 list_append(&match_id->link, &match_ids->ids); 176 176 177 log_msg(LVL_DEBUG, "Received match id `%s', score %d. ",177 log_msg(LVL_DEBUG, "Received match id `%s', score %d.\n", 178 178 match_id->id, match_id->score); 179 179 return rc; … … 232 232 /* Unknown function type */ 233 233 log_msg(LVL_ERROR, 234 "Unknown function type %d provided by driver. ",234 "Unknown function type %d provided by driver.\n", 235 235 (int) ftype); 236 236 … … 248 248 } 249 249 250 /* Check that function with same name is not there already. */251 if (find_fun_node_in_device(pdev, fun_name) != NULL) {252 fibril_rwlock_write_unlock(&tree->rwlock);253 async_answer_0(callid, EEXISTS);254 printf(NAME ": Warning, driver tried to register `%s' twice.\n",255 fun_name);256 free(fun_name);257 return;258 }259 260 250 fun_node_t *fun = create_fun_node(); 261 251 if (!insert_fun_node(&device_tree, fun, fun_name, pdev)) { … … 280 270 fibril_rwlock_write_unlock(&tree->rwlock); 281 271 282 log_msg(LVL_DEBUG, "devman_add_function(fun=\"%s\") ", fun->pathname);272 log_msg(LVL_DEBUG, "devman_add_function(fun=\"%s\")\n", fun->pathname); 283 273 284 274 devman_receive_match_ids(match_count, &fun->match_ids); … … 362 352 devmap_register_class_dev(class_info); 363 353 364 log_msg(LVL_NOTE, "Function `%s' added to class `%s' as `%s'. ",354 log_msg(LVL_NOTE, "Function `%s' added to class `%s' as `%s'.\n", 365 355 fun->pathname, class_name, class_info->dev_name); 366 356 … … 378 368 379 369 initialize_running_driver(driver, &device_tree); 380 log_msg(LVL_DEBUG, "The `%s` driver was successfully initialized. ",370 log_msg(LVL_DEBUG, "The `%s` driver was successfully initialized.\n", 381 371 driver->name); 382 372 return 0; … … 401 391 if (fid == 0) { 402 392 log_msg(LVL_ERROR, "Failed to create initialization fibril " \ 403 "for driver `%s' .", driver->name);393 "for driver `%s' .\n", driver->name); 404 394 return; 405 395 } … … 453 443 } 454 444 455 /** Find handle for the device instance identified by device class name. */456 static void devman_function_get_handle_by_class(ipc_callid_t iid,457 ipc_call_t *icall)458 {459 char *classname;460 char *devname;461 462 int rc = async_data_write_accept((void **) &classname, true, 0, 0, 0, 0);463 if (rc != EOK) {464 async_answer_0(iid, rc);465 return;466 }467 rc = async_data_write_accept((void **) &devname, true, 0, 0, 0, 0);468 if (rc != EOK) {469 free(classname);470 async_answer_0(iid, rc);471 return;472 }473 474 475 fun_node_t *fun = find_fun_node_by_class(&class_list,476 classname, devname);477 478 free(classname);479 free(devname);480 481 if (fun == NULL) {482 async_answer_0(iid, ENOENT);483 return;484 }485 486 async_answer_1(iid, EOK, fun->handle);487 }488 489 445 490 446 /** Function for handling connections from a client to the device manager. */ … … 506 462 devman_function_get_handle(callid, &call); 507 463 break; 508 case DEVMAN_DEVICE_GET_HANDLE_BY_CLASS:509 devman_function_get_handle_by_class(callid, &call);510 break;511 464 default: 512 465 async_answer_0(callid, ENOENT); … … 537 490 if (dev == NULL) { 538 491 log_msg(LVL_ERROR, "IPC forwarding failed - no device or " 539 "function with handle %" PRIun " was found. ", handle);492 "function with handle %" PRIun " was found.\n", handle); 540 493 async_answer_0(iid, ENOENT); 541 494 return; … … 544 497 if (fun == NULL && !drv_to_parent) { 545 498 log_msg(LVL_ERROR, NAME ": devman_forward error - cannot " 546 "connect to handle %" PRIun ", refers to a device. ",499 "connect to handle %" PRIun ", refers to a device.\n", 547 500 handle); 548 501 async_answer_0(iid, ENOENT); … … 567 520 if (driver == NULL) { 568 521 log_msg(LVL_ERROR, "IPC forwarding refused - " \ 569 "the device %" PRIun " is not in usable state. ", handle);522 "the device %" PRIun " is not in usable state.\n", handle); 570 523 async_answer_0(iid, ENOENT); 571 524 return; … … 580 533 if (driver->phone <= 0) { 581 534 log_msg(LVL_ERROR, 582 "Could not forward to driver `%s' (phone is %d). ",535 "Could not forward to driver `%s' (phone is %d).\n", 583 536 driver->name, (int) driver->phone); 584 537 async_answer_0(iid, EINVAL); … … 588 541 if (fun != NULL) { 589 542 log_msg(LVL_DEBUG, 590 "Forwarding request for `%s' function to driver `%s'. ",543 "Forwarding request for `%s' function to driver `%s'.\n", 591 544 fun->pathname, driver->name); 592 545 } else { 593 546 log_msg(LVL_DEBUG, 594 "Forwarding request for `%s' device to driver `%s'. ",547 "Forwarding request for `%s' device to driver `%s'.\n", 595 548 dev->pfun->pathname, driver->name); 596 549 } … … 626 579 IPC_FF_NONE); 627 580 log_msg(LVL_DEBUG, 628 "Forwarding devmapper request for `%s' function to driver `%s'. ",581 "Forwarding devmapper request for `%s' function to driver `%s'.\n", 629 582 fun->pathname, dev->drv->name); 630 583 } … … 662 615 static bool devman_init(void) 663 616 { 664 log_msg(LVL_DEBUG, "devman_init - looking for available drivers. ");617 log_msg(LVL_DEBUG, "devman_init - looking for available drivers.\n"); 665 618 666 619 /* Initialize list of available drivers. */ … … 668 621 if (lookup_available_drivers(&drivers_list, 669 622 DRIVER_DEFAULT_STORE) == 0) { 670 log_msg(LVL_FATAL, " No drivers found.");623 log_msg(LVL_FATAL, "no drivers found."); 671 624 return false; 672 625 } 673 626 674 log_msg(LVL_DEBUG, "devman_init - list of drivers has been initialized. ");627 log_msg(LVL_DEBUG, "devman_init - list of drivers has been initialized.\n"); 675 628 676 629 /* Create root device node. */ … … 703 656 704 657 if (!devman_init()) { 705 log_msg(LVL_ERROR, "Error while initializing service. ");658 log_msg(LVL_ERROR, "Error while initializing service.\n"); 706 659 return -1; 707 660 } … … 712 665 /* Register device manager at naming service. */ 713 666 if (service_register(SERVICE_DEVMAN) != EOK) { 714 log_msg(LVL_ERROR, "Failed registering as a service. ");667 log_msg(LVL_ERROR, "Failed registering as a service.\n"); 715 668 return -1; 716 669 }
Note:
See TracChangeset
for help on using the changeset viewer.