Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/uhci/pci.c

    r266976f r45a9cf4  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
     28
    2829/**
    2930 * @addtogroup drvusbuhcihc
     
    3839#include <assert.h>
    3940#include <devman.h>
    40 #include <device/hw_res_parsed.h>
     41#include <device/hw_res.h>
    4142
    4243#include <usb/debug.h>
     
    6768                return ENOMEM;
    6869
    69         hw_res_list_parsed_t hw_res;
    70         hw_res_list_parsed_init(&hw_res);
    71         const int ret =  hw_res_get_list_parsed(parent_sess, &hw_res, 0);
     70        hw_resource_list_t hw_resources;
     71        const int rc = hw_res_get_resource_list(parent_sess, &hw_resources);
    7272        async_hangup(parent_sess);
    73         if (ret != EOK) {
    74                 return ret;
     73        if (rc != EOK) {
     74                return rc;
    7575        }
    7676
    77         /* We want one irq and one io range. */
    78         if (hw_res.irqs.count != 1 || hw_res.io_ranges.count != 1) {
    79                 hw_res_list_parsed_clean(&hw_res);
    80                 return EINVAL;
     77        uintptr_t io_address = 0;
     78        size_t io_size = 0;
     79        bool io_found = false;
     80
     81        int irq = 0;
     82        bool irq_found = false;
     83
     84        size_t i;
     85        for (i = 0; i < hw_resources.count; i++) {
     86                const hw_resource_t *res = &hw_resources.resources[i];
     87                switch (res->type) {
     88                case INTERRUPT:
     89                        irq = res->res.interrupt.irq;
     90                        irq_found = true;
     91                        usb_log_debug2("Found interrupt: %d.\n", irq);
     92                        break;
     93                case IO_RANGE:
     94                        io_address = res->res.io_range.address;
     95                        io_size = res->res.io_range.size;
     96                        usb_log_debug2("Found io: %" PRIx64" %zu.\n",
     97                            res->res.io_range.address, res->res.io_range.size);
     98                        io_found = true;
     99                        break;
     100                default:
     101                        break;
     102                }
    81103        }
     104        free(hw_resources.resources);
    82105
    83         if (io_reg_address)
    84                 *io_reg_address = hw_res.io_ranges.ranges[0].address;
    85         if (io_reg_size)
    86                 *io_reg_size = hw_res.io_ranges.ranges[0].size;
    87         if (irq_no)
    88                 *irq_no = hw_res.irqs.irqs[0];
     106        if (!io_found || !irq_found)
     107                return ENOENT;
    89108
    90         hw_res_list_parsed_clean(&hw_res);
     109        *io_reg_address = io_address;
     110        *io_reg_size = io_size;
     111        *irq_no = irq;
     112
    91113        return EOK;
    92114}
Note: See TracChangeset for help on using the changeset viewer.