Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/main.c

    rebcb05a r9b415c9  
    7373        driver_t *driver = NULL;
    7474
    75         log_msg(LVL_DEBUG, "devman_driver_register");
     75        log_msg(LVL_DEBUG, "devman_driver_register\n");
    7676       
    7777        iid = async_get_call(&icall);
     
    9090        }
    9191
    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",
    9393            drv_name);
    9494       
     
    9797       
    9898        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);
    100100                free(drv_name);
    101101                drv_name = NULL;
     
    108108       
    109109        /* 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",
    111111            driver->name);
    112112        ipc_call_t call;
     
    122122       
    123123        log_msg(LVL_NOTE,
    124             "The `%s' driver was successfully registered as running.",
     124            "The `%s' driver was successfully registered as running.\n",
    125125            driver->name);
    126126       
     
    147147        if (DEVMAN_ADD_MATCH_ID != IPC_GET_IMETHOD(call)) {
    148148                log_msg(LVL_ERROR,
    149                     "Invalid protocol when trying to receive match id.");
     149                    "Invalid protocol when trying to receive match id.\n");
    150150                async_answer_0(callid, EINVAL);
    151151                delete_match_id(match_id);
     
    154154       
    155155        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");
    157157                async_answer_0(callid, ENOMEM);
    158158                return ENOMEM;
     
    168168        if (rc != EOK) {
    169169                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",
    171171                    str_error(rc));
    172172                return rc;
     
    175175        list_append(&match_id->link, &match_ids->ids);
    176176       
    177         log_msg(LVL_DEBUG, "Received match id `%s', score %d.",
     177        log_msg(LVL_DEBUG, "Received match id `%s', score %d.\n",
    178178            match_id->id, match_id->score);
    179179        return rc;
     
    232232                /* Unknown function type */
    233233                log_msg(LVL_ERROR,
    234                     "Unknown function type %d provided by driver.",
     234                    "Unknown function type %d provided by driver.\n",
    235235                    (int) ftype);
    236236
     
    248248        }
    249249       
    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 
    260250        fun_node_t *fun = create_fun_node();
    261251        if (!insert_fun_node(&device_tree, fun, fun_name, pdev)) {
     
    280270        fibril_rwlock_write_unlock(&tree->rwlock);
    281271       
    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);
    283273       
    284274        devman_receive_match_ids(match_count, &fun->match_ids);
     
    362352        devmap_register_class_dev(class_info);
    363353       
    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",
    365355            fun->pathname, class_name, class_info->dev_name);
    366356
     
    378368       
    379369        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",
    381371            driver->name);
    382372        return 0;
     
    401391        if (fid == 0) {
    402392                log_msg(LVL_ERROR, "Failed to create initialization fibril " \
    403                     "for driver `%s'.", driver->name);
     393                    "for driver `%s' .\n", driver->name);
    404394                return;
    405395        }
     
    453443}
    454444
    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 
    489445
    490446/** Function for handling connections from a client to the device manager. */
     
    506462                        devman_function_get_handle(callid, &call);
    507463                        break;
    508                 case DEVMAN_DEVICE_GET_HANDLE_BY_CLASS:
    509                         devman_function_get_handle_by_class(callid, &call);
    510                         break;
    511464                default:
    512465                        async_answer_0(callid, ENOENT);
     
    537490        if (dev == NULL) {
    538491                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);
    540493                async_answer_0(iid, ENOENT);
    541494                return;
     
    544497        if (fun == NULL && !drv_to_parent) {
    545498                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",
    547500                    handle);
    548501                async_answer_0(iid, ENOENT);
     
    567520        if (driver == NULL) {
    568521                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);
    570523                async_answer_0(iid, ENOENT);
    571524                return;
     
    580533        if (driver->phone <= 0) {
    581534                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",
    583536                    driver->name, (int) driver->phone);
    584537                async_answer_0(iid, EINVAL);
     
    588541        if (fun != NULL) {
    589542                log_msg(LVL_DEBUG,
    590                     "Forwarding request for `%s' function to driver `%s'.",
     543                    "Forwarding request for `%s' function to driver `%s'.\n",
    591544                    fun->pathname, driver->name);
    592545        } else {
    593546                log_msg(LVL_DEBUG,
    594                     "Forwarding request for `%s' device to driver `%s'.",
     547                    "Forwarding request for `%s' device to driver `%s'.\n",
    595548                    dev->pfun->pathname, driver->name);
    596549        }
     
    626579            IPC_FF_NONE);
    627580        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",
    629582            fun->pathname, dev->drv->name);
    630583}
     
    662615static bool devman_init(void)
    663616{
    664         log_msg(LVL_DEBUG, "devman_init - looking for available drivers.");
     617        log_msg(LVL_DEBUG, "devman_init - looking for available drivers.\n");
    665618       
    666619        /* Initialize list of available drivers. */
     
    668621        if (lookup_available_drivers(&drivers_list,
    669622            DRIVER_DEFAULT_STORE) == 0) {
    670                 log_msg(LVL_FATAL, "No drivers found.");
     623                log_msg(LVL_FATAL, "no drivers found.");
    671624                return false;
    672625        }
    673626
    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");
    675628
    676629        /* Create root device node. */
     
    703656
    704657        if (!devman_init()) {
    705                 log_msg(LVL_ERROR, "Error while initializing service.");
     658                log_msg(LVL_ERROR, "Error while initializing service.\n");
    706659                return -1;
    707660        }
     
    712665        /* Register device manager at naming service. */
    713666        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");
    715668                return -1;
    716669        }
Note: See TracChangeset for help on using the changeset viewer.