Changeset 45f04f8 in mainline for uspace/lib/block/libblock.c


Ignore:
Timestamp:
2010-11-18T18:23:43Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3f0a7971, a7811f17, cb569e6
Parents:
51a268f (diff), c63e70c (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 changes that aim to do a better job in differentiating between
dev_handle_t and device_handle_t, respectively, by renaming these types to
devmap_handle_t and devman_handle_t, respectively.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/block/libblock.c

    r51a268f r45f04f8  
    7575typedef struct {
    7676        link_t link;
    77         dev_handle_t dev_handle;
     77        devmap_handle_t devmap_handle;
    7878        int dev_phone;
    7979        fibril_mutex_t comm_area_lock;
     
    9191static int get_num_blocks(int dev_phone, aoff64_t *nblocks);
    9292
    93 static devcon_t *devcon_search(dev_handle_t dev_handle)
     93static devcon_t *devcon_search(devmap_handle_t devmap_handle)
    9494{
    9595        link_t *cur;
     
    9898        for (cur = dcl_head.next; cur != &dcl_head; cur = cur->next) {
    9999                devcon_t *devcon = list_get_instance(cur, devcon_t, link);
    100                 if (devcon->dev_handle == dev_handle) {
     100                if (devcon->devmap_handle == devmap_handle) {
    101101                        fibril_mutex_unlock(&dcl_lock);
    102102                        return devcon;
     
    107107}
    108108
    109 static int devcon_add(dev_handle_t dev_handle, int dev_phone, size_t bsize,
     109static int devcon_add(devmap_handle_t devmap_handle, int dev_phone, size_t bsize,
    110110    void *comm_area, size_t comm_size)
    111111{
     
    121121       
    122122        link_initialize(&devcon->link);
    123         devcon->dev_handle = dev_handle;
     123        devcon->devmap_handle = devmap_handle;
    124124        devcon->dev_phone = dev_phone;
    125125        fibril_mutex_initialize(&devcon->comm_area_lock);
     
    134134        for (cur = dcl_head.next; cur != &dcl_head; cur = cur->next) {
    135135                devcon_t *d = list_get_instance(cur, devcon_t, link);
    136                 if (d->dev_handle == dev_handle) {
     136                if (d->devmap_handle == devmap_handle) {
    137137                        fibril_mutex_unlock(&dcl_lock);
    138138                        free(devcon);
     
    152152}
    153153
    154 int block_init(dev_handle_t dev_handle, size_t comm_size)
     154int block_init(devmap_handle_t devmap_handle, size_t comm_size)
    155155{
    156156        int rc;
     
    165165        }
    166166
    167         dev_phone = devmap_device_connect(dev_handle, IPC_FLAG_BLOCKING);
     167        dev_phone = devmap_device_connect(devmap_handle, IPC_FLAG_BLOCKING);
    168168        if (dev_phone < 0) {
    169169                munmap(comm_area, comm_size);
     
    185185        }
    186186       
    187         rc = devcon_add(dev_handle, dev_phone, bsize, comm_area, comm_size);
     187        rc = devcon_add(devmap_handle, dev_phone, bsize, comm_area, comm_size);
    188188        if (rc != EOK) {
    189189                munmap(comm_area, comm_size);
     
    195195}
    196196
    197 void block_fini(dev_handle_t dev_handle)
    198 {
    199         devcon_t *devcon = devcon_search(dev_handle);
     197void block_fini(devmap_handle_t devmap_handle)
     198{
     199        devcon_t *devcon = devcon_search(devmap_handle);
    200200        assert(devcon);
    201201       
    202202        if (devcon->cache)
    203                 (void) block_cache_fini(dev_handle);
     203                (void) block_cache_fini(devmap_handle);
    204204
    205205        devcon_remove(devcon);
     
    214214}
    215215
    216 int block_bb_read(dev_handle_t dev_handle, aoff64_t ba)
     216int block_bb_read(devmap_handle_t devmap_handle, aoff64_t ba)
    217217{
    218218        void *bb_buf;
    219219        int rc;
    220220
    221         devcon_t *devcon = devcon_search(dev_handle);
     221        devcon_t *devcon = devcon_search(devmap_handle);
    222222        if (!devcon)
    223223                return ENOENT;
     
    244244}
    245245
    246 void *block_bb_get(dev_handle_t dev_handle)
    247 {
    248         devcon_t *devcon = devcon_search(dev_handle);
     246void *block_bb_get(devmap_handle_t devmap_handle)
     247{
     248        devcon_t *devcon = devcon_search(devmap_handle);
    249249        assert(devcon);
    250250        return devcon->bb_buf;
     
    272272};
    273273
    274 int block_cache_init(dev_handle_t dev_handle, size_t size, unsigned blocks,
     274int block_cache_init(devmap_handle_t devmap_handle, size_t size, unsigned blocks,
    275275    enum cache_mode mode)
    276276{
    277         devcon_t *devcon = devcon_search(dev_handle);
     277        devcon_t *devcon = devcon_search(devmap_handle);
    278278        cache_t *cache;
    279279        if (!devcon)
     
    305305}
    306306
    307 int block_cache_fini(dev_handle_t dev_handle)
    308 {
    309         devcon_t *devcon = devcon_search(dev_handle);
     307int block_cache_fini(devmap_handle_t devmap_handle)
     308{
     309        devcon_t *devcon = devcon_search(devmap_handle);
    310310        cache_t *cache;
    311311        int rc;
     
    374374 * @param block                 Pointer to where the function will store the
    375375 *                              block pointer on success.
    376  * @param dev_handle            Device handle of the block device.
     376 * @param devmap_handle         Device handle of the block device.
    377377 * @param boff                  Block offset.
    378378 * @param flags                 If BLOCK_FLAGS_NOREAD is specified, block_get()
     
    382382 * @return                      EOK on success or a negative error code.
    383383 */
    384 int block_get(block_t **block, dev_handle_t dev_handle, aoff64_t boff, int flags)
     384int block_get(block_t **block, devmap_handle_t devmap_handle, aoff64_t boff, int flags)
    385385{
    386386        devcon_t *devcon;
     
    391391        int rc;
    392392       
    393         devcon = devcon_search(dev_handle);
     393        devcon = devcon_search(devmap_handle);
    394394
    395395        assert(devcon);
     
    500500
    501501                block_initialize(b);
    502                 b->dev_handle = dev_handle;
     502                b->devmap_handle = devmap_handle;
    503503                b->size = cache->lblock_size;
    504504                b->boff = boff;
     
    549549int block_put(block_t *block)
    550550{
    551         devcon_t *devcon = devcon_search(block->dev_handle);
     551        devcon_t *devcon = devcon_search(block->devmap_handle);
    552552        cache_t *cache;
    553553        unsigned blocks_cached;
     
    645645/** Read sequential data from a block device.
    646646 *
    647  * @param dev_handle    Device handle of the block device.
     647 * @param devmap_handle Device handle of the block device.
    648648 * @param bufpos        Pointer to the first unread valid offset within the
    649649 *                      communication buffer.
     
    657657 * @return              EOK on success or a negative return code on failure.
    658658 */
    659 int block_seqread(dev_handle_t dev_handle, size_t *bufpos, size_t *buflen,
     659int block_seqread(devmap_handle_t devmap_handle, size_t *bufpos, size_t *buflen,
    660660    aoff64_t *pos, void *dst, size_t size)
    661661{
     
    665665        devcon_t *devcon;
    666666
    667         devcon = devcon_search(dev_handle);
     667        devcon = devcon_search(devmap_handle);
    668668        assert(devcon);
    669669        block_size = devcon->pblock_size;
     
    711711/** Read blocks directly from device (bypass cache).
    712712 *
    713  * @param dev_handle    Device handle of the block device.
     713 * @param devmap_handle Device handle of the block device.
    714714 * @param ba            Address of first block.
    715715 * @param cnt           Number of blocks.
     
    718718 * @return              EOK on success or negative error code on failure.
    719719 */
    720 int block_read_direct(dev_handle_t dev_handle, aoff64_t ba, size_t cnt, void *buf)
     720int block_read_direct(devmap_handle_t devmap_handle, aoff64_t ba, size_t cnt, void *buf)
    721721{
    722722        devcon_t *devcon;
    723723        int rc;
    724724
    725         devcon = devcon_search(dev_handle);
     725        devcon = devcon_search(devmap_handle);
    726726        assert(devcon);
    727727       
     
    739739/** Write blocks directly to device (bypass cache).
    740740 *
    741  * @param dev_handle    Device handle of the block device.
     741 * @param devmap_handle Device handle of the block device.
    742742 * @param ba            Address of first block.
    743743 * @param cnt           Number of blocks.
     
    746746 * @return              EOK on success or negative error code on failure.
    747747 */
    748 int block_write_direct(dev_handle_t dev_handle, aoff64_t ba, size_t cnt,
     748int block_write_direct(devmap_handle_t devmap_handle, aoff64_t ba, size_t cnt,
    749749    const void *data)
    750750{
     
    752752        int rc;
    753753
    754         devcon = devcon_search(dev_handle);
     754        devcon = devcon_search(devmap_handle);
    755755        assert(devcon);
    756756       
     
    767767/** Get device block size.
    768768 *
    769  * @param dev_handle    Device handle of the block device.
     769 * @param devmap_handle Device handle of the block device.
    770770 * @param bsize         Output block size.
    771771 *
    772772 * @return              EOK on success or negative error code on failure.
    773773 */
    774 int block_get_bsize(dev_handle_t dev_handle, size_t *bsize)
     774int block_get_bsize(devmap_handle_t devmap_handle, size_t *bsize)
    775775{
    776776        devcon_t *devcon;
    777777
    778         devcon = devcon_search(dev_handle);
     778        devcon = devcon_search(devmap_handle);
    779779        assert(devcon);
    780780       
     
    784784/** Get number of blocks on device.
    785785 *
    786  * @param dev_handle    Device handle of the block device.
     786 * @param devmap_handle Device handle of the block device.
    787787 * @param nblocks       Output number of blocks.
    788788 *
    789789 * @return              EOK on success or negative error code on failure.
    790790 */
    791 int block_get_nblocks(dev_handle_t dev_handle, aoff64_t *nblocks)
     791int block_get_nblocks(devmap_handle_t devmap_handle, aoff64_t *nblocks)
    792792{
    793793        devcon_t *devcon;
    794794
    795         devcon = devcon_search(dev_handle);
     795        devcon = devcon_search(devmap_handle);
    796796        assert(devcon);
    797797       
     
    818818                printf("Error %d reading %d blocks starting at block %" PRIuOFF64
    819819                    " from device handle %d\n", rc, cnt, ba,
    820                     devcon->dev_handle);
     820                    devcon->devmap_handle);
    821821#ifndef NDEBUG
    822822                stacktrace_print();
     
    844844        if (rc != EOK) {
    845845                printf("Error %d writing %d blocks starting at block %" PRIuOFF64
    846                     " to device handle %d\n", rc, cnt, ba, devcon->dev_handle);
     846                    " to device handle %d\n", rc, cnt, ba, devcon->devmap_handle);
    847847#ifndef NDEBUG
    848848                stacktrace_print();
Note: See TracChangeset for help on using the changeset viewer.