Changeset b72efe8 in mainline for uspace/srv/fs/fat


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/fs/fat
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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 {
Note: See TracChangeset for help on using the changeset viewer.