Changeset 659ca07 in mainline
- Timestamp:
- 2011-02-14T22:22:54Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 34588a80
- Parents:
- cd0684d
- Location:
- uspace
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/root/root.c
rcd0684d r659ca07 45 45 #include <stdlib.h> 46 46 #include <str.h> 47 #include <str_error.h> 47 48 #include <ctype.h> 48 49 #include <macros.h> … … 84 85 static int add_virtual_root_fun(device_t *dev) 85 86 { 87 const char *name = VIRTUAL_FUN_NAME; 88 function_t *fun; 89 int rc; 90 86 91 printf(NAME ": adding new function for virtual devices.\n"); 87 printf(NAME ": function node is `%s' (%d %s)\n", VIRTUAL_FUN_NAME,92 printf(NAME ": function node is `%s' (%d %s)\n", name, 88 93 VIRTUAL_FUN_MATCH_SCORE, VIRTUAL_FUN_MATCH_ID); 89 94 90 int res = register_function_wrapper(dev, VIRTUAL_FUN_NAME, 91 VIRTUAL_FUN_MATCH_ID, VIRTUAL_FUN_MATCH_SCORE); 92 93 return res; 95 fun = ddf_fun_create(dev, fun_inner, name); 96 if (fun == NULL) { 97 printf(NAME ": error creating function %s\n", name); 98 return ENOMEM; 99 } 100 101 rc = ddf_fun_add_match_id(fun, VIRTUAL_FUN_MATCH_ID, 102 VIRTUAL_FUN_MATCH_SCORE); 103 if (rc != EOK) { 104 printf(NAME ": error adding match IDs to function %s\n", name); 105 ddf_fun_destroy(fun); 106 return rc; 107 } 108 109 rc = ddf_fun_bind(fun); 110 if (rc != EOK) { 111 printf(NAME ": error binding function %s: %s\n", name, 112 str_error(rc)); 113 ddf_fun_destroy(fun); 114 return rc; 115 } 116 117 return EOK; 94 118 } 95 119 … … 104 128 char *platform; 105 129 size_t platform_size; 106 int res; 130 131 const char *name = PLATFORM_FUN_NAME; 132 function_t *fun; 133 int rc; 107 134 108 135 /* Get platform name from sysinfo. */ … … 133 160 PLATFORM_FUN_MATCH_SCORE, match_id); 134 161 135 res = register_function_wrapper(dev, PLATFORM_FUN_NAME, 136 match_id, PLATFORM_FUN_MATCH_SCORE); 137 138 return res; 162 fun = ddf_fun_create(dev, fun_inner, name); 163 if (fun == NULL) { 164 printf(NAME ": error creating function %s\n", name); 165 return ENOMEM; 166 } 167 168 rc = ddf_fun_add_match_id(fun, match_id, PLATFORM_FUN_MATCH_SCORE); 169 if (rc != EOK) { 170 printf(NAME ": error adding match IDs to function %s\n", name); 171 ddf_fun_destroy(fun); 172 return rc; 173 } 174 175 rc = ddf_fun_bind(fun); 176 if (rc != EOK) { 177 printf(NAME ": error binding function %s: %s\n", name, 178 str_error(rc)); 179 ddf_fun_destroy(fun); 180 return rc; 181 } 182 183 return EOK; 139 184 } 140 185 -
uspace/lib/drv/generic/driver.c
rcd0684d r659ca07 632 632 } 633 633 634 635 /** Wrapper for child_device_register for devices with single match id.636 *637 * @param parent Parent device.638 * @param child_name Child device name.639 * @param child_match_id Child device match id.640 * @param child_match_score Child device match score.641 * @return Error code.642 */643 int register_function_wrapper(device_t *dev, const char *fun_name,644 const char *match_id, int match_score)645 {646 function_t *fun = NULL;647 match_id_t *m_id = NULL;648 int rc;649 650 fun = ddf_fun_create(dev, fun_inner, fun_name);651 if (fun == NULL) {652 rc = ENOMEM;653 goto failure;654 }655 656 m_id = create_match_id();657 if (m_id == NULL) {658 rc = ENOMEM;659 goto failure;660 }661 662 m_id->id = match_id;663 m_id->score = match_score;664 add_match_id(&fun->match_ids, m_id);665 666 rc = ddf_fun_bind(fun);667 if (rc != EOK)668 goto failure;669 670 return EOK;671 672 failure:673 if (m_id != NULL) {674 m_id->id = NULL;675 delete_match_id(m_id);676 }677 678 if (fun != NULL) {679 fun->name = NULL;680 delete_function(fun);681 }682 683 return rc;684 }685 686 634 /** Get default handler for client requests */ 687 635 remote_handler_t *function_get_default_handler(function_t *fun) -
uspace/lib/drv/include/driver.h
rcd0684d r659ca07 166 166 extern void *function_get_ops(function_t *, dev_inferface_idx_t); 167 167 168 extern int register_function_wrapper(device_t *, const char *, const char *,169 int);170 171 168 /* 172 169 * Interrupts
Note:
See TracChangeset
for help on using the changeset viewer.