Changeset cd0684d in mainline
- Timestamp:
- 2011-02-14T22:14:52Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 659ca07
- Parents:
- 97a62fe
- Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/isa/isa.c
r97a62fe rcd0684d 44 44 #include <stdlib.h> 45 45 #include <str.h> 46 #include <str_error.h> 46 47 #include <ctype.h> 47 48 #include <macros.h> … … 324 325 int score = 0; 325 326 char *end = NULL; 327 int rc; 326 328 327 329 val = skip_spaces(val); … … 334 336 } 335 337 336 match_id_t *match_id = create_match_id();337 if (match_id == NULL) {338 printf(NAME " : failed to allocate match id for function %s.\n",339 fun->fnode->name);340 return;341 }342 343 338 val = skip_spaces(end); 344 339 get_match_id(&id, val); … … 346 341 printf(NAME " : error - could not read match id for " 347 342 "function %s.\n", fun->fnode->name); 348 delete_match_id(match_id);349 343 return; 350 344 } 351 352 match_id->id = id;353 match_id->score = score;354 345 355 346 printf(NAME ": adding match id '%s' with score %d to function %s\n", id, 356 347 score, fun->fnode->name); 357 add_match_id(&fun->fnode->match_ids, match_id); 348 349 rc = ddf_fun_add_match_id(fun->fnode, id, score); 350 if (rc != EOK) 351 printf(NAME ": error adding match ID: %s\n", str_error(rc)); 358 352 } 359 353 -
uspace/drv/pciintel/pci.c
r97a62fe rcd0684d 45 45 #include <ctype.h> 46 46 #include <macros.h> 47 #include <str_error.h> 47 48 48 49 #include <driver.h> … … 217 218 void pci_fun_create_match_ids(pci_fun_t *fun) 218 219 { 219 match_id_t *match_id = NULL;220 220 char *match_id_str; 221 222 match_id = create_match_id(); 223 if (match_id != NULL) { 224 asprintf(&match_id_str, "pci/ven=%04x&dev=%04x", 225 fun->vendor_id, fun->device_id); 226 match_id->id = match_id_str; 227 match_id->score = 90; 228 add_match_id(&fun->fnode->match_ids, match_id); 221 int rc; 222 223 asprintf(&match_id_str, "pci/ven=%04x&dev=%04x", 224 fun->vendor_id, fun->device_id); 225 226 if (match_id_str == NULL) { 227 printf(NAME ": out of memory creating match ID.\n"); 228 return; 229 } 230 231 rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 90); 232 if (rc != EOK) { 233 printf(NAME ": error adding match ID: %s\n", 234 str_error(rc)); 229 235 } 230 236 -
uspace/drv/rootvirt/rootvirt.c
r97a62fe rcd0684d 80 80 static int rootvirt_add_fun(device_t *vdev, virtual_function_t *vfun) 81 81 { 82 function_t *fun; 83 int rc; 84 82 85 printf(NAME ": registering function `%s' (match \"%s\")\n", 83 86 vfun->name, vfun->match_id); 84 87 85 int rc = register_function_wrapper(vdev, vfun->name, 86 vfun->match_id, 10); 87 88 if (rc == EOK) { 89 printf(NAME ": registered child device `%s'\n", 90 vfun->name); 91 } else { 92 printf(NAME ": failed to register child device `%s': %s\n", 93 vfun->name, str_error(rc)); 88 fun = ddf_fun_create(vdev, fun_inner, vfun->name); 89 if (fun == NULL) { 90 printf(NAME ": error creating function %s\n", vfun->name); 91 return ENOMEM; 94 92 } 95 93 96 return rc; 94 rc = ddf_fun_add_match_id(fun, vfun->match_id, 10); 95 if (rc != EOK) { 96 printf(NAME ": error adding match IDs to function %s\n", 97 vfun->name); 98 ddf_fun_destroy(fun); 99 return rc; 100 } 101 102 rc = ddf_fun_bind(fun); 103 if (rc != EOK) { 104 printf(NAME ": error binding function %s: %s\n", vfun->name, 105 str_error(rc)); 106 ddf_fun_destroy(fun); 107 return rc; 108 } 109 110 printf(NAME ": registered child device `%s'\n", vfun->name); 111 return EOK; 97 112 } 98 113 -
uspace/drv/test1/test1.c
r97a62fe rcd0684d 55 55 * @param score Device match score. 56 56 */ 57 static voidregister_fun_verbose(device_t *parent, const char *message,57 static int register_fun_verbose(device_t *parent, const char *message, 58 58 const char *name, const char *match_id, int match_score) 59 59 { 60 printf(NAME ": registering child device `%s': %s.\n",61 name, message);60 function_t *fun; 61 int rc; 62 62 63 int rc = register_function_wrapper(parent, name, 64 match_id, match_score); 63 printf(NAME ": registering function `%s': %s.\n", name, message); 65 64 66 if (rc == EOK) { 67 printf(NAME ": registered function `%s'.\n", name); 68 } else { 69 printf(NAME ": failed to register function `%s' (%s).\n", 70 name, str_error(rc)); 65 fun = ddf_fun_create(parent, fun_inner, name); 66 if (fun == NULL) { 67 printf(NAME ": error creating function %s\n", name); 68 return ENOMEM; 71 69 } 70 71 rc = ddf_fun_add_match_id(fun, match_id, match_score); 72 if (rc != EOK) { 73 printf(NAME ": error adding match IDs to function %s\n", name); 74 ddf_fun_destroy(fun); 75 return rc; 76 } 77 78 rc = ddf_fun_bind(fun); 79 if (rc != EOK) { 80 printf(NAME ": error binding function %s: %s\n", name, 81 str_error(rc)); 82 ddf_fun_destroy(fun); 83 return rc; 84 } 85 86 printf(NAME ": registered child device `%s'\n", name); 87 return EOK; 72 88 } 73 89 … … 115 131 add_function_to_class(fun_a, "virt-null"); 116 132 } else if (str_cmp(dev->name, "test1") == 0) { 117 register_fun_verbose(dev, "cloning myself ;-)", "clone",133 (void) register_fun_verbose(dev, "cloning myself ;-)", "clone", 118 134 "virtual&test1", 10); 119 135 } else if (str_cmp(dev->name, "clone") == 0) { 120 register_fun_verbose(dev, "run by the same task", "child",136 (void) register_fun_verbose(dev, "run by the same task", "child", 121 137 "virtual&test1&child", 10); 122 138 } -
uspace/drv/test2/test2.c
r97a62fe rcd0684d 57 57 * @param score Device match score. 58 58 */ 59 static void register_child_verbose(device_t *parent, const char *message,59 static int register_fun_verbose(device_t *parent, const char *message, 60 60 const char *name, const char *match_id, int match_score) 61 61 { 62 printf(NAME ": registering child device `%s': %s.\n",63 name, message);62 function_t *fun; 63 int rc; 64 64 65 int rc = register_function_wrapper(parent, name, 66 match_id, match_score); 65 printf(NAME ": registering function `%s': %s.\n", name, message); 67 66 68 if (rc == EOK) { 69 printf(NAME ": registered child device `%s'.\n", name); 70 } else { 71 printf(NAME ": failed to register child `%s' (%s).\n", 72 name, str_error(rc)); 67 fun = ddf_fun_create(parent, fun_inner, name); 68 if (fun == NULL) { 69 printf(NAME ": error creating function %s\n", name); 70 return ENOMEM; 73 71 } 72 73 rc = ddf_fun_add_match_id(fun, match_id, match_score); 74 if (rc != EOK) { 75 printf(NAME ": error adding match IDs to function %s\n", name); 76 ddf_fun_destroy(fun); 77 return rc; 78 } 79 80 rc = ddf_fun_bind(fun); 81 if (rc != EOK) { 82 printf(NAME ": error binding function %s: %s\n", name, 83 str_error(rc)); 84 ddf_fun_destroy(fun); 85 return rc; 86 } 87 88 printf(NAME ": registered child device `%s'\n", name); 89 return EOK; 74 90 } 75 91 … … 87 103 async_usleep(1000); 88 104 89 register_child_verbose(dev, "child driven by the same task",105 (void) register_fun_verbose(dev, "child driven by the same task", 90 106 "child", "virtual&test2", 10); 91 register_child_verbose(dev, "child driven by test1",107 (void) register_fun_verbose(dev, "child driven by test1", 92 108 "test1", "virtual&test1", 10); 93 109 … … 122 138 fibril_add_ready(postpone); 123 139 } else { 124 register_child_verbose(dev, "child without available driver",140 (void) register_fun_verbose(dev, "child without available driver", 125 141 "ERROR", "non-existent.match.id", 10); 126 142 } -
uspace/lib/drv/generic/driver.c
r97a62fe rcd0684d 607 607 } 608 608 609 /** Add single match ID to function. 610 * 611 * Construct and add a single match ID to the specified function. 612 * 613 * @param fun Function 614 * @param match_id_str Match string 615 * @param match_score Match score 616 * @return EOK on success, ENOMEM if out of memory. 617 */ 618 int ddf_fun_add_match_id(function_t *fun, const char *match_id_str, 619 int match_score) 620 { 621 match_id_t *match_id; 622 623 match_id = create_match_id(); 624 if (match_id == NULL) 625 return ENOMEM; 626 627 match_id->id = match_id_str; 628 match_id->score = 90; 629 630 add_match_id(&fun->match_ids, match_id); 631 return EOK; 632 } 633 634 609 635 /** Wrapper for child_device_register for devices with single match id. 610 636 * -
uspace/lib/drv/include/driver.h
r97a62fe rcd0684d 162 162 extern void ddf_fun_destroy(function_t *); 163 163 extern int ddf_fun_bind(function_t *); 164 extern int ddf_fun_add_match_id(function_t *, const char *, int); 164 165 165 166 extern void *function_get_ops(function_t *, dev_inferface_idx_t);
Note:
See TracChangeset
for help on using the changeset viewer.