Changeset c028b22 in mainline for uspace/srv/fs/devfs/devfs_ops.c


Ignore:
Timestamp:
2011-07-08T17:01:01Z (13 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cc1a727
Parents:
4e36219 (diff), 026793d (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.
Message:

Merge mainline changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/devfs/devfs_ops.c

    r4e36219 rc028b22  
    5959typedef struct {
    6060        devmap_handle_t handle;
    61         int phone;              /**< When < 0, the structure is incomplete. */
     61        async_sess_t *sess;       /**< If NULL, the structure is incomplete. */
    6262        size_t refcount;
    6363        link_t link;
    64         fibril_condvar_t cv;    /**< Broadcast when completed. */
     64        fibril_condvar_t cv;      /**< Broadcast when completed. */
    6565} device_t;
    6666
     
    232232                };
    233233                link_t *lnk;
    234 
     234               
    235235                fibril_mutex_lock(&devices_mutex);
    236236restart:
     
    244244                       
    245245                        dev->handle = node->handle;
    246                         dev->phone = -1;        /* mark as incomplete */
     246                       
     247                        /* Mark as incomplete */
     248                        dev->sess = NULL;
    247249                        dev->refcount = 1;
    248250                        fibril_condvar_initialize(&dev->cv);
    249 
     251                       
    250252                        /*
    251253                         * Insert the incomplete device structure so that other
     
    254256                         */
    255257                        hash_table_insert(&devices, key, &dev->link);
    256 
     258                       
    257259                        /*
    258260                         * Drop the mutex to allow recursive devfs requests.
    259261                         */
    260262                        fibril_mutex_unlock(&devices_mutex);
    261 
    262                         int phone = devmap_device_connect(node->handle, 0);
    263 
     263                       
     264                        async_sess_t *sess = devmap_device_connect(EXCHANGE_SERIALIZE,
     265                            node->handle, 0);
     266                       
    264267                        fibril_mutex_lock(&devices_mutex);
    265 
     268                       
    266269                        /*
    267270                         * Notify possible waiters about this device structure
     
    269272                         */
    270273                        fibril_condvar_broadcast(&dev->cv);
    271 
    272                         if (phone < 0) {
     274                       
     275                        if (!sess) {
    273276                                /*
    274277                                 * Connecting failed, need to remove the
     
    277280                                hash_table_remove(&devices, key, DEVICES_KEYS);
    278281                                fibril_mutex_unlock(&devices_mutex);
    279 
     282                               
    280283                                return ENOENT;
    281284                        }
    282285                       
    283                         /* Set the correct phone. */
    284                         dev->phone = phone;
     286                        /* Set the correct session. */
     287                        dev->sess = sess;
    285288                } else {
    286289                        device_t *dev = hash_table_get_instance(lnk, device_t, link);
    287 
    288                         if (dev->phone < 0) {
     290                       
     291                        if (!dev->sess) {
    289292                                /*
    290293                                 * Wait until the device structure is completed
     
    608611               
    609612                device_t *dev = hash_table_get_instance(lnk, device_t, link);
    610                 assert(dev->phone >= 0);
     613                assert(dev->sess);
    611614               
    612615                ipc_callid_t callid;
     
    619622               
    620623                /* Make a request at the driver */
     624                async_exch_t *exch = async_exchange_begin(dev->sess);
     625               
    621626                ipc_call_t answer;
    622                 aid_t msg = async_send_3(dev->phone, IPC_GET_IMETHOD(*request),
     627                aid_t msg = async_send_3(exch, IPC_GET_IMETHOD(*request),
    623628                    IPC_GET_ARG1(*request), IPC_GET_ARG2(*request),
    624629                    IPC_GET_ARG3(*request), &answer);
    625630               
    626631                /* Forward the IPC_M_DATA_READ request to the driver */
    627                 async_forward_fast(callid, dev->phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
     632                async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
     633               
     634                async_exchange_end(exch);
     635               
    628636                fibril_mutex_unlock(&devices_mutex);
    629637               
     
    672680               
    673681                device_t *dev = hash_table_get_instance(lnk, device_t, link);
    674                 assert(dev->phone >= 0);
     682                assert(dev->sess);
    675683               
    676684                ipc_callid_t callid;
     
    683691               
    684692                /* Make a request at the driver */
     693                async_exch_t *exch = async_exchange_begin(dev->sess);
     694               
    685695                ipc_call_t answer;
    686                 aid_t msg = async_send_3(dev->phone, IPC_GET_IMETHOD(*request),
     696                aid_t msg = async_send_3(exch, IPC_GET_IMETHOD(*request),
    687697                    IPC_GET_ARG1(*request), IPC_GET_ARG2(*request),
    688698                    IPC_GET_ARG3(*request), &answer);
    689699               
    690700                /* Forward the IPC_M_DATA_WRITE request to the driver */
    691                 async_forward_fast(callid, dev->phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
     701                async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
     702               
     703                async_exchange_end(exch);
    692704               
    693705                fibril_mutex_unlock(&devices_mutex);
     
    742754               
    743755                device_t *dev = hash_table_get_instance(lnk, device_t, link);
    744                 assert(dev->phone >= 0);
     756                assert(dev->sess);
    745757                dev->refcount--;
    746758               
    747759                if (dev->refcount == 0) {
    748                         async_hangup(dev->phone);
     760                        async_hangup(dev->sess);
    749761                        hash_table_remove(&devices, key, DEVICES_KEYS);
    750762                }
     
    790802               
    791803                device_t *dev = hash_table_get_instance(lnk, device_t, link);
    792                 assert(dev->phone >= 0);
     804                assert(dev->sess);
    793805               
    794806                /* Make a request at the driver */
     807                async_exch_t *exch = async_exchange_begin(dev->sess);
     808               
    795809                ipc_call_t answer;
    796                 aid_t msg = async_send_2(dev->phone, IPC_GET_IMETHOD(*request),
     810                aid_t msg = async_send_2(exch, IPC_GET_IMETHOD(*request),
    797811                    IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), &answer);
     812               
     813                async_exchange_end(exch);
    798814               
    799815                fibril_mutex_unlock(&devices_mutex);
Note: See TracChangeset for help on using the changeset viewer.