Changeset 3f0a7971 in mainline for uspace/srv/fs/fat/fat_idx.c


Ignore:
Timestamp:
2010-11-18T22:34:23Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
63b4f90
Parents:
c7137738 (diff), 45f04f8 (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

Updated srv/hw/bus/usb/hcd/virtual to use new type names (devmap_handle_t).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/fat/fat_idx.c

    rc7137738 r3f0a7971  
    5858typedef struct {
    5959        link_t          link;
    60         dev_handle_t    dev_handle;
     60        devmap_handle_t devmap_handle;
    6161
    6262        /** Next unassigned index. */
     
    7575static LIST_INITIALIZE(unused_head);
    7676
    77 static void unused_initialize(unused_t *u, dev_handle_t dev_handle)
     77static void unused_initialize(unused_t *u, devmap_handle_t devmap_handle)
    7878{
    7979        link_initialize(&u->link);
    80         u->dev_handle = dev_handle;
     80        u->devmap_handle = devmap_handle;
    8181        u->next = 0;
    8282        u->remaining = ((uint64_t)((fs_index_t)-1)) + 1;
     
    8484}
    8585
    86 static unused_t *unused_find(dev_handle_t dev_handle, bool lock)
     86static unused_t *unused_find(devmap_handle_t devmap_handle, bool lock)
    8787{
    8888        unused_t *u;
     
    9393        for (l = unused_head.next; l != &unused_head; l = l->next) {
    9494                u = list_get_instance(l, unused_t, link);
    95                 if (u->dev_handle == dev_handle)
     95                if (u->devmap_handle == devmap_handle)
    9696                        return u;
    9797        }
     
    106106/**
    107107 * Global hash table of all used fat_idx_t structures.
    108  * The index structures are hashed by the dev_handle, parent node's first
     108 * The index structures are hashed by the devmap_handle, parent node's first
    109109 * cluster and index within the parent directory.
    110110 */
     
    120120static hash_index_t pos_hash(unsigned long key[])
    121121{
    122         dev_handle_t dev_handle = (dev_handle_t)key[UPH_DH_KEY];
     122        devmap_handle_t devmap_handle = (devmap_handle_t)key[UPH_DH_KEY];
    123123        fat_cluster_t pfc = (fat_cluster_t)key[UPH_PFC_KEY];
    124124        unsigned pdi = (unsigned)key[UPH_PDI_KEY];
     
    140140        h |= (pdi & ((1 << (UPH_BUCKETS_LOG / 4)) - 1)) <<
    141141            (UPH_BUCKETS_LOG / 2);
    142         h |= (dev_handle & ((1 << (UPH_BUCKETS_LOG / 4)) - 1)) <<
     142        h |= (devmap_handle & ((1 << (UPH_BUCKETS_LOG / 4)) - 1)) <<
    143143            (3 * (UPH_BUCKETS_LOG / 4));
    144144
     
    148148static int pos_compare(unsigned long key[], hash_count_t keys, link_t *item)
    149149{
    150         dev_handle_t dev_handle = (dev_handle_t)key[UPH_DH_KEY];
     150        devmap_handle_t devmap_handle = (devmap_handle_t)key[UPH_DH_KEY];
    151151        fat_cluster_t pfc;
    152152        unsigned pdi;
     
    155155        switch (keys) {
    156156        case 1:
    157                 return (dev_handle == fidx->dev_handle);
     157                return (devmap_handle == fidx->devmap_handle);
    158158        case 3:
    159159                pfc = (fat_cluster_t) key[UPH_PFC_KEY];
    160160                pdi = (unsigned) key[UPH_PDI_KEY];
    161                 return (dev_handle == fidx->dev_handle) && (pfc == fidx->pfc) &&
     161                return (devmap_handle == fidx->devmap_handle) && (pfc == fidx->pfc) &&
    162162                    (pdi == fidx->pdi);
    163163        default:
     
    181181/**
    182182 * Global hash table of all used fat_idx_t structures.
    183  * The index structures are hashed by the dev_handle and index.
     183 * The index structures are hashed by the devmap_handle and index.
    184184 */
    185185static hash_table_t ui_hash;
     
    193193static hash_index_t idx_hash(unsigned long key[])
    194194{
    195         dev_handle_t dev_handle = (dev_handle_t)key[UIH_DH_KEY];
     195        devmap_handle_t devmap_handle = (devmap_handle_t)key[UIH_DH_KEY];
    196196        fs_index_t index = (fs_index_t)key[UIH_INDEX_KEY];
    197197
    198198        hash_index_t h;
    199199
    200         h = dev_handle & ((1 << (UIH_BUCKETS_LOG / 2)) - 1);
     200        h = devmap_handle & ((1 << (UIH_BUCKETS_LOG / 2)) - 1);
    201201        h |= (index & ((1 << (UIH_BUCKETS_LOG / 2)) - 1)) <<
    202202            (UIH_BUCKETS_LOG / 2);
     
    207207static int idx_compare(unsigned long key[], hash_count_t keys, link_t *item)
    208208{
    209         dev_handle_t dev_handle = (dev_handle_t)key[UIH_DH_KEY];
     209        devmap_handle_t devmap_handle = (devmap_handle_t)key[UIH_DH_KEY];
    210210        fs_index_t index;
    211211        fat_idx_t *fidx = list_get_instance(item, fat_idx_t, uih_link);
     
    213213        switch (keys) {
    214214        case 1:
    215                 return (dev_handle == fidx->dev_handle);
     215                return (devmap_handle == fidx->devmap_handle);
    216216        case 2:
    217217                index = (fs_index_t) key[UIH_INDEX_KEY];
    218                 return (dev_handle == fidx->dev_handle) &&
     218                return (devmap_handle == fidx->devmap_handle) &&
    219219                    (index == fidx->index);
    220220        default:
     
    239239
    240240/** Allocate a VFS index which is not currently in use. */
    241 static bool fat_index_alloc(dev_handle_t dev_handle, fs_index_t *index)
     241static bool fat_index_alloc(devmap_handle_t devmap_handle, fs_index_t *index)
    242242{
    243243        unused_t *u;
    244244       
    245245        assert(index);
    246         u = unused_find(dev_handle, true);
     246        u = unused_find(devmap_handle, true);
    247247        if (!u)
    248248                return false;   
     
    301301
    302302/** Free a VFS index, which is no longer in use. */
    303 static void fat_index_free(dev_handle_t dev_handle, fs_index_t index)
     303static void fat_index_free(devmap_handle_t devmap_handle, fs_index_t index)
    304304{
    305305        unused_t *u;
    306306
    307         u = unused_find(dev_handle, true);
     307        u = unused_find(devmap_handle, true);
    308308        assert(u);
    309309
     
    363363}
    364364
    365 static int fat_idx_create(fat_idx_t **fidxp, dev_handle_t dev_handle)
     365static int fat_idx_create(fat_idx_t **fidxp, devmap_handle_t devmap_handle)
    366366{
    367367        fat_idx_t *fidx;
     
    370370        if (!fidx)
    371371                return ENOMEM;
    372         if (!fat_index_alloc(dev_handle, &fidx->index)) {
     372        if (!fat_index_alloc(devmap_handle, &fidx->index)) {
    373373                free(fidx);
    374374                return ENOSPC;
     
    378378        link_initialize(&fidx->uih_link);
    379379        fibril_mutex_initialize(&fidx->lock);
    380         fidx->dev_handle = dev_handle;
     380        fidx->devmap_handle = devmap_handle;
    381381        fidx->pfc = FAT_CLST_RES0;      /* no parent yet */
    382382        fidx->pdi = 0;
     
    387387}
    388388
    389 int fat_idx_get_new(fat_idx_t **fidxp, dev_handle_t dev_handle)
     389int fat_idx_get_new(fat_idx_t **fidxp, devmap_handle_t devmap_handle)
    390390{
    391391        fat_idx_t *fidx;
     
    393393
    394394        fibril_mutex_lock(&used_lock);
    395         rc = fat_idx_create(&fidx, dev_handle);
     395        rc = fat_idx_create(&fidx, devmap_handle);
    396396        if (rc != EOK) {
    397397                fibril_mutex_unlock(&used_lock);
     
    400400               
    401401        unsigned long ikey[] = {
    402                 [UIH_DH_KEY] = dev_handle,
     402                [UIH_DH_KEY] = devmap_handle,
    403403                [UIH_INDEX_KEY] = fidx->index,
    404404        };
     
    413413
    414414fat_idx_t *
    415 fat_idx_get_by_pos(dev_handle_t dev_handle, fat_cluster_t pfc, unsigned pdi)
     415fat_idx_get_by_pos(devmap_handle_t devmap_handle, fat_cluster_t pfc, unsigned pdi)
    416416{
    417417        fat_idx_t *fidx;
    418418        link_t *l;
    419419        unsigned long pkey[] = {
    420                 [UPH_DH_KEY] = dev_handle,
     420                [UPH_DH_KEY] = devmap_handle,
    421421                [UPH_PFC_KEY] = pfc,
    422422                [UPH_PDI_KEY] = pdi,
     
    430430                int rc;
    431431
    432                 rc = fat_idx_create(&fidx, dev_handle);
     432                rc = fat_idx_create(&fidx, devmap_handle);
    433433                if (rc != EOK) {
    434434                        fibril_mutex_unlock(&used_lock);
     
    437437               
    438438                unsigned long ikey[] = {
    439                         [UIH_DH_KEY] = dev_handle,
     439                        [UIH_DH_KEY] = devmap_handle,
    440440                        [UIH_INDEX_KEY] = fidx->index,
    441441                };
     
    456456{
    457457        unsigned long pkey[] = {
    458                 [UPH_DH_KEY] = idx->dev_handle,
     458                [UPH_DH_KEY] = idx->devmap_handle,
    459459                [UPH_PFC_KEY] = idx->pfc,
    460460                [UPH_PDI_KEY] = idx->pdi,
     
    469469{
    470470        unsigned long pkey[] = {
    471                 [UPH_DH_KEY] = idx->dev_handle,
     471                [UPH_DH_KEY] = idx->devmap_handle,
    472472                [UPH_PFC_KEY] = idx->pfc,
    473473                [UPH_PDI_KEY] = idx->pdi,
     
    480480
    481481fat_idx_t *
    482 fat_idx_get_by_index(dev_handle_t dev_handle, fs_index_t index)
     482fat_idx_get_by_index(devmap_handle_t devmap_handle, fs_index_t index)
    483483{
    484484        fat_idx_t *fidx = NULL;
    485485        link_t *l;
    486486        unsigned long ikey[] = {
    487                 [UIH_DH_KEY] = dev_handle,
     487                [UIH_DH_KEY] = devmap_handle,
    488488                [UIH_INDEX_KEY] = index,
    489489        };
     
    507507{
    508508        unsigned long ikey[] = {
    509                 [UIH_DH_KEY] = idx->dev_handle,
     509                [UIH_DH_KEY] = idx->devmap_handle,
    510510                [UIH_INDEX_KEY] = idx->index,
    511511        };
    512         dev_handle_t dev_handle = idx->dev_handle;
     512        devmap_handle_t devmap_handle = idx->devmap_handle;
    513513        fs_index_t index = idx->index;
    514514
     
    524524        fibril_mutex_unlock(&used_lock);
    525525        /* Release the VFS index. */
    526         fat_index_free(dev_handle, index);
     526        fat_index_free(devmap_handle, index);
    527527        /* The index structure itself is freed in idx_remove_callback(). */
    528528}
     
    546546}
    547547
    548 int fat_idx_init_by_dev_handle(dev_handle_t dev_handle)
     548int fat_idx_init_by_devmap_handle(devmap_handle_t devmap_handle)
    549549{
    550550        unused_t *u;
     
    554554        if (!u)
    555555                return ENOMEM;
    556         unused_initialize(u, dev_handle);
     556        unused_initialize(u, devmap_handle);
    557557        fibril_mutex_lock(&unused_lock);
    558         if (!unused_find(dev_handle, false)) {
     558        if (!unused_find(devmap_handle, false)) {
    559559                list_append(&u->link, &unused_head);
    560560        } else {
     
    566566}
    567567
    568 void fat_idx_fini_by_dev_handle(dev_handle_t dev_handle)
     568void fat_idx_fini_by_devmap_handle(devmap_handle_t devmap_handle)
    569569{
    570570        unsigned long ikey[] = {
    571                 [UIH_DH_KEY] = dev_handle
     571                [UIH_DH_KEY] = devmap_handle
    572572        };
    573573        unsigned long pkey[] = {
    574                 [UPH_DH_KEY] = dev_handle
     574                [UPH_DH_KEY] = devmap_handle
    575575        };
    576576
     
    588588         * Free the unused and freed structures for this instance.
    589589         */
    590         unused_t *u = unused_find(dev_handle, true);
     590        unused_t *u = unused_find(devmap_handle, true);
    591591        assert(u);
    592592        list_remove(&u->link);
Note: See TracChangeset for help on using the changeset viewer.