Changes in / [23cdcc6f:6118ccaf] in mainline
- Location:
- uspace
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/devmap.c
r23cdcc6f r6118ccaf 279 279 280 280 if (flags & IPC_FLAG_BLOCKING) { 281 phone = async_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP,281 phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP, 282 282 DEVMAP_CONNECT_TO_DEVICE, handle); 283 283 } else { 284 phone = async_connect_me_to(PHONE_NS, SERVICE_DEVMAP,284 phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, 285 285 DEVMAP_CONNECT_TO_DEVICE, handle); 286 286 } -
uspace/srv/fs/devfs/devfs_ops.c
r23cdcc6f r6118ccaf 60 60 typedef struct { 61 61 devmap_handle_t handle; 62 int phone; /**< When < 0, the structure is incomplete. */62 int phone; 63 63 size_t refcount; 64 64 link_t link; 65 fibril_condvar_t cv; /**< Broadcast when completed. */66 65 } device_t; 67 66 … … 228 227 [DEVICES_KEY_HANDLE] = (unsigned long) node->handle 229 228 }; 230 link_t *lnk; 231 229 232 230 fibril_mutex_lock(&devices_mutex); 233 restart: 234 lnk = hash_table_find(&devices, key); 231 link_t *lnk = hash_table_find(&devices, key); 235 232 if (lnk == NULL) { 236 233 device_t *dev = (device_t *) malloc(sizeof(device_t)); … … 240 237 } 241 238 242 dev->handle = node->handle;243 dev->phone = -1; /* mark as incomplete */244 dev->refcount = 1;245 fibril_condvar_initialize(&dev->cv);246 247 /*248 * Insert the incomplete device structure so that other249 * fibrils will not race with us when we drop the mutex250 * below.251 */252 hash_table_insert(&devices, key, &dev->link);253 254 /*255 * Drop the mutex to allow recursive devfs requests.256 */257 fibril_mutex_unlock(&devices_mutex);258 259 239 int phone = devmap_device_connect(node->handle, 0); 260 261 fibril_mutex_lock(&devices_mutex);262 263 /*264 * Notify possible waiters about this device structure265 * being completed (or destroyed).266 */267 fibril_condvar_broadcast(&dev->cv);268 269 240 if (phone < 0) { 270 /*271 * Connecting failed, need to remove the272 * entry and free the device structure.273 */274 hash_table_remove(&devices, key, DEVICES_KEYS);275 241 fibril_mutex_unlock(&devices_mutex); 276 277 242 free(dev); 278 243 return ENOENT; 279 244 } 280 245 281 /* Set the correct phone. */246 dev->handle = node->handle; 282 247 dev->phone = phone; 248 dev->refcount = 1; 249 250 hash_table_insert(&devices, key, &dev->link); 283 251 } else { 284 252 device_t *dev = hash_table_get_instance(lnk, device_t, link); 285 286 if (dev->phone < 0) {287 /*288 * Wait until the device structure is completed289 * and start from the beginning as the device290 * structure might have entirely disappeared291 * while we were not holding the mutex in292 * fibril_condvar_wait().293 */294 fibril_condvar_wait(&dev->cv, &devices_mutex);295 goto restart;296 }297 298 253 dev->refcount++; 299 254 } … … 609 564 610 565 device_t *dev = hash_table_get_instance(lnk, device_t, link); 611 assert(dev->phone >= 0);612 566 613 567 ipc_callid_t callid; … … 673 627 674 628 device_t *dev = hash_table_get_instance(lnk, device_t, link); 675 assert(dev->phone >= 0);676 629 677 630 ipc_callid_t callid; … … 743 696 744 697 device_t *dev = hash_table_get_instance(lnk, device_t, link); 745 assert(dev->phone >= 0);746 698 dev->refcount--; 747 699 … … 791 743 792 744 device_t *dev = hash_table_get_instance(lnk, device_t, link); 793 assert(dev->phone >= 0);794 745 795 746 /* Make a request at the driver */
Note:
See TracChangeset
for help on using the changeset viewer.