Changeset a676574 in mainline for uspace/srv/devmap/devmap.c
- Timestamp:
- 2011-01-09T12:18:00Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 54de5ebd
- Parents:
- a3eeef45 (diff), 9d12059 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devmap/devmap.c
ra3eeef45 ra676574 46 46 #include <str.h> 47 47 #include <ipc/devmap.h> 48 #include <assert.h> 48 49 49 50 #define NAME "devmap" … … 208 209 } 209 210 210 /** Find namespace with given name. 211 * 212 * The devices_list_mutex should be already held when 213 * calling this function. 214 * 215 */ 211 /** Find namespace with given name. */ 216 212 static devmap_namespace_t *devmap_namespace_find_name(const char *name) 217 213 { 218 214 link_t *item; 215 216 assert(fibril_mutex_is_locked(&devices_list_mutex)); 217 219 218 for (item = namespaces_list.next; item != &namespaces_list; item = item->next) { 220 219 devmap_namespace_t *namespace = … … 229 228 /** Find namespace with given handle. 230 229 * 231 * The devices_list_mutex should be already held when232 * calling this function.233 *234 230 * @todo: use hash table 235 231 * … … 238 234 { 239 235 link_t *item; 236 237 assert(fibril_mutex_is_locked(&devices_list_mutex)); 238 240 239 for (item = namespaces_list.next; item != &namespaces_list; item = item->next) { 241 240 devmap_namespace_t *namespace = … … 248 247 } 249 248 250 /** Find device with given name. 251 * 252 * The devices_list_mutex should be already held when 253 * calling this function. 254 * 255 */ 249 /** Find device with given name. */ 256 250 static devmap_device_t *devmap_device_find_name(const char *ns_name, 257 251 const char *name) 258 252 { 259 253 link_t *item; 254 255 assert(fibril_mutex_is_locked(&devices_list_mutex)); 256 260 257 for (item = devices_list.next; item != &devices_list; item = item->next) { 261 258 devmap_device_t *device = … … 271 268 /** Find device with given handle. 272 269 * 273 * The devices_list_mutex should be already held when274 * calling this function.275 *276 270 * @todo: use hash table 277 271 * … … 280 274 { 281 275 link_t *item; 276 277 assert(fibril_mutex_is_locked(&devices_list_mutex)); 278 282 279 for (item = devices_list.next; item != &devices_list; item = item->next) { 283 280 devmap_device_t *device = … … 290 287 } 291 288 292 /** Create a namespace (if not already present) 293 * 294 * The devices_list_mutex should be already held when 295 * calling this function. 296 * 297 */ 289 /** Create a namespace (if not already present). */ 298 290 static devmap_namespace_t *devmap_namespace_create(const char *ns_name) 299 291 { 300 devmap_namespace_t *namespace = devmap_namespace_find_name(ns_name); 292 devmap_namespace_t *namespace; 293 294 assert(fibril_mutex_is_locked(&devices_list_mutex)); 295 296 namespace = devmap_namespace_find_name(ns_name); 301 297 if (namespace != NULL) 302 298 return namespace; … … 323 319 } 324 320 325 /** Destroy a namespace (if it is no longer needed) 326 * 327 * The devices_list_mutex should be already held when 328 * calling this function. 329 * 330 */ 321 /** Destroy a namespace (if it is no longer needed). */ 331 322 static void devmap_namespace_destroy(devmap_namespace_t *namespace) 332 323 { 324 assert(fibril_mutex_is_locked(&devices_list_mutex)); 325 333 326 if (namespace->refcnt == 0) { 334 327 list_remove(&(namespace->namespaces)); … … 339 332 } 340 333 341 /** Increase namespace reference count by including device 342 * 343 * The devices_list_mutex should be already held when 344 * calling this function. 345 * 346 */ 334 /** Increase namespace reference count by including device. */ 347 335 static void devmap_namespace_addref(devmap_namespace_t *namespace, 348 336 devmap_device_t *device) 349 337 { 338 assert(fibril_mutex_is_locked(&devices_list_mutex)); 339 350 340 device->namespace = namespace; 351 341 namespace->refcnt++; 352 342 } 353 343 354 /** Decrease namespace reference count 355 * 356 * The devices_list_mutex should be already held when 357 * calling this function. 358 * 359 */ 344 /** Decrease namespace reference count. */ 360 345 static void devmap_namespace_delref(devmap_namespace_t *namespace) 361 346 { 347 assert(fibril_mutex_is_locked(&devices_list_mutex)); 348 362 349 namespace->refcnt--; 363 350 devmap_namespace_destroy(namespace); 364 351 } 365 352 366 /** Unregister device and free it 367 * 368 * The devices_list_mutex should be already held when 369 * calling this function. 370 * 371 */ 353 /** Unregister device and free it. */ 372 354 static void devmap_device_unregister_core(devmap_device_t *device) 373 355 { 356 assert(fibril_mutex_is_locked(&devices_list_mutex)); 357 374 358 devmap_namespace_delref(device->namespace); 375 359 list_remove(&(device->devices));
Note:
See TracChangeset
for help on using the changeset viewer.