Ignore:
File:
1 edited

Legend:

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

    r33fc3ae r50ad3f3  
    419419       
    420420        /* Check that function with same name is not there already. */
    421         fun_node_t *tfun = find_fun_node_in_device(tree, pdev, fun_name);
    422         if (tfun) {
    423                 fun_del_ref(tfun);      /* drop the new unwanted reference */
     421        if (find_fun_node_in_device(tree, pdev, fun_name) != NULL) {
    424422                fibril_rwlock_write_unlock(&tree->rwlock);
    425423                dev_del_ref(pdev);
     
    857855}
    858856
    859 /** Get function driver name. */
    860 static void devman_fun_get_driver_name(ipc_callid_t iid, ipc_call_t *icall)
    861 {
    862         devman_handle_t handle = IPC_GET_ARG1(*icall);
    863 
    864         fun_node_t *fun = find_fun_node(&device_tree, handle);
    865         if (fun == NULL) {
    866                 async_answer_0(iid, ENOMEM);
    867                 return;
    868         }
    869 
    870         ipc_callid_t data_callid;
    871         size_t data_len;
    872         if (!async_data_read_receive(&data_callid, &data_len)) {
    873                 async_answer_0(iid, EINVAL);
    874                 fun_del_ref(fun);
    875                 return;
    876         }
    877 
    878         void *buffer = malloc(data_len);
    879         if (buffer == NULL) {
    880                 async_answer_0(data_callid, ENOMEM);
    881                 async_answer_0(iid, ENOMEM);
    882                 fun_del_ref(fun);
    883                 return;
    884         }
    885 
    886         fibril_rwlock_read_lock(&device_tree.rwlock);
    887 
    888         /* Check function state */
    889         if (fun->state == FUN_REMOVED) {
    890                 fibril_rwlock_read_unlock(&device_tree.rwlock);
    891                 free(buffer);
    892 
    893                 async_answer_0(data_callid, ENOENT);
    894                 async_answer_0(iid, ENOENT);
    895                 fun_del_ref(fun);
    896                 return;
    897         }
    898 
    899         /* Check whether function has a driver */
    900         if (fun->child == NULL || fun->child->drv == NULL) {
    901                 fibril_rwlock_read_unlock(&device_tree.rwlock);
    902                 free(buffer);
    903 
    904                 async_answer_0(data_callid, EINVAL);
    905                 async_answer_0(iid, EINVAL);
    906                 fun_del_ref(fun);
    907                 return;
    908         }
    909 
    910         size_t sent_length = str_size(fun->child->drv->name);
    911         if (sent_length > data_len) {
    912                 sent_length = data_len;
    913         }
    914 
    915         async_data_read_finalize(data_callid, fun->child->drv->name,
    916             sent_length);
    917         async_answer_0(iid, EOK);
    918 
    919         fibril_rwlock_read_unlock(&device_tree.rwlock);
    920         fun_del_ref(fun);
    921         free(buffer);
    922 }
    923857
    924858/** Get device path. */
     
    11481082                case DEVMAN_FUN_GET_NAME:
    11491083                        devman_fun_get_name(callid, &call);
    1150                         break;
    1151                 case DEVMAN_FUN_GET_DRIVER_NAME:
    1152                         devman_fun_get_driver_name(callid, &call);
    11531084                        break;
    11541085                case DEVMAN_FUN_GET_PATH:
Note: See TracChangeset for help on using the changeset viewer.