Changes in uspace/drv/vhc/hub.c [71ed4849:b476347] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/vhc/hub.c

    r71ed4849 rb476347  
    2727 */
    2828
    29 /** @addtogroup usb
     29/** @addtogroup drvusbvhc
    3030 * @{
    3131 */
     
    4040#include <stdlib.h>
    4141#include <driver.h>
    42 #include <usb/usbdrv.h>
     42#include <usb/hub.h>
     43#include <usb/recognise.h>
    4344
    4445#include "hub.h"
     
    6364            = fibril_create(hub_register_in_devman_fibril, hc_dev);
    6465        if (root_hub_registration == 0) {
    65                 printf(NAME ": failed to register root hub\n");
     66                usb_log_fatal("Failed to create hub registration fibril.\n");
    6667                return;
    6768        }
    6869
    6970        fibril_add_ready(root_hub_registration);
     71}
     72
     73static int pretend_port_rest(int unused, void *unused2)
     74{
     75        return EOK;
    7076}
    7177
     
    7985        device_t *hc_dev = (device_t *) arg;
    8086
    81         int hc = usb_drv_hc_connect(hc_dev, hc_dev->handle, IPC_FLAG_BLOCKING);
    82         if (hc < 0) {
    83                 printf(NAME ": failed to register root hub\n");
    84                 return hc;
     87        /*
     88         * Wait until parent device is properly initialized.
     89         */
     90        int phone;
     91        do {
     92                phone = devman_device_connect(hc_dev->handle, 0);
     93        } while (phone < 0);
     94        async_hangup(phone);
     95
     96        usb_hc_connection_t hc_conn;
     97        usb_hc_connection_initialize(&hc_conn, hc_dev->handle);
     98
     99        usb_hc_connection_open(&hc_conn);
     100
     101        int rc = usb_hc_new_device_wrapper(hc_dev, &hc_conn, USB_SPEED_FULL,
     102            pretend_port_rest, 0, NULL,
     103            NULL, NULL);
     104        if (rc != EOK) {
     105                usb_log_fatal("Failed to create root hub: %s.\n",
     106                    str_error(rc));
    85107        }
    86108
    87         usb_drv_reserve_default_address(hc);
     109        usb_hc_connection_close(&hc_conn);
    88110
    89         usb_address_t hub_address = usb_drv_request_address(hc);
    90         usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT, hub_address);
    91 
    92         usb_drv_release_default_address(hc);
    93 
    94         devman_handle_t hub_handle;
    95         usb_drv_register_child_in_devman(hc, hc_dev, hub_address, &hub_handle);
    96         usb_drv_bind_address(hc, hub_address, hub_handle);
    97 
    98         return EOK;
     111        return 0;
    99112}
    100113       
Note: See TracChangeset for help on using the changeset viewer.