Changeset c1a0488 in mainline
- Timestamp:
- 2011-09-02T15:58:02Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e2b9b341
- Parents:
- aff587f
- Location:
- uspace/srv/devman
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.c
raff587f rc1a0488 846 846 add_device(drv, dev, tree); 847 847 848 fibril_mutex_lock(&drv->driver_mutex); 849 fibril_mutex_unlock(&drv->driver_mutex); 850 851 fibril_rwlock_write_lock(&tree->rwlock); 852 if (dev->pfun != NULL) { 853 dev->pfun->state = FUN_ON_LINE; 854 } 855 fibril_rwlock_write_unlock(&tree->rwlock); 848 856 return true; 849 857 } … … 1106 1114 return NULL; 1107 1115 1116 fun->state = FUN_INIT; 1108 1117 atomic_set(&fun->refcnt, 0); 1109 1118 link_initialize(&fun->dev_functions); … … 1275 1284 dev->pfun->child = NULL; 1276 1285 dev->pfun = NULL; 1286 1287 dev->state = DEVICE_REMOVED; 1277 1288 } 1278 1289 … … 1338 1349 1339 1350 fun->dev = NULL; 1351 fun->state = FUN_REMOVED; 1340 1352 } 1341 1353 -
uspace/srv/devman/devman.h
raff587f rc1a0488 118 118 } driver_list_t; 119 119 120 /** The state of the device.*/120 /** Device state */ 121 121 typedef enum { 122 122 DEVICE_NOT_INITIALIZED = 0, 123 123 DEVICE_USABLE, 124 124 DEVICE_NOT_PRESENT, 125 DEVICE_INVALID 125 DEVICE_INVALID, 126 /** Device node has been removed from the tree */ 127 DEVICE_REMOVED 126 128 } device_state_t; 127 129 … … 157 159 }; 158 160 161 /** Function state */ 162 typedef enum { 163 FUN_INIT = 0, 164 FUN_OFF_LINE, 165 FUN_ON_LINE, 166 /** Function node has been removed from the tree */ 167 FUN_REMOVED 168 } fun_state_t; 169 159 170 /** Function node in the device tree. */ 160 171 struct fun_node { 161 172 /** Reference count */ 162 173 atomic_t refcnt; 174 /** State */ 175 fun_state_t state; 163 176 164 177 /** The global unique identifier of the function */ -
uspace/srv/devman/main.c
raff587f rc1a0488 234 234 dev_node_t *dev_node = (dev_node_t *) arg; 235 235 assign_driver(dev_node, &drivers_list, &device_tree); 236 237 /* Delete one reference we got from the caller. */ 238 dev_del_ref(dev_node); 236 239 return EOK; 237 240 } … … 243 246 fibril_rwlock_write_lock(&device_tree.rwlock); 244 247 248 if (fun->state == FUN_ON_LINE) { 249 fibril_rwlock_write_unlock(&device_tree.rwlock); 250 log_msg(LVL_WARN, "Function %s is already on line.", 251 fun->pathname); 252 return EOK; 253 } 254 245 255 if (fun->ftype == fun_inner) { 246 256 dev = create_dev_node(); … … 260 270 assert(dev != NULL); 261 271 272 /* Give one reference over to assign_driver_fibril(). */ 273 dev_add_ref(dev); 262 274 /* 263 275 * Try to find a suitable driver and assign it to the device. We do … … 269 281 fid_t assign_fibril = fibril_create(assign_driver_fibril, dev); 270 282 if (assign_fibril == 0) { 271 /* 272 * Fallback in case we are out of memory. 273 * Probably not needed as we will die soon anyway ;-). 274 */ 275 (void) assign_driver_fibril(fun); 276 } else { 277 fibril_add_ready(assign_fibril); 283 log_msg(LVL_ERROR, "Failed to create fibril for " 284 "assigning driver."); 285 /* XXX Cleanup */ 286 fibril_rwlock_write_unlock(&device_tree.rwlock); 287 return ENOMEM; 278 288 } 289 fibril_add_ready(assign_fibril); 279 290 } else { 280 291 loc_register_tree_function(fun, &device_tree); … … 291 302 292 303 fibril_rwlock_write_lock(&device_tree.rwlock); 304 305 if (fun->state == FUN_OFF_LINE) { 306 fibril_rwlock_write_unlock(&device_tree.rwlock); 307 log_msg(LVL_WARN, "Function %s is already off line.", 308 fun->pathname); 309 return EOK; 310 } 293 311 294 312 if (fun->ftype == fun_inner) { … … 329 347 } 330 348 349 fun->state = FUN_OFF_LINE; 331 350 fibril_rwlock_write_unlock(&device_tree.rwlock); 332 351
Note:
See TracChangeset
for help on using the changeset viewer.