Changeset a35b458 in mainline for uspace/srv/devman/devtree.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devtree.c
r3061bc1 ra35b458 127 127 fun_node_t *fun; 128 128 dev_node_t *dev; 129 129 130 130 log_msg(LOG_DEFAULT, LVL_DEBUG, "create_root_nodes()"); 131 131 132 132 fibril_rwlock_write_lock(&tree->rwlock); 133 133 134 134 /* 135 135 * Create root function. This is a pseudo function to which … … 138 138 * the parent function. 139 139 */ 140 140 141 141 fun = create_fun_node(); 142 142 if (fun == NULL) { … … 144 144 return false; 145 145 } 146 146 147 147 fun_add_ref(fun); 148 148 insert_fun_node(tree, fun, str_dup(""), NULL); 149 149 150 150 match_id_t *id = create_match_id(); 151 151 id->id = str_dup("root"); … … 153 153 add_match_id(&fun->match_ids, id); 154 154 tree->root_node = fun; 155 155 156 156 /* 157 157 * Create root device node. … … 162 162 return false; 163 163 } 164 164 165 165 dev_add_ref(dev); 166 166 insert_dev_node(tree, dev, fun); 167 167 168 168 fibril_rwlock_write_unlock(&tree->rwlock); 169 169 170 170 return dev != NULL; 171 171 } … … 182 182 { 183 183 log_msg(LOG_DEFAULT, LVL_DEBUG, "init_device_tree()"); 184 184 185 185 tree->current_handle = 0; 186 186 187 187 hash_table_create(&tree->devman_devices, 0, 0, &devman_devices_ops); 188 188 hash_table_create(&tree->devman_functions, 0, 0, &devman_functions_ops); 189 189 hash_table_create(&tree->loc_functions, 0, 0, &loc_devices_ops); 190 190 191 191 fibril_rwlock_initialize(&tree->rwlock); 192 192 193 193 /* Create root function and root device and add them to the device tree. */ 194 194 if (!create_root_nodes(tree)) 195 195 return false; 196 196 197 197 /* Find suitable driver and start it. */ 198 198 dev_node_t *rdev = tree->root_node->child; … … 200 200 bool rc = assign_driver(rdev, drivers_list, tree); 201 201 dev_del_ref(rdev); 202 202 203 203 return rc; 204 204 } … … 216 216 { 217 217 assert(fibril_rwlock_is_write_locked(&tree->rwlock)); 218 218 219 219 log_msg(LOG_DEFAULT, LVL_DEBUG, "insert_dev_node(dev=%p, pfun=%p [\"%s\"])", 220 220 dev, pfun, pfun->pathname); … … 227 227 dev->pfun = pfun; 228 228 pfun->child = dev; 229 229 230 230 return true; 231 231 } … … 239 239 { 240 240 assert(fibril_rwlock_is_write_locked(&tree->rwlock)); 241 241 242 242 log_msg(LOG_DEFAULT, LVL_DEBUG, "remove_dev_node(dev=%p)", dev); 243 243 244 244 /* Remove node from the handle-to-node map. */ 245 245 hash_table_remove(&tree->devman_devices, &dev->handle); 246 246 247 247 /* Unlink from parent function. */ 248 248 dev->pfun->child = NULL; 249 249 dev->pfun = NULL; 250 250 251 251 dev->state = DEVICE_REMOVED; 252 252 } … … 267 267 { 268 268 fun_node_t *pfun; 269 269 270 270 assert(fun_name != NULL); 271 271 assert(fibril_rwlock_is_write_locked(&tree->rwlock)); 272 272 273 273 /* 274 274 * The root function is a special case, it does not belong to any … … 276 276 */ 277 277 pfun = (dev != NULL) ? dev->pfun : NULL; 278 278 279 279 fun->name = fun_name; 280 280 if (!set_fun_path(tree, fun, pfun)) { 281 281 return false; 282 282 } 283 283 284 284 /* Add the node to the handle-to-node map. */ 285 285 fun->handle = ++tree->current_handle; … … 290 290 if (dev != NULL) 291 291 list_append(&fun->dev_functions, &dev->functions); 292 292 293 293 return true; 294 294 } … … 302 302 { 303 303 assert(fibril_rwlock_is_write_locked(&tree->rwlock)); 304 304 305 305 /* Remove the node from the handle-to-node map. */ 306 306 hash_table_remove(&tree->devman_functions, &fun->handle); 307 307 308 308 /* Remove the node from the list of its parent's children. */ 309 309 if (fun->dev != NULL) 310 310 list_remove(&fun->dev_functions); 311 311 312 312 fun->dev = NULL; 313 313 fun->state = FUN_REMOVED;
Note:
See TracChangeset
for help on using the changeset viewer.