Changeset 80a96d2 in mainline for uspace/drv/test/test2/test2.c
- Timestamp:
- 2011-09-05T21:26:47Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b33870b
- Parents:
- 16cc9a6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/test/test2/test2.c
r16cc9a6 r80a96d2 42 42 static int test2_add_device(ddf_dev_t *dev); 43 43 static int test2_dev_remove(ddf_dev_t *dev); 44 static int test2_dev_gone(ddf_dev_t *dev); 44 45 static int test2_fun_online(ddf_fun_t *fun); 45 46 static int test2_fun_offline(ddf_fun_t *fun); … … 48 49 .add_device = &test2_add_device, 49 50 .dev_remove = &test2_dev_remove, 51 .dev_gone = &test2_dev_gone, 50 52 .fun_online = &test2_fun_online, 51 53 .fun_offline = &test2_fun_offline … … 111 113 } 112 114 113 /** Add child devices after some sleep.115 /** Simulate plugging and surprise unplugging. 114 116 * 115 117 * @param arg Parent device structure (ddf_dev_t *). 116 118 * @return Always EOK. 117 119 */ 118 static int p ostponed_birth(void *arg)120 static int plug_unplug(void *arg) 119 121 { 120 122 test2_t *test2 = (test2_t *) arg; … … 144 146 test2->fun_a = fun_a; 145 147 148 async_usleep(10000000); 149 150 ddf_msg(LVL_NOTE, "Unbinding function test1."); 151 ddf_fun_unbind(test2->test1); 152 async_usleep(1000000); 153 ddf_msg(LVL_NOTE, "Unbinding function child."); 154 ddf_fun_unbind(test2->child); 155 146 156 return EOK; 147 157 } … … 158 168 } 159 169 170 rc = ddf_fun_unbind(fun); 171 if (rc != EOK) { 172 ddf_msg(LVL_ERROR, "Failed unbinding function '%s'.", name); 173 return rc; 174 } 175 176 ddf_fun_destroy(fun); 177 return EOK; 178 } 179 180 static int fun_unbind(ddf_fun_t *fun, const char *name) 181 { 182 int rc; 183 184 ddf_msg(LVL_DEBUG, "fun_unbind(%p, '%s')", fun, name); 160 185 rc = ddf_fun_unbind(fun); 161 186 if (rc != EOK) { … … 184 209 185 210 if (str_cmp(dev->name, "child") != 0) { 186 fid_t postpone = fibril_create(p ostponed_birth, test2);211 fid_t postpone = fibril_create(plug_unplug, test2); 187 212 if (postpone == 0) { 188 213 ddf_msg(LVL_ERROR, "fibril_create() failed."); … … 232 257 } 233 258 259 static int test2_dev_gone(ddf_dev_t *dev) 260 { 261 test2_t *test2 = (test2_t *)dev->driver_data; 262 int rc; 263 264 ddf_msg(LVL_DEBUG, "test2_dev_gone(%p)", dev); 265 266 if (test2->fun_a != NULL) { 267 rc = fun_unbind(test2->fun_a, "a"); 268 if (rc != EOK) 269 return rc; 270 } 271 272 if (test2->fun_err != NULL) { 273 rc = fun_unbind(test2->fun_err, "ERROR"); 274 if (rc != EOK) 275 return rc; 276 } 277 278 if (test2->child != NULL) { 279 rc = fun_unbind(test2->child, "child"); 280 if (rc != EOK) 281 return rc; 282 } 283 284 if (test2->test1 != NULL) { 285 rc = fun_unbind(test2->test1, "test1"); 286 if (rc != EOK) 287 return rc; 288 } 289 290 return EOK; 291 } 292 234 293 235 294 static int test2_fun_online(ddf_fun_t *fun) … … 248 307 { 249 308 printf(NAME ": HelenOS test2 virtual device driver\n"); 250 ddf_log_init(NAME, LVL_ ERROR);309 ddf_log_init(NAME, LVL_NOTE); 251 310 return ddf_driver_main(&test2_driver); 252 311 }
Note:
See TracChangeset
for help on using the changeset viewer.