Changes in uspace/srv/fs/devfs/devfs_ops.c [79ae36dd:cfd630af] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/devfs/devfs_ops.c
r79ae36dd rcfd630af 59 59 typedef struct { 60 60 devmap_handle_t handle; 61 async_sess_t *sess; /**< If NULL, the structure is incomplete. */61 int phone; /**< When < 0, the structure is incomplete. */ 62 62 size_t refcount; 63 63 link_t link; 64 fibril_condvar_t cv; 64 fibril_condvar_t cv; /**< Broadcast when completed. */ 65 65 } device_t; 66 66 … … 232 232 }; 233 233 link_t *lnk; 234 234 235 235 fibril_mutex_lock(&devices_mutex); 236 236 restart: … … 244 244 245 245 dev->handle = node->handle; 246 247 /* Mark as incomplete */ 248 dev->sess = NULL; 246 dev->phone = -1; /* mark as incomplete */ 249 247 dev->refcount = 1; 250 248 fibril_condvar_initialize(&dev->cv); 251 249 252 250 /* 253 251 * Insert the incomplete device structure so that other … … 256 254 */ 257 255 hash_table_insert(&devices, key, &dev->link); 258 256 259 257 /* 260 258 * Drop the mutex to allow recursive devfs requests. 261 259 */ 262 260 fibril_mutex_unlock(&devices_mutex); 263 264 async_sess_t *sess = devmap_device_connect(EXCHANGE_SERIALIZE, 265 node->handle, 0); 266 261 262 int phone = devmap_device_connect(node->handle, 0); 263 267 264 fibril_mutex_lock(&devices_mutex); 268 265 269 266 /* 270 267 * Notify possible waiters about this device structure … … 272 269 */ 273 270 fibril_condvar_broadcast(&dev->cv); 274 275 if ( !sess) {271 272 if (phone < 0) { 276 273 /* 277 274 * Connecting failed, need to remove the … … 280 277 hash_table_remove(&devices, key, DEVICES_KEYS); 281 278 fibril_mutex_unlock(&devices_mutex); 282 279 283 280 return ENOENT; 284 281 } 285 282 286 /* Set the correct session. */287 dev-> sess = sess;283 /* Set the correct phone. */ 284 dev->phone = phone; 288 285 } else { 289 286 device_t *dev = hash_table_get_instance(lnk, device_t, link); 290 291 if ( !dev->sess) {287 288 if (dev->phone < 0) { 292 289 /* 293 290 * Wait until the device structure is completed … … 611 608 612 609 device_t *dev = hash_table_get_instance(lnk, device_t, link); 613 assert(dev-> sess);610 assert(dev->phone >= 0); 614 611 615 612 ipc_callid_t callid; … … 622 619 623 620 /* Make a request at the driver */ 624 async_exch_t *exch = async_exchange_begin(dev->sess);625 626 621 ipc_call_t answer; 627 aid_t msg = async_send_3( exch, IPC_GET_IMETHOD(*request),622 aid_t msg = async_send_3(dev->phone, IPC_GET_IMETHOD(*request), 628 623 IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), 629 624 IPC_GET_ARG3(*request), &answer); 630 625 631 626 /* Forward the IPC_M_DATA_READ request to the driver */ 632 async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 633 634 async_exchange_end(exch); 635 627 async_forward_fast(callid, dev->phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 636 628 fibril_mutex_unlock(&devices_mutex); 637 629 … … 680 672 681 673 device_t *dev = hash_table_get_instance(lnk, device_t, link); 682 assert(dev-> sess);674 assert(dev->phone >= 0); 683 675 684 676 ipc_callid_t callid; … … 691 683 692 684 /* Make a request at the driver */ 693 async_exch_t *exch = async_exchange_begin(dev->sess);694 695 685 ipc_call_t answer; 696 aid_t msg = async_send_3( exch, IPC_GET_IMETHOD(*request),686 aid_t msg = async_send_3(dev->phone, IPC_GET_IMETHOD(*request), 697 687 IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), 698 688 IPC_GET_ARG3(*request), &answer); 699 689 700 690 /* Forward the IPC_M_DATA_WRITE request to the driver */ 701 async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 702 703 async_exchange_end(exch); 691 async_forward_fast(callid, dev->phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); 704 692 705 693 fibril_mutex_unlock(&devices_mutex); … … 754 742 755 743 device_t *dev = hash_table_get_instance(lnk, device_t, link); 756 assert(dev-> sess);744 assert(dev->phone >= 0); 757 745 dev->refcount--; 758 746 759 747 if (dev->refcount == 0) { 760 async_hangup(dev-> sess);748 async_hangup(dev->phone); 761 749 hash_table_remove(&devices, key, DEVICES_KEYS); 762 750 } … … 802 790 803 791 device_t *dev = hash_table_get_instance(lnk, device_t, link); 804 assert(dev-> sess);792 assert(dev->phone >= 0); 805 793 806 794 /* Make a request at the driver */ 807 async_exch_t *exch = async_exchange_begin(dev->sess);808 809 795 ipc_call_t answer; 810 aid_t msg = async_send_2( exch, IPC_GET_IMETHOD(*request),796 aid_t msg = async_send_2(dev->phone, IPC_GET_IMETHOD(*request), 811 797 IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), &answer); 812 813 async_exchange_end(exch);814 798 815 799 fibril_mutex_unlock(&devices_mutex);
Note:
See TracChangeset
for help on using the changeset viewer.