Changeset 89e061d in mainline


Ignore:
Timestamp:
2011-12-09T22:30:52Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1664a26
Parents:
8f5b4d44
Message:

uhcirh: Use parsed variant of hw_resources.

Fixes memory leak.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/uhcirh/main.c

    r8f5b4d44 r89e061d  
    3636#include <ddf/driver.h>
    3737#include <devman.h>
    38 #include <device/hw_res.h>
     38#include <device/hw_res_parsed.h>
    3939#include <errno.h>
    4040#include <str_error.h>
     
    136136{
    137137        assert(dev);
    138        
     138
    139139        async_sess_t *parent_sess =
    140140            devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle,
     
    142142        if (!parent_sess)
    143143                return ENOMEM;
    144        
    145         hw_resource_list_t hw_resources;
    146         const int ret = hw_res_get_resource_list(parent_sess, &hw_resources);
     144
     145        hw_res_list_parsed_t hw_res;
     146        hw_res_list_parsed_init(&hw_res);
     147        const int ret =  hw_res_get_list_parsed(parent_sess, &hw_res, 0);
     148        async_hangup(parent_sess);
    147149        if (ret != EOK) {
    148                 async_hangup(parent_sess);
    149150                return ret;
    150151        }
    151        
    152         uintptr_t io_address = 0;
    153         size_t io_size = 0;
    154         bool io_found = false;
    155        
    156         size_t i = 0;
    157         for (; i < hw_resources.count; i++) {
    158                 hw_resource_t *res = &hw_resources.resources[i];
    159                 if (res->type == IO_RANGE) {
    160                         io_address = res->res.io_range.address;
    161                         io_size = res->res.io_range.size;
    162                         io_found = true;
    163                 }
    164        
     152
     153        if (hw_res.io_ranges.count != 1) {
     154                hw_res_list_parsed_clean(&hw_res);
     155                return EINVAL;
    165156        }
    166         async_hangup(parent_sess);
    167        
    168         if (!io_found)
    169                 return ENOENT;
    170        
     157
    171158        if (io_reg_address != NULL)
    172                 *io_reg_address = io_address;
    173        
     159                *io_reg_address = hw_res.io_ranges.ranges[0].address;
     160
    174161        if (io_reg_size != NULL)
    175                 *io_reg_size = io_size;
    176        
     162                *io_reg_size = hw_res.io_ranges.ranges[0].size;
     163
     164        hw_res_list_parsed_clean(&hw_res);
    177165        return EOK;
    178166}
Note: See TracChangeset for help on using the changeset viewer.