Changes in uspace/srv/devmap/devmap.c [01b87dc5:47a7174f] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devmap/devmap.c
r01b87dc5 r47a7174f 46 46 #include <str.h> 47 47 #include <ipc/devmap.h> 48 #include <assert.h>49 48 50 49 #define NAME "devmap" … … 209 208 } 210 209 211 /** Find namespace with given name. */ 210 /** Find namespace with given name. 211 * 212 * The devices_list_mutex should be already held when 213 * calling this function. 214 * 215 */ 212 216 static devmap_namespace_t *devmap_namespace_find_name(const char *name) 213 217 { 214 218 link_t *item; 215 216 assert(fibril_mutex_is_locked(&devices_list_mutex));217 218 219 for (item = namespaces_list.next; item != &namespaces_list; item = item->next) { 219 220 devmap_namespace_t *namespace = … … 228 229 /** Find namespace with given handle. 229 230 * 231 * The devices_list_mutex should be already held when 232 * calling this function. 233 * 230 234 * @todo: use hash table 231 235 * … … 234 238 { 235 239 link_t *item; 236 237 assert(fibril_mutex_is_locked(&devices_list_mutex));238 239 240 for (item = namespaces_list.next; item != &namespaces_list; item = item->next) { 240 241 devmap_namespace_t *namespace = … … 247 248 } 248 249 249 /** Find device with given name. */ 250 /** Find device with given name. 251 * 252 * The devices_list_mutex should be already held when 253 * calling this function. 254 * 255 */ 250 256 static devmap_device_t *devmap_device_find_name(const char *ns_name, 251 257 const char *name) 252 258 { 253 259 link_t *item; 254 255 assert(fibril_mutex_is_locked(&devices_list_mutex));256 257 260 for (item = devices_list.next; item != &devices_list; item = item->next) { 258 261 devmap_device_t *device = … … 268 271 /** Find device with given handle. 269 272 * 273 * The devices_list_mutex should be already held when 274 * calling this function. 275 * 270 276 * @todo: use hash table 271 277 * … … 274 280 { 275 281 link_t *item; 276 277 assert(fibril_mutex_is_locked(&devices_list_mutex));278 279 282 for (item = devices_list.next; item != &devices_list; item = item->next) { 280 283 devmap_device_t *device = … … 287 290 } 288 291 289 /** Create a namespace (if not already present). */ 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 */ 290 298 static devmap_namespace_t *devmap_namespace_create(const char *ns_name) 291 299 { 292 devmap_namespace_t *namespace; 293 294 assert(fibril_mutex_is_locked(&devices_list_mutex)); 295 296 namespace = devmap_namespace_find_name(ns_name); 300 devmap_namespace_t *namespace = devmap_namespace_find_name(ns_name); 297 301 if (namespace != NULL) 298 302 return namespace; … … 319 323 } 320 324 321 /** Destroy a namespace (if it is no longer needed). */ 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 */ 322 331 static void devmap_namespace_destroy(devmap_namespace_t *namespace) 323 332 { 324 assert(fibril_mutex_is_locked(&devices_list_mutex));325 326 333 if (namespace->refcnt == 0) { 327 334 list_remove(&(namespace->namespaces)); … … 332 339 } 333 340 334 /** Increase namespace reference count by including device. */ 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 */ 335 347 static void devmap_namespace_addref(devmap_namespace_t *namespace, 336 348 devmap_device_t *device) 337 349 { 338 assert(fibril_mutex_is_locked(&devices_list_mutex));339 340 350 device->namespace = namespace; 341 351 namespace->refcnt++; 342 352 } 343 353 344 /** Decrease namespace reference count. */ 354 /** Decrease namespace reference count 355 * 356 * The devices_list_mutex should be already held when 357 * calling this function. 358 * 359 */ 345 360 static void devmap_namespace_delref(devmap_namespace_t *namespace) 346 361 { 347 assert(fibril_mutex_is_locked(&devices_list_mutex));348 349 362 namespace->refcnt--; 350 363 devmap_namespace_destroy(namespace); 351 364 } 352 365 353 /** Unregister device and free it. */ 366 /** Unregister device and free it 367 * 368 * The devices_list_mutex should be already held when 369 * calling this function. 370 * 371 */ 354 372 static void devmap_device_unregister_core(devmap_device_t *device) 355 373 { 356 assert(fibril_mutex_is_locked(&devices_list_mutex));357 358 374 devmap_namespace_delref(device->namespace); 359 375 list_remove(&(device->devices)); … … 607 623 608 624 if (dev->forward_interface == 0) { 625 /* The IPC_GET_ARG3(*icall) would be always zero, 626 * wouldn't it? So why to pass it at all? 627 */ 609 628 ipc_forward_fast(callid, dev->driver->phone, 610 629 dev->handle, 0, 0,
Note:
See TracChangeset
for help on using the changeset viewer.