Changeset b72efe8 in mainline for uspace/srv


Ignore:
Timestamp:
2011-06-19T14:38:59Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
74464e8
Parents:
1d1bb0f
Message:

Separate list_t typedef from link_t (user-space part).

  • list_t represents lists
  • Use list_first(), list_last(), list_empty() where appropriate
  • Use list_foreach() where possible
  • assert_link_not_used()
  • usb_hid_report_path_free() shall not unlink the path, caller must do it
Location:
uspace/srv
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/devman.c

    r1d1bb0f rb72efe8  
    466466        fibril_mutex_lock(&drivers_list->drivers_mutex);
    467467       
    468         link_t *link = drivers_list->drivers.next;
    469         while (link != &drivers_list->drivers) {
     468        list_foreach(drivers_list->drivers, link) {
    470469                drv = list_get_instance(link, driver_t, drivers);
    471470                score = get_match_score(drv, node);
     
    474473                        best_drv = drv;
    475474                }
    476                 link = link->next;
    477475        }
    478476       
     
    536534        driver_t *res = NULL;
    537535        driver_t *drv = NULL;
    538         link_t *link;
    539536       
    540537        fibril_mutex_lock(&drv_list->drivers_mutex);
    541538       
    542         link = drv_list->drivers.next;
    543         while (link != &drv_list->drivers) {
     539        list_foreach(drv_list->drivers, link) {
    544540                drv = list_get_instance(link, driver_t, drivers);
    545541                if (str_cmp(drv->name, drv_name) == 0) {
     
    547543                        break;
    548544                }
    549 
    550                 link = link->next;
    551545        }
    552546       
     
    584578         * that has not been passed to the driver.
    585579         */
    586         link = driver->devices.next;
    587         while (link != &driver->devices) {
     580        link = driver->devices.head.next;
     581        while (link != &driver->devices.head) {
    588582                dev = list_get_instance(link, dev_node_t, driver_devices);
    589583                if (dev->passed_to_driver) {
     
    622616                 * Restart the cycle to go through all devices again.
    623617                 */
    624                 link = driver->devices.next;
     618                link = driver->devices.head.next;
    625619        }
    626620
     
    11871181
    11881182        fun_node_t *fun;
    1189         link_t *link;
    1190 
    1191         for (link = dev->functions.next;
    1192             link != &dev->functions;
    1193             link = link->next) {
     1183
     1184        list_foreach(dev->functions, link) {
    11941185                fun = list_get_instance(link, fun_node_t, dev_functions);
    11951186
     
    13851376{
    13861377        dev_class_t *cl;
    1387         link_t *link = class_list->classes.next;
    1388        
    1389         while (link != &class_list->classes) {
     1378       
     1379        list_foreach(class_list->classes, link) {
    13901380                cl = list_get_instance(link, dev_class_t, link);
    13911381                if (str_cmp(cl->name, class_name) == 0) {
    13921382                        return cl;
    13931383                }
    1394                 link = link->next;
    13951384        }
    13961385       
     
    14081397        assert(dev_name != NULL);
    14091398
    1410         link_t *link;
    1411         for (link = dev_class->devices.next;
    1412             link != &dev_class->devices;
    1413             link = link->next) {
     1399        list_foreach(dev_class->devices, link) {
    14141400                dev_class_info_t *dev = list_get_instance(link,
    14151401                    dev_class_info_t, link);
  • uspace/srv/devman/devman.h

    r1d1bb0f rb72efe8  
    9696        /** List of device ids for device-to-driver matching. */
    9797        match_id_list_t match_ids;
    98         /** Pointer to the linked list of devices controlled by this driver. */
    99         link_t devices;
     98        /** List of devices controlled by this driver. */
     99        list_t devices;
    100100       
    101101        /**
     
    108108typedef struct driver_list {
    109109        /** List of drivers */
    110         link_t drivers;
     110        list_t drivers;
    111111        /** Fibril mutex for list of drivers. */
    112112        fibril_mutex_t drivers_mutex;
     
    130130       
    131131        /** List of device functions. */
    132         link_t functions;
     132        list_t functions;
    133133        /** Driver of this device. */
    134134        driver_t *drv;
     
    170170        match_id_list_t match_ids;
    171171       
    172         /** The list of device classes to which this device function belongs. */
    173         link_t classes;
     172        /** List of device classes to which this device function belongs. */
     173        list_t classes;
    174174        /** Devmap handle if the device function is registered by devmap. */
    175175        devmap_handle_t devmap_handle;
     
    228228         * this class.
    229229         */
    230         link_t devices;
     230        list_t devices;
    231231       
    232232        /**
     
    280280typedef struct class_list {
    281281        /** List of classes. */
    282         link_t classes;
     282        list_t classes;
    283283       
    284284        /**
  • uspace/srv/devman/match.c

    r1d1bb0f rb72efe8  
    5959int get_match_score(driver_t *drv, dev_node_t *dev)
    6060{
    61         link_t *drv_head = &drv->match_ids.ids;
    62         link_t *dev_head = &dev->pfun->match_ids.ids;
     61        link_t *drv_head = &drv->match_ids.ids.head;
     62        link_t *dev_head = &dev->pfun->match_ids.ids.head;
    6363       
    64         if (list_empty(drv_head) || list_empty(dev_head))
     64        if (list_empty(&drv->match_ids.ids) ||
     65            list_empty(&dev->pfun->match_ids.ids)) {
    6566                return 0;
     67        }
    6668       
    6769        /*
     
    7072        int highest_score = 0;
    7173       
    72         link_t *drv_link = drv->match_ids.ids.next;
     74        link_t *drv_link = drv->match_ids.ids.head.next;
    7375        while (drv_link != drv_head) {
    7476                link_t *dev_link = dev_head->next;
  • uspace/srv/devmap/devmap.c

    r1d1bb0f rb72efe8  
    5757 */
    5858typedef struct {
    59         /** Pointers to previous and next drivers in linked list */
     59        /** Link to drivers_list */
    6060        link_t drivers;
    6161       
    62         /** Pointer to the linked list of devices controlled by this driver */
    63         link_t devices;
     62        /** List of devices controlled by this driver */
     63        list_t devices;
    6464       
    6565        /** Session asociated with this driver */
     
    7777 */
    7878typedef struct {
    79         /** Pointer to the previous and next device in the list of all namespaces */
     79        /** Link to namespaces_list */
    8080        link_t namespaces;
    8181       
     
    9494 */
    9595typedef struct {
    96         /** Pointer to the previous and next device in the list of all devices */
     96        /** Link to global list of devices (devices_list) */
    9797        link_t devices;
    98         /** Pointer to the previous and next device in the list of devices
    99             owned by one driver */
     98        /** Link to driver list of devices (devmap_driver_t.devices) */
    10099        link_t driver_devices;
    101100        /** Unique device identifier */
     
    225224static devmap_namespace_t *devmap_namespace_find_name(const char *name)
    226225{
    227         link_t *item;
    228        
    229226        assert(fibril_mutex_is_locked(&devices_list_mutex));
    230227       
    231         for (item = namespaces_list.next; item != &namespaces_list; item = item->next) {
     228        list_foreach(namespaces_list, item) {
    232229                devmap_namespace_t *namespace =
    233230                    list_get_instance(item, devmap_namespace_t, namespaces);
     
    246243static devmap_namespace_t *devmap_namespace_find_handle(devmap_handle_t handle)
    247244{
    248         link_t *item;
    249        
    250245        assert(fibril_mutex_is_locked(&devices_list_mutex));
    251246       
    252         for (item = namespaces_list.next; item != &namespaces_list; item = item->next) {
     247        list_foreach(namespaces_list, item) {
    253248                devmap_namespace_t *namespace =
    254249                    list_get_instance(item, devmap_namespace_t, namespaces);
     
    264259    const char *name)
    265260{
    266         link_t *item;
    267        
    268261        assert(fibril_mutex_is_locked(&devices_list_mutex));
    269262       
    270         for (item = devices_list.next; item != &devices_list; item = item->next) {
     263        list_foreach(devices_list, item) {
    271264                devmap_device_t *device =
    272265                    list_get_instance(item, devmap_device_t, devices);
     
    286279static devmap_device_t *devmap_device_find_handle(devmap_handle_t handle)
    287280{
    288         link_t *item;
    289        
    290281        assert(fibril_mutex_is_locked(&devices_list_mutex));
    291282       
    292         for (item = devices_list.next; item != &devices_list; item = item->next) {
     283        list_foreach(devices_list, item) {
    293284                devmap_device_t *device =
    294285                    list_get_instance(item, devmap_device_t, devices);
     
    473464        fibril_mutex_lock(&driver->devices_mutex);
    474465       
    475         while (!list_empty(&(driver->devices))) {
    476                 devmap_device_t *device = list_get_instance(driver->devices.next,
    477                     devmap_device_t, driver_devices);
     466        while (!list_empty(&driver->devices)) {
     467                devmap_device_t *device = list_get_instance(
     468                    list_first(&driver->devices), devmap_device_t,
     469                    driver_devices);
    478470                devmap_device_unregister_core(device);
    479471        }
     
    815807        }
    816808       
    817         link_t *item;
    818809        size_t pos = 0;
    819         for (item = namespaces_list.next; item != &namespaces_list;
    820             item = item->next) {
     810        list_foreach(namespaces_list, item) {
    821811                devmap_namespace_t *namespace =
    822812                    list_get_instance(item, devmap_namespace_t, namespaces);
     
    881871        }
    882872       
    883         link_t *item;
    884873        size_t pos = 0;
    885         for (item = devices_list.next; item != &devices_list; item = item->next) {
     874        list_foreach(devices_list, item) {
    886875                devmap_device_t *device =
    887876                    list_get_instance(item, devmap_device_t, devices);
  • uspace/srv/fs/ext2fs/ext2fs_ops.c

    r1d1bb0f rb72efe8  
    187187{
    188188        EXT2FS_DBG("(%" PRIun ", -)", devmap_handle);
    189         link_t *link;
    190189        ext2fs_instance_t *tmp;
    191190       
     
    198197        }
    199198
    200         for (link = instance_list.next; link != &instance_list; link = link->next) {
     199        list_foreach(instance_list, link) {
    201200                tmp = list_get_instance(link, ext2fs_instance_t, link);
    202201               
  • uspace/srv/fs/fat/fat_idx.c

    r1d1bb0f rb72efe8  
    6767
    6868        /** Sorted list of intervals of freed indices. */
    69         link_t          freed_head;
     69        list_t          freed_list;
    7070} unused_t;
    7171
     
    7474
    7575/** List of unused structures. */
    76 static LIST_INITIALIZE(unused_head);
     76static LIST_INITIALIZE(unused_list);
    7777
    7878static void unused_initialize(unused_t *u, devmap_handle_t devmap_handle)
     
    8282        u->next = 0;
    8383        u->remaining = ((uint64_t)((fs_index_t)-1)) + 1;
    84         list_initialize(&u->freed_head);
     84        list_initialize(&u->freed_list);
    8585}
    8686
     
    8888{
    8989        unused_t *u;
    90         link_t *l;
    9190
    9291        if (lock)
    9392                fibril_mutex_lock(&unused_lock);
    94         for (l = unused_head.next; l != &unused_head; l = l->next) {
     93
     94        list_foreach(unused_list, l) {
    9595                u = list_get_instance(l, unused_t, link);
    9696                if (u->devmap_handle == devmap_handle)
    9797                        return u;
    9898        }
     99
    99100        if (lock)
    100101                fibril_mutex_unlock(&unused_lock);
     
    249250                return false;   
    250251
    251         if (list_empty(&u->freed_head)) {
     252        if (list_empty(&u->freed_list)) {
    252253                if (u->remaining) {
    253254                        /*
     
    262263        } else {
    263264                /* There are some freed indices which we can reuse. */
    264                 freed_t *f = list_get_instance(u->freed_head.next, freed_t,
    265                     link);
     265                freed_t *f = list_get_instance(list_first(&u->freed_list),
     266                    freed_t, link);
    266267                *index = f->first;
    267268                if (f->first++ == f->last) {
     
    320321                link_t *lnk;
    321322                freed_t *n;
    322                 for (lnk = u->freed_head.next; lnk != &u->freed_head;
     323                for (lnk = u->freed_list.head.next; lnk != &u->freed_list.head;
    323324                    lnk = lnk->next) {
    324325                        freed_t *f = list_get_instance(lnk, freed_t, link);
    325326                        if (f->first == index + 1) {
    326327                                f->first--;
    327                                 if (lnk->prev != &u->freed_head)
     328                                if (lnk->prev != &u->freed_list.head)
    328329                                        try_coalesce_intervals(lnk->prev, lnk,
    329330                                            lnk);
     
    333334                        if (f->last == index - 1) {
    334335                                f->last++;
    335                                 if (lnk->next != &u->freed_head)
     336                                if (lnk->next != &u->freed_list.head)
    336337                                        try_coalesce_intervals(lnk, lnk->next,
    337338                                            lnk);
     
    359360                n->first = index;
    360361                n->last = index;
    361                 list_append(&n->link, &u->freed_head);
     362                list_append(&n->link, &u->freed_list);
    362363        }
    363364        fibril_mutex_unlock(&unused_lock);
     
    558559        fibril_mutex_lock(&unused_lock);
    559560        if (!unused_find(devmap_handle, false)) {
    560                 list_append(&u->link, &unused_head);
     561                list_append(&u->link, &unused_list);
    561562        } else {
    562563                free(u);
     
    594595        fibril_mutex_unlock(&unused_lock);
    595596
    596         while (!list_empty(&u->freed_head)) {
     597        while (!list_empty(&u->freed_list)) {
    597598                freed_t *f;
    598                 f = list_get_instance(u->freed_head.next, freed_t, link);
     599                f = list_get_instance(list_first(&u->freed_list), freed_t, link);
    599600                list_remove(&f->link);
    600601                free(f);
  • uspace/srv/fs/fat/fat_ops.c

    r1d1bb0f rb72efe8  
    6767
    6868/** List of cached free FAT nodes. */
    69 static LIST_INITIALIZE(ffn_head);
     69static LIST_INITIALIZE(ffn_list);
    7070
    7171/*
     
    147147static int fat_node_fini_by_devmap_handle(devmap_handle_t devmap_handle)
    148148{
    149         link_t *lnk;
    150149        fat_node_t *nodep;
    151150        int rc;
     
    159158restart:
    160159        fibril_mutex_lock(&ffn_mutex);
    161         for (lnk = ffn_head.next; lnk != &ffn_head; lnk = lnk->next) {
     160        list_foreach(ffn_list, lnk) {
    162161                nodep = list_get_instance(lnk, fat_node_t, ffn_link);
    163162                if (!fibril_mutex_trylock(&nodep->lock)) {
     
    196195                free(nodep);
    197196
    198                 /* Need to restart because we changed the ffn_head list. */
     197                /* Need to restart because we changed ffn_list. */
    199198                goto restart;
    200199        }
     
    211210
    212211        fibril_mutex_lock(&ffn_mutex);
    213         if (!list_empty(&ffn_head)) {
     212        if (!list_empty(&ffn_list)) {
    214213                /* Try to use a cached free node structure. */
    215214                fat_idx_t *idxp_tmp;
    216                 nodep = list_get_instance(ffn_head.next, fat_node_t, ffn_link);
     215                nodep = list_get_instance(list_first(&ffn_list), fat_node_t,
     216                    ffn_link);
    217217                if (!fibril_mutex_trylock(&nodep->lock))
    218218                        goto skip_cache;
     
    473473                if (nodep->idx) {
    474474                        fibril_mutex_lock(&ffn_mutex);
    475                         list_append(&nodep->ffn_link, &ffn_head);
     475                        list_append(&nodep->ffn_link, &ffn_list);
    476476                        fibril_mutex_unlock(&ffn_mutex);
    477477                } else {
  • uspace/srv/fs/tmpfs/tmpfs.h

    r1d1bb0f rb72efe8  
    6767        size_t size;            /**< File size if type is TMPFS_FILE. */
    6868        void *data;             /**< File content's if type is TMPFS_FILE. */
    69         link_t cs_head;         /**< Head of child's siblings list. */
     69        list_t cs_list;         /**< Child's siblings list. */
    7070} tmpfs_node_t;
    7171
  • uspace/srv/fs/tmpfs/tmpfs_ops.c

    r1d1bb0f rb72efe8  
    8585static int tmpfs_has_children(bool *has_children, fs_node_t *fn)
    8686{
    87         *has_children = !list_empty(&TMPFS_NODE(fn)->cs_head);
     87        *has_children = !list_empty(&TMPFS_NODE(fn)->cs_list);
    8888        return EOK;
    8989}
     
    180180            nh_link);
    181181
    182         while (!list_empty(&nodep->cs_head)) {
    183                 tmpfs_dentry_t *dentryp = list_get_instance(nodep->cs_head.next,
    184                     tmpfs_dentry_t, link);
     182        while (!list_empty(&nodep->cs_list)) {
     183                tmpfs_dentry_t *dentryp = list_get_instance(
     184                    list_first(&nodep->cs_list), tmpfs_dentry_t, link);
    185185
    186186                assert(nodep->type == TMPFS_DIRECTORY);
     
    214214        nodep->data = NULL;
    215215        link_initialize(&nodep->nh_link);
    216         list_initialize(&nodep->cs_head);
     216        list_initialize(&nodep->cs_list);
    217217}
    218218
     
    262262{
    263263        tmpfs_node_t *parentp = TMPFS_NODE(pfn);
    264         link_t *lnk;
    265 
    266         for (lnk = parentp->cs_head.next; lnk != &parentp->cs_head;
    267             lnk = lnk->next) {
     264
     265        list_foreach(parentp->cs_list, lnk) {
    268266                tmpfs_dentry_t *dentryp;
    269267                dentryp = list_get_instance(lnk, tmpfs_dentry_t, link);
     
    353351       
    354352        assert(!nodep->lnkcnt);
    355         assert(list_empty(&nodep->cs_head));
     353        assert(list_empty(&nodep->cs_list));
    356354
    357355        unsigned long key[] = {
     
    373371        tmpfs_node_t *childp = TMPFS_NODE(cfn);
    374372        tmpfs_dentry_t *dentryp;
    375         link_t *lnk;
    376373
    377374        assert(parentp->type == TMPFS_DIRECTORY);
    378375
    379376        /* Check for duplicit entries. */
    380         for (lnk = parentp->cs_head.next; lnk != &parentp->cs_head;
    381             lnk = lnk->next) {
     377        list_foreach(parentp->cs_list, lnk) {
    382378                dentryp = list_get_instance(lnk, tmpfs_dentry_t, link);
    383379                if (!str_cmp(dentryp->name, nm))
     
    401397        dentryp->node = childp;
    402398        childp->lnkcnt++;
    403         list_append(&dentryp->link, &parentp->cs_head);
     399        list_append(&dentryp->link, &parentp->cs_list);
    404400
    405401        return EOK;
     
    411407        tmpfs_node_t *childp = NULL;
    412408        tmpfs_dentry_t *dentryp;
    413         link_t *lnk;
    414409
    415410        if (!parentp)
    416411                return EBUSY;
    417412       
    418         for (lnk = parentp->cs_head.next; lnk != &parentp->cs_head;
    419             lnk = lnk->next) {
     413        list_foreach(parentp->cs_list, lnk) {
    420414                dentryp = list_get_instance(lnk, tmpfs_dentry_t, link);
    421415                if (!str_cmp(dentryp->name, nm)) {
     
    423417                        assert(FS_NODE(childp) == cfn);
    424418                        break;
    425                 }       
     419                }
    426420        }
    427421
     
    429423                return ENOENT;
    430424               
    431         if ((childp->lnkcnt == 1) && !list_empty(&childp->cs_head))
     425        if ((childp->lnkcnt == 1) && !list_empty(&childp->cs_list))
    432426                return ENOTEMPTY;
    433427
     
    550544                tmpfs_dentry_t *dentryp;
    551545                link_t *lnk;
    552                 aoff64_t i;
    553546               
    554547                assert(nodep->type == TMPFS_DIRECTORY);
     
    559552                 * hash table.
    560553                 */
    561                 for (i = 0, lnk = nodep->cs_head.next;
    562                     (i < pos) && (lnk != &nodep->cs_head);
    563                     i++, lnk = lnk->next)
    564                         ;
    565 
    566                 if (lnk == &nodep->cs_head) {
     554                lnk = list_nth(&nodep->cs_list, pos);
     555               
     556                if (lnk == NULL) {
    567557                        async_answer_0(callid, ENOENT);
    568558                        async_answer_1(rid, ENOENT, 0);
  • uspace/srv/hid/input/generic/input.c

    r1d1bb0f rb72efe8  
    7575
    7676/** List of keyboard devices */
    77 static link_t kbd_devs;
     77static list_t kbd_devs;
    7878
    7979/** List of mouse devices */
    80 link_t mouse_devs;
     80list_t mouse_devs;
    8181
    8282bool irc_service = false;
  • uspace/srv/hid/input/include/input.h

    r1d1bb0f rb72efe8  
    4747extern int irc_phone;
    4848
    49 extern link_t mouse_devs;
     49extern list_t mouse_devs;
    5050
    5151void input_event_move(int, int);
  • uspace/srv/hw/netif/ne2000/dp8390.c

    r1d1bb0f rb72efe8  
    483483}
    484484
    485 static link_t *ne2k_receive(ne2k_t *ne2k)
     485static list_t *ne2k_receive(ne2k_t *ne2k)
    486486{
    487487        /*
     
    490490         * frames from the network, but they will be lost.
    491491         */
    492         link_t *frames = (link_t *) malloc(sizeof(link_t));
     492        list_t *frames = (list_t *) malloc(sizeof(list_t));
    493493        if (frames != NULL)
    494494                list_initialize(frames);
     
    567567}
    568568
    569 link_t *ne2k_interrupt(ne2k_t *ne2k, uint8_t isr, uint8_t tsr)
     569list_t *ne2k_interrupt(ne2k_t *ne2k, uint8_t isr, uint8_t tsr)
    570570{
    571571        /* List of received frames */
    572         link_t *frames = NULL;
     572        list_t *frames = NULL;
    573573       
    574574        if (isr & (ISR_PTX | ISR_TXE)) {
  • uspace/srv/hw/netif/ne2000/dp8390.h

    r1d1bb0f rb72efe8  
    241241extern void ne2k_down(ne2k_t *);
    242242extern void ne2k_send(ne2k_t *, packet_t *);
    243 extern link_t *ne2k_interrupt(ne2k_t *, uint8_t, uint8_t);
     243extern list_t *ne2k_interrupt(ne2k_t *, uint8_t, uint8_t);
    244244
    245245#endif
  • uspace/srv/hw/netif/ne2000/ne2000.c

    r1d1bb0f rb72efe8  
    168168       
    169169        if (ne2k != NULL) {
    170                 link_t *frames =
     170                list_t *frames =
    171171                    ne2k_interrupt(ne2k, IRQ_GET_ISR(*call), IRQ_GET_TSR(*call));
    172172               
    173173                if (frames != NULL) {
    174174                        while (!list_empty(frames)) {
    175                                 frame_t *frame =
    176                                     list_get_instance(frames->next, frame_t, link);
     175                                frame_t *frame = list_get_instance(
     176                                    list_first(frames), frame_t, link);
    177177                               
    178178                                list_remove(&frame->link);
    179                                 nil_received_msg(nil_phone, device_id, frame->packet,
    180                                     SERVICE_NONE);
     179                                nil_received_msg(nil_phone, device_id,
     180                                    frame->packet, SERVICE_NONE);
    181181                                free(frame);
    182182                        }
  • uspace/srv/ns/clonable.c

    r1d1bb0f rb72efe8  
    5252
    5353/** List of clonable-service connection requests. */
    54 static link_t cs_req;
     54static list_t cs_req;
    5555
    5656int clonable_init(void)
     
    7676    ipc_callid_t callid)
    7777{
    78         if (list_empty(&cs_req)) {
     78        link_t *req_link;
     79
     80        req_link = list_first(&cs_req);
     81        if (req_link == NULL) {
    7982                /* There was no pending connection request. */
    8083                printf("%s: Unexpected clonable server.\n", NAME);
     
    8386        }
    8487       
    85         cs_req_t *csr = list_get_instance(cs_req.next, cs_req_t, link);
    86         list_remove(&csr->link);
     88        cs_req_t *csr = list_get_instance(req_link, cs_req_t, link);
     89        list_remove(req_link);
    8790       
    8891        /* Currently we can only handle a single type of clonable service. */
  • uspace/srv/ns/service.c

    r1d1bb0f rb72efe8  
    123123} pending_conn_t;
    124124
    125 static link_t pending_conn;
     125static list_t pending_conn;
    126126
    127127int service_init(void)
     
    141141void process_pending_conn(void)
    142142{
    143         link_t *cur;
    144        
    145143loop:
    146         for (cur = pending_conn.next; cur != &pending_conn; cur = cur->next) {
     144        list_foreach(pending_conn, cur) {
    147145                pending_conn_t *pr = list_get_instance(cur, pending_conn_t, link);
    148146               
  • uspace/srv/ns/task.c

    r1d1bb0f rb72efe8  
    189189} pending_wait_t;
    190190
    191 static link_t pending_wait;
     191static list_t pending_wait;
    192192
    193193int task_init(void)
     
    212212void process_pending_wait(void)
    213213{
    214         link_t *cur;
    215214        task_exit_t texit;
    216215       
    217216loop:
    218         for (cur = pending_wait.next; cur != &pending_wait; cur = cur->next) {
     217        list_foreach(pending_wait, cur) {
    219218                pending_wait_t *pr = list_get_instance(cur, pending_wait_t, link);
    220219               
  • uspace/srv/vfs/vfs.h

    r1d1bb0f rb72efe8  
    145145extern fibril_mutex_t nodes_mutex;
    146146
    147 extern fibril_condvar_t fs_head_cv;
    148 extern fibril_mutex_t fs_head_lock;
    149 extern link_t fs_head;          /**< List of registered file systems. */
     147extern fibril_condvar_t fs_list_cv;
     148extern fibril_mutex_t fs_list_lock;
     149extern list_t fs_list;          /**< List of registered file systems. */
    150150
    151151extern vfs_pair_t rootfs;       /**< Root file system. */
     
    158158} plb_entry_t;
    159159
    160 extern fibril_mutex_t plb_mutex;/**< Mutex protecting plb and plb_head. */
     160extern fibril_mutex_t plb_mutex;/**< Mutex protecting plb and plb_entries. */
    161161extern uint8_t *plb;            /**< Path Lookup Buffer */
    162 extern link_t plb_head;         /**< List of active PLB entries. */
     162extern list_t plb_entries;      /**< List of active PLB entries. */
    163163
    164164#define MAX_MNTOPTS_LEN         256
  • uspace/srv/vfs/vfs_lookup.c

    r1d1bb0f rb72efe8  
    5050
    5151FIBRIL_MUTEX_INITIALIZE(plb_mutex);
    52 LIST_INITIALIZE(plb_head);      /**< PLB entry ring buffer. */
     52LIST_INITIALIZE(plb_entries);   /**< PLB entry ring buffer. */
    5353uint8_t *plb = NULL;
    5454
     
    102102        size_t last;    /* the last free index */
    103103
    104         if (list_empty(&plb_head)) {
     104        if (list_empty(&plb_entries)) {
    105105                first = 0;
    106106                last = PLB_SIZE - 1;
    107107        } else {
    108                 plb_entry_t *oldest = list_get_instance(plb_head.next,
    109                     plb_entry_t, plb_link);
    110                 plb_entry_t *newest = list_get_instance(plb_head.prev,
    111                     plb_entry_t, plb_link);
     108                plb_entry_t *oldest = list_get_instance(
     109                    list_first(&plb_entries), plb_entry_t, plb_link);
     110                plb_entry_t *newest = list_get_instance(
     111                    list_last(&plb_entries), plb_entry_t, plb_link);
    112112
    113113                first = (newest->index + newest->len) % PLB_SIZE;
     
    145145         * buffer.
    146146         */
    147         list_append(&entry.plb_link, &plb_head);
     147        list_append(&entry.plb_link, &plb_entries);
    148148       
    149149        fibril_mutex_unlock(&plb_mutex);
  • uspace/srv/vfs/vfs_ops.c

    r1d1bb0f rb72efe8  
    325325         * This will also give us its file system handle.
    326326         */
    327         fibril_mutex_lock(&fs_head_lock);
     327        fibril_mutex_lock(&fs_list_lock);
    328328        fs_handle_t fs_handle;
    329329recheck:
     
    331331        if (!fs_handle) {
    332332                if (flags & IPC_FLAG_BLOCKING) {
    333                         fibril_condvar_wait(&fs_head_cv, &fs_head_lock);
     333                        fibril_condvar_wait(&fs_list_cv, &fs_list_lock);
    334334                        goto recheck;
    335335                }
    336336               
    337                 fibril_mutex_unlock(&fs_head_lock);
     337                fibril_mutex_unlock(&fs_list_lock);
    338338                async_answer_0(callid, ENOENT);
    339339                async_answer_0(rid, ENOENT);
     
    343343                return;
    344344        }
    345         fibril_mutex_unlock(&fs_head_lock);
     345        fibril_mutex_unlock(&fs_list_lock);
    346346       
    347347        /* Acknowledge that we know fs_name. */
  • uspace/srv/vfs/vfs_register.c

    r1d1bb0f rb72efe8  
    5252#include "vfs.h"
    5353
    54 FIBRIL_CONDVAR_INITIALIZE(fs_head_cv);
    55 FIBRIL_MUTEX_INITIALIZE(fs_head_lock);
    56 LIST_INITIALIZE(fs_head);
     54FIBRIL_CONDVAR_INITIALIZE(fs_list_cv);
     55FIBRIL_MUTEX_INITIALIZE(fs_list_lock);
     56LIST_INITIALIZE(fs_list);
    5757
    5858atomic_t fs_handle_next = {
     
    149149        }
    150150       
    151         fibril_mutex_lock(&fs_head_lock);
     151        fibril_mutex_lock(&fs_list_lock);
    152152       
    153153        /*
     
    159159                 */
    160160                dprintf("FS is already registered.\n");
    161                 fibril_mutex_unlock(&fs_head_lock);
     161                fibril_mutex_unlock(&fs_list_lock);
    162162                free(fs_info);
    163163                async_answer_0(rid, EEXISTS);
     
    169169         */
    170170        dprintf("Inserting FS into the list of registered file systems.\n");
    171         list_append(&fs_info->fs_link, &fs_head);
     171        list_append(&fs_info->fs_link, &fs_list);
    172172       
    173173        /*
     
    180180                dprintf("Callback connection expected\n");
    181181                list_remove(&fs_info->fs_link);
    182                 fibril_mutex_unlock(&fs_head_lock);
     182                fibril_mutex_unlock(&fs_list_lock);
    183183                free(fs_info);
    184184                async_answer_0(rid, EINVAL);
     
    197197                dprintf("Unexpected call, method = %d\n", IPC_GET_IMETHOD(call));
    198198                list_remove(&fs_info->fs_link);
    199                 fibril_mutex_unlock(&fs_head_lock);
     199                fibril_mutex_unlock(&fs_list_lock);
    200200                async_hangup(fs_info->sess);
    201201                free(fs_info);
     
    211211                dprintf("Client suggests wrong size of PFB, size = %d\n", size);
    212212                list_remove(&fs_info->fs_link);
    213                 fibril_mutex_unlock(&fs_head_lock);
     213                fibril_mutex_unlock(&fs_list_lock);
    214214                async_hangup(fs_info->sess);
    215215                free(fs_info);
     
    235235        async_answer_1(rid, EOK, (sysarg_t) fs_info->fs_handle);
    236236       
    237         fibril_condvar_broadcast(&fs_head_cv);
    238         fibril_mutex_unlock(&fs_head_lock);
     237        fibril_condvar_broadcast(&fs_list_cv);
     238        fibril_mutex_unlock(&fs_list_lock);
    239239       
    240240        dprintf("\"%.*s\" filesystem successfully registered, handle=%d.\n",
     
    254254        /*
    255255         * For now, we don't try to be very clever and very fast.
    256          * We simply lookup the session in the fs_head list and
     256         * We simply lookup the session in fs_list and
    257257         * begin an exchange.
    258258         */
    259         fibril_mutex_lock(&fs_head_lock);
    260        
    261         link_t *cur;
    262         for (cur = fs_head.next; cur != &fs_head; cur = cur->next) {
     259        fibril_mutex_lock(&fs_list_lock);
     260       
     261        list_foreach(fs_list, cur) {
    263262                fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link);
    264263               
    265264                if (fs->fs_handle == handle) {
    266                         fibril_mutex_unlock(&fs_head_lock);
     265                        fibril_mutex_unlock(&fs_list_lock);
    267266                       
    268267                        assert(fs->sess);
     
    274273        }
    275274       
    276         fibril_mutex_unlock(&fs_head_lock);
     275        fibril_mutex_unlock(&fs_list_lock);
    277276       
    278277        return NULL;
     
    293292 * @param name File system name.
    294293 * @param lock If true, the function will lock and unlock the
    295  *             fs_head_lock.
     294 *             fs_list_lock.
    296295 *
    297296 * @return File system handle or zero if file system not found.
     
    303302       
    304303        if (lock)
    305                 fibril_mutex_lock(&fs_head_lock);
    306        
    307         link_t *cur;
    308         for (cur = fs_head.next; cur != &fs_head; cur = cur->next) {
     304                fibril_mutex_lock(&fs_list_lock);
     305       
     306        list_foreach(fs_list, cur) {
    309307                fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link);
    310308                if (str_cmp(fs->vfs_info.name, name) == 0) {
     
    315313       
    316314        if (lock)
    317                 fibril_mutex_unlock(&fs_head_lock);
     315                fibril_mutex_unlock(&fs_list_lock);
    318316       
    319317        return handle;
     
    330328{
    331329        vfs_info_t *info = NULL;
    332         link_t *cur;
    333        
    334         fibril_mutex_lock(&fs_head_lock);
    335         for (cur = fs_head.next; cur != &fs_head; cur = cur->next) {
     330       
     331        fibril_mutex_lock(&fs_list_lock);
     332        list_foreach(fs_list, cur) {
    336333                fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link);
    337334                if (fs->fs_handle == handle) {
     
    340337                }
    341338        }
    342         fibril_mutex_unlock(&fs_head_lock);
     339        fibril_mutex_unlock(&fs_list_lock);
    343340       
    344341        return info;
Note: See TracChangeset for help on using the changeset viewer.