Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-rhd/port.c

    r563ead9 r5f94a0c  
    3636#include <errno.h>
    3737#include <str_error.h>
     38#include <time.h>
    3839#include <async.h>
    3940
    4041#include <usb/usb.h>    /* usb_address_t */
    41 #include <usb/dev/hub.h>    /* usb_hc_new_device_wrapper */
     42#include <usb/hub.h>    /* usb_hc_new_device_wrapper */
    4243#include <usb/debug.h>
    4344
     
    8182 * @param[in] number Port number.
    8283 * @param[in] usec Polling interval.
    83  * @param[in] rh Pointer to ddf instance of the root hub driver.
     84 * @param[in] rh Pointer to ddf instance fo the root hub driver.
    8485 * @return Error code.
    8586 *
     
    9091{
    9192        assert(port);
    92         char *id_string;
    93         asprintf(&id_string, "Port (%p - %u)", port, number);
    94         if (id_string == NULL) {
     93        asprintf(&port->id_string, "Port (%p - %u)", port, number);
     94        if (port->id_string == NULL) {
    9595                return ENOMEM;
    9696        }
    9797
    98         port->id_string = id_string;
    9998        port->address = address;
    10099        port->number = number;
     
    106105            usb_hc_connection_initialize_from_device(&port->hc_connection, rh);
    107106        if (ret != EOK) {
    108                 usb_log_error("%s: failed to initialize connection to HC.",
    109                     port->id_string);
    110                 free(id_string);
     107                usb_log_error("Failed to initialize connection to HC.");
    111108                return ret;
    112109        }
     
    116113                usb_log_error("%s: failed to create polling fibril.",
    117114                    port->id_string);
    118                 free(id_string);
    119115                return ENOMEM;
    120116        }
     
    136132        assert(port);
    137133        free(port->id_string);
    138         // TODO: Kill fibril here
     134        /* TODO: Kill fibril here */
    139135        return;
    140136}
     
    154150
    155151                /* Read register value */
    156                 const port_status_t port_status =
    157                     uhci_port_read_status(instance);
     152                port_status_t port_status = uhci_port_read_status(instance);
    158153
    159154                /* Print the value if it's interesting */
     
    166161                usb_log_debug("%s: Connected change detected: %x.\n",
    167162                    instance->id_string, port_status);
     163
     164                int rc =
     165                    usb_hc_connection_open(&instance->hc_connection);
     166                if (rc != EOK) {
     167                        usb_log_error("%s: Failed to connect to HC.",
     168                            instance->id_string);
     169                        continue;
     170                }
    168171
    169172                /* Remove any old device */
     
    172175                            instance->id_string);
    173176                        uhci_port_remove_device(instance);
    174                 }
    175 
    176                 int ret =
    177                     usb_hc_connection_open(&instance->hc_connection);
    178                 if (ret != EOK) {
    179                         usb_log_error("%s: Failed to connect to HC.",
    180                             instance->id_string);
    181                         continue;
    182177                }
    183178
     
    195190                }
    196191
    197                 ret = usb_hc_connection_close(&instance->hc_connection);
    198                 if (ret != EOK) {
     192                rc = usb_hc_connection_close(&instance->hc_connection);
     193                if (rc != EOK) {
    199194                        usb_log_error("%s: Failed to disconnect.",
    200195                            instance->id_string);
     
    214209int uhci_port_reset_enable(int portno, void *arg)
    215210{
    216         uhci_port_t *port = arg;
    217         assert(port);
     211        uhci_port_t *port = (uhci_port_t *) arg;
    218212
    219213        usb_log_debug2("%s: new_device_enable_port.\n", port->id_string);
     
    289283        usb_log_error("%s: Don't know how to remove device %" PRIun ".\n",
    290284            port->id_string, port->attached_device);
    291         port->attached_device = 0;
    292285        return ENOTSUP;
    293286}
Note: See TracChangeset for help on using the changeset viewer.