Changeset 90478727 in mainline for uspace/srv/devman/main.c


Ignore:
Timestamp:
2012-08-12T11:46:44Z (12 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
41b764b7
Parents:
e1e4192 (diff), 371cb6c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge mainline changes

File:
1 edited

Legend:

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

    re1e4192 r90478727  
    419419       
    420420        /* Check that function with same name is not there already. */
    421         if (find_fun_node_in_device(tree, pdev, fun_name) != NULL) {
     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 */
    422424                fibril_rwlock_write_unlock(&tree->rwlock);
    423425                dev_del_ref(pdev);
     
    855857}
    856858
     859/** Get function driver name. */
     860static 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}
    857923
    858924/** Get device path. */
     
    10821148                case DEVMAN_FUN_GET_NAME:
    10831149                        devman_fun_get_name(callid, &call);
     1150                        break;
     1151                case DEVMAN_FUN_GET_DRIVER_NAME:
     1152                        devman_fun_get_driver_name(callid, &call);
    10841153                        break;
    10851154                case DEVMAN_FUN_GET_PATH:
Note: See TracChangeset for help on using the changeset viewer.