Changeset 3f57fb7 in mainline for uspace/srv/devman/main.c
- Timestamp:
- 2012-06-13T21:44:47Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a3fcfba
- Parents:
- 375e501
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/main.c
r375e501 r3f57fb7 855 855 } 856 856 857 /** Get function driver name. */ 858 static void devman_fun_get_driver_name(ipc_callid_t iid, ipc_call_t *icall) 859 { 860 devman_handle_t handle = IPC_GET_ARG1(*icall); 861 862 fun_node_t *fun = find_fun_node(&device_tree, handle); 863 if (fun == NULL) { 864 async_answer_0(iid, ENOMEM); 865 return; 866 } 867 868 ipc_callid_t data_callid; 869 size_t data_len; 870 if (!async_data_read_receive(&data_callid, &data_len)) { 871 async_answer_0(iid, EINVAL); 872 fun_del_ref(fun); 873 return; 874 } 875 876 void *buffer = malloc(data_len); 877 if (buffer == NULL) { 878 async_answer_0(data_callid, ENOMEM); 879 async_answer_0(iid, ENOMEM); 880 fun_del_ref(fun); 881 return; 882 } 883 884 fibril_rwlock_read_lock(&device_tree.rwlock); 885 886 /* Check function state */ 887 if (fun->state == FUN_REMOVED) { 888 fibril_rwlock_read_unlock(&device_tree.rwlock); 889 free(buffer); 890 891 async_answer_0(data_callid, ENOENT); 892 async_answer_0(iid, ENOENT); 893 fun_del_ref(fun); 894 return; 895 } 896 897 /* Check whether function has a driver */ 898 if (fun->child == NULL || fun->child->drv == NULL) { 899 fibril_rwlock_read_unlock(&device_tree.rwlock); 900 free(buffer); 901 902 async_answer_0(data_callid, EINVAL); 903 async_answer_0(iid, EINVAL); 904 fun_del_ref(fun); 905 return; 906 } 907 908 size_t sent_length = str_size(fun->child->drv->name); 909 if (sent_length > data_len) { 910 sent_length = data_len; 911 } 912 913 async_data_read_finalize(data_callid, fun->child->drv->name, 914 sent_length); 915 async_answer_0(iid, EOK); 916 917 fibril_rwlock_read_unlock(&device_tree.rwlock); 918 fun_del_ref(fun); 919 free(buffer); 920 } 857 921 858 922 /** Get device path. */ … … 1082 1146 case DEVMAN_FUN_GET_NAME: 1083 1147 devman_fun_get_name(callid, &call); 1148 break; 1149 case DEVMAN_FUN_GET_DRIVER_NAME: 1150 devman_fun_get_driver_name(callid, &call); 1084 1151 break; 1085 1152 case DEVMAN_FUN_GET_PATH:
Note:
See TracChangeset
for help on using the changeset viewer.