Changes in uspace/drv/test1/test1.c [3fddb55:fc51296] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/test1/test1.c
r3fddb55 rfc51296 35 35 #include <str_error.h> 36 36 #include <ddf/driver.h> 37 #include <ddf/log.h> 37 38 38 39 #include "test1.h" … … 58 59 */ 59 60 static int register_fun_verbose(ddf_dev_t *parent, const char *message, 60 const char *name, const char *match_id, int match_score, 61 int expected_rc) 61 const char *name, const char *match_id, int match_score) 62 62 { 63 ddf_fun_t *fun = NULL;63 ddf_fun_t *fun; 64 64 int rc; 65 65 66 printf(NAME ": registering function `%s': %s.\n", name, message);66 ddf_msg(LVL_DEBUG, "Registering function `%s': %s.\n", name, message); 67 67 68 68 fun = ddf_fun_create(parent, fun_inner, name); 69 69 if (fun == NULL) { 70 printf(NAME ": error creating function %s\n", name); 71 rc = ENOMEM; 72 goto leave; 70 ddf_msg(LVL_ERROR, "Failed creating function %s\n", name); 71 return ENOMEM; 73 72 } 74 73 75 rc = ddf_fun_add_match_id(fun, str_dup(match_id), match_score);74 rc = ddf_fun_add_match_id(fun, match_id, match_score); 76 75 if (rc != EOK) { 77 printf(NAME ": error adding match IDs to function %s\n", name); 78 goto leave; 76 ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s\n", 77 name); 78 ddf_fun_destroy(fun); 79 return rc; 79 80 } 80 81 81 82 rc = ddf_fun_bind(fun); 82 83 if (rc != EOK) { 83 printf(NAME ": errorbinding function %s: %s\n", name,84 ddf_msg(LVL_ERROR, "Failed binding function %s: %s\n", name, 84 85 str_error(rc)); 85 goto leave; 86 ddf_fun_destroy(fun); 87 return rc; 86 88 } 87 89 88 printf(NAME ": registered child device `%s'\n", name); 89 rc = EOK; 90 91 92 leave: 93 if (rc != expected_rc) { 94 fprintf(stderr, 95 NAME ": Unexpected error registering function `%s'.\n" \ 96 NAME ": Expected \"%s\" but got \"%s\".\n", 97 name, str_error(expected_rc), str_error(rc)); 98 } 99 100 if ((rc != EOK) && (fun != NULL)) { 101 ddf_fun_destroy(fun); 102 } 103 104 return rc; 90 ddf_msg(LVL_NOTE, "Registered child device `%s'\n", name); 91 return EOK; 105 92 } 106 93 … … 127 114 int rc; 128 115 129 printf(NAME ":add_device(name=\"%s\", handle=%d)\n",116 ddf_msg(LVL_DEBUG, "add_device(name=\"%s\", handle=%d)\n", 130 117 dev->name, (int) dev->handle); 131 118 132 119 fun_a = ddf_fun_create(dev, fun_exposed, "a"); 133 120 if (fun_a == NULL) { 134 printf(NAME ": errorcreating function 'a'.\n");121 ddf_msg(LVL_ERROR, "Failed creating function 'a'.\n"); 135 122 return ENOMEM; 136 123 } … … 138 125 rc = ddf_fun_bind(fun_a); 139 126 if (rc != EOK) { 140 printf(NAME ": errorbinding function 'a'.\n");127 ddf_msg(LVL_ERROR, "Failed binding function 'a'.\n"); 141 128 return rc; 142 129 } … … 148 135 ddf_fun_add_to_class(fun_a, "virt-null"); 149 136 } else if (str_cmp(dev->name, "test1") == 0) { 150 (void) register_fun_verbose(dev, 151 "cloning myself ;-)", "clone", 152 "virtual&test1", 10, EOK); 153 (void) register_fun_verbose(dev, 154 "cloning myself twice ;-)", "clone", 155 "virtual&test1", 10, EEXISTS); 137 (void) register_fun_verbose(dev, "cloning myself ;-)", "clone", 138 "virtual&test1", 10); 156 139 } else if (str_cmp(dev->name, "clone") == 0) { 157 (void) register_fun_verbose(dev, 158 "run by the same task", "child", 159 "virtual&test1&child", 10, EOK); 140 (void) register_fun_verbose(dev, "run by the same task", "child", 141 "virtual&test1&child", 10); 160 142 } 161 143 162 printf(NAME ": device `%s' accepted.\n", dev->name);144 ddf_msg(LVL_DEBUG, "Device `%s' accepted.\n", dev->name); 163 145 164 146 return EOK; … … 168 150 { 169 151 printf(NAME ": HelenOS test1 virtual device driver\n"); 152 ddf_log_init(NAME, LVL_ERROR); 170 153 return ddf_driver_main(&test1_driver); 171 154 }
Note:
See TracChangeset
for help on using the changeset viewer.