Changeset 3f57fb7 in mainline
- Timestamp:
- 2012-06-13T21:44:47Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a3fcfba
- Parents:
- 375e501
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/devctl/devctl.c
r375e501 r3f57fb7 44 44 #define MAX_NAME_LENGTH 1024 45 45 46 char name[MAX_NAME_LENGTH]; 47 char drv_name[MAX_NAME_LENGTH]; 48 46 49 static int fun_subtree_print(devman_handle_t funh, int lvl) 47 50 { 48 char name[MAX_NAME_LENGTH];49 51 devman_handle_t devh; 50 52 devman_handle_t *cfuns; … … 57 59 58 60 rc = devman_fun_get_name(funh, name, MAX_NAME_LENGTH); 59 if (rc != EOK) { 60 str_cpy(name, MAX_NAME_LENGTH, "unknown"); 61 return ENOMEM; 62 } 61 if (rc != EOK) 62 return ELIMIT; 63 63 64 64 if (name[0] == '\0') 65 65 str_cpy(name, MAX_NAME_LENGTH, "/"); 66 66 67 printf("%s (%" PRIun ")\n", name, funh); 67 rc = devman_fun_get_driver_name(funh, drv_name, MAX_NAME_LENGTH); 68 if (rc != EOK && rc != EINVAL) 69 return ELIMIT; 70 71 if (rc == EINVAL) 72 printf("%s\n", name); 73 else 74 printf("%s : %s\n", name, drv_name); 68 75 69 76 rc = devman_fun_get_child(funh, &devh); -
uspace/lib/c/generic/devman.c
r375e501 r3f57fb7 430 430 async_wait_for(req, &retval); 431 431 432 if (retval != EOK) 433 return retval; 432 if (retval != EOK) { 433 return retval; 434 } 434 435 435 436 act_size = IPC_GET_ARG2(dreply); … … 449 450 { 450 451 return devman_get_str_internal(DEVMAN_FUN_GET_NAME, handle, buf, 452 buf_size); 453 } 454 455 int devman_fun_get_driver_name(devman_handle_t handle, char *buf, size_t buf_size) 456 { 457 return devman_get_str_internal(DEVMAN_FUN_GET_DRIVER_NAME, handle, buf, 451 458 buf_size); 452 459 } -
uspace/lib/c/include/devman.h
r375e501 r3f57fb7 64 64 size_t *); 65 65 extern int devman_fun_get_name(devman_handle_t, char *, size_t); 66 extern int devman_fun_get_driver_name(devman_handle_t, char *, size_t); 66 67 extern int devman_fun_get_path(devman_handle_t, char *, size_t); 67 68 extern int devman_fun_online(devman_handle_t); -
uspace/lib/c/include/ipc/devman.h
r375e501 r3f57fb7 157 157 DEVMAN_FUN_GET_CHILD, 158 158 DEVMAN_FUN_GET_NAME, 159 DEVMAN_FUN_GET_DRIVER_NAME, 159 160 DEVMAN_FUN_ONLINE, 160 161 DEVMAN_FUN_OFFLINE, -
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.