Changeset ca56afa in mainline for uspace/drv/uhci-hcd/root_hub.c


Ignore:
Timestamp:
2011-02-25T09:46:23Z (13 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d493ac17
Parents:
15b0432 (diff), a80849c (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 with /usb/development

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/root_hub.c

    r15b0432 rca56afa  
    3939
    4040#include "root_hub.h"
     41#include "uhci.h"
    4142
    42 extern device_ops_t child_ops;
     43static int usb_iface_get_hc_handle_rh_impl(ddf_fun_t *root_hub_fun,
     44    devman_handle_t *handle)
     45{
     46        ddf_fun_t *hc_fun = root_hub_fun->driver_data;
     47        assert(hc_fun != NULL);
     48
     49        *handle = hc_fun->handle;
     50
     51        return EOK;
     52}
     53
     54static int usb_iface_get_address_rh_impl(ddf_fun_t *fun, devman_handle_t handle,
     55    usb_address_t *address)
     56{
     57        assert(fun);
     58        ddf_fun_t *hc_fun = fun->driver_data;
     59        assert(hc_fun);
     60        uhci_t *hc = fun_to_uhci(hc_fun);
     61        assert(hc);
     62
     63        usb_address_t addr = usb_address_keeping_find(&hc->address_manager,
     64            handle);
     65        if (addr < 0) {
     66                return addr;
     67        }
     68
     69        if (address != NULL) {
     70                *address = addr;
     71        }
     72
     73        return EOK;
     74}
     75
     76usb_iface_t usb_iface_root_hub_fun_impl = {
     77        .get_hc_handle = usb_iface_get_hc_handle_rh_impl,
     78        .get_address = usb_iface_get_address_rh_impl
     79};
     80
     81static ddf_dev_ops_t root_hub_ops = {
     82        .interfaces[USB_DEV_IFACE] = &usb_iface_root_hub_fun_impl
     83};
     84
    4385/*----------------------------------------------------------------------------*/
    44 int setup_root_hub(device_t **device, device_t *hc)
     86int setup_root_hub(ddf_fun_t **fun, ddf_dev_t *hc)
    4587{
    46         assert(device);
    47         device_t *hub = create_device();
     88        assert(fun);
     89        int ret;
     90
     91        ddf_fun_t *hub = ddf_fun_create(hc, fun_inner, "root-hub");
    4892        if (!hub) {
    4993                usb_log_error("Failed to create root hub device structure.\n");
    50                 return ENOMEM;
    51         }
    52         char *name;
    53         int ret = asprintf(&name, "UHCI Root Hub");
    54         if (ret < 0) {
    55                 usb_log_error("Failed to create root hub name.\n");
    56                 free(hub);
    5794                return ENOMEM;
    5895        }
     
    6299        if (ret < 0) {
    63100                usb_log_error("Failed to create root hub match string.\n");
    64                 free(hub);
    65                 free(name);
     101                ddf_fun_destroy(hub);
    66102                return ENOMEM;
    67103        }
    68104
    69         match_id_t *match_id = create_match_id();
    70         if (!match_id) {
    71                 usb_log_error("Failed to create root hub match id.\n");
    72                 free(hub);
    73                 free(match_str);
     105        ret = ddf_fun_add_match_id(hub, match_str, 100);
     106        if (ret != EOK) {
     107                usb_log_error("Failed to add root hub match id.\n");
     108                ddf_fun_destroy(hub);
    74109                return ENOMEM;
    75110        }
    76         match_id->id = match_str;
    77         match_id->score = 90;
    78111
    79         add_match_id(&hub->match_ids, match_id);
    80         hub->name = name;
    81         hub->parent = hc;
    82         hub->ops = &child_ops;
     112        hub->ops = &root_hub_ops;
    83113
    84         *device = hub;
     114        *fun = hub;
    85115        return EOK;
    86116}
Note: See TracChangeset for help on using the changeset viewer.