Ignore:
File:
1 edited

Legend:

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

    ra7e04d16 r991f645  
    6060typedef struct {
    6161        devmap_handle_t handle;
    62         int phone;              /**< When < 0, the structure is incomplete. */
     62        int phone;
    6363        size_t refcount;
    6464        link_t link;
    65         fibril_condvar_t cv;    /**< Broadcast when completed. */
    6665} device_t;
    6766
     
    228227                        [DEVICES_KEY_HANDLE] = (unsigned long) node->handle
    229228                };
    230                 link_t *lnk;
    231 
     229               
    232230                fibril_mutex_lock(&devices_mutex);
    233 restart:
    234                 lnk = hash_table_find(&devices, key);
     231                link_t *lnk = hash_table_find(&devices, key);
    235232                if (lnk == NULL) {
    236233                        device_t *dev = (device_t *) malloc(sizeof(device_t));
     
    240237                        }
    241238                       
    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 other
    249                          * fibrils will not race with us when we drop the mutex
    250                          * 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 
    259239                        int phone = devmap_device_connect(node->handle, 0);
    260 
    261                         fibril_mutex_lock(&devices_mutex);
    262 
    263                         /*
    264                          * Notify possible waiters about this device structure
    265                          * being completed (or destroyed).
    266                          */
    267                         fibril_condvar_broadcast(&dev->cv);
    268 
    269240                        if (phone < 0) {
    270                                 /*
    271                                  * Connecting failed, need to remove the
    272                                  * entry and free the device structure.
    273                                  */
    274                                 hash_table_remove(&devices, key, DEVICES_KEYS);
    275241                                fibril_mutex_unlock(&devices_mutex);
    276 
    277242                                free(dev);
    278243                                return ENOENT;
    279244                        }
    280245                       
    281                         /* Set the correct phone. */
     246                        dev->handle = node->handle;
    282247                        dev->phone = phone;
     248                        dev->refcount = 1;
     249                       
     250                        hash_table_insert(&devices, key, &dev->link);
    283251                } else {
    284252                        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 completed
    289                                  * and start from the beginning as the device
    290                                  * structure might have entirely disappeared
    291                                  * while we were not holding the mutex in
    292                                  * fibril_condvar_wait().
    293                                  */
    294                                 fibril_condvar_wait(&dev->cv, &devices_mutex);
    295                                 goto restart;
    296                         }
    297 
    298253                        dev->refcount++;
    299254                }
     
    465420       
    466421        /* Accept the mount options */
    467         sysarg_t retval = async_data_write_accept((void **) &opts, true, 0, 0,
     422        ipcarg_t retval = async_data_write_accept((void **) &opts, true, 0, 0,
    468423            0, NULL);
    469424        if (retval != EOK) {
     
    609564               
    610565                device_t *dev = hash_table_get_instance(lnk, device_t, link);
    611                 assert(dev->phone >= 0);
    612566               
    613567                ipc_callid_t callid;
     
    621575                /* Make a request at the driver */
    622576                ipc_call_t answer;
    623                 aid_t msg = async_send_3(dev->phone, IPC_GET_IMETHOD(*request),
     577                aid_t msg = async_send_3(dev->phone, IPC_GET_METHOD(*request),
    624578                    IPC_GET_ARG1(*request), IPC_GET_ARG2(*request),
    625579                    IPC_GET_ARG3(*request), &answer);
     
    630584               
    631585                /* Wait for reply from the driver. */
    632                 sysarg_t rc;
     586                ipcarg_t rc;
    633587                async_wait_for(msg, &rc);
    634588                size_t bytes = IPC_GET_ARG1(answer);
     
    673627               
    674628                device_t *dev = hash_table_get_instance(lnk, device_t, link);
    675                 assert(dev->phone >= 0);
    676629               
    677630                ipc_callid_t callid;
     
    685638                /* Make a request at the driver */
    686639                ipc_call_t answer;
    687                 aid_t msg = async_send_3(dev->phone, IPC_GET_IMETHOD(*request),
     640                aid_t msg = async_send_3(dev->phone, IPC_GET_METHOD(*request),
    688641                    IPC_GET_ARG1(*request), IPC_GET_ARG2(*request),
    689642                    IPC_GET_ARG3(*request), &answer);
     
    695648               
    696649                /* Wait for reply from the driver. */
    697                 sysarg_t rc;
     650                ipcarg_t rc;
    698651                async_wait_for(msg, &rc);
    699652                size_t bytes = IPC_GET_ARG1(answer);
     
    743696               
    744697                device_t *dev = hash_table_get_instance(lnk, device_t, link);
    745                 assert(dev->phone >= 0);
    746698                dev->refcount--;
    747699               
     
    791743               
    792744                device_t *dev = hash_table_get_instance(lnk, device_t, link);
    793                 assert(dev->phone >= 0);
    794745               
    795746                /* Make a request at the driver */
    796747                ipc_call_t answer;
    797                 aid_t msg = async_send_2(dev->phone, IPC_GET_IMETHOD(*request),
     748                aid_t msg = async_send_2(dev->phone, IPC_GET_METHOD(*request),
    798749                    IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), &answer);
    799750               
     
    801752               
    802753                /* Wait for reply from the driver */
    803                 sysarg_t rc;
     754                ipcarg_t rc;
    804755                async_wait_for(msg, &rc);
    805756               
Note: See TracChangeset for help on using the changeset viewer.