Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset c0fdc0e in mainline


Ignore:
Timestamp:
2011-12-11T18:17:47Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
0681c06
Parents:
7267fa1
Message:

libusbdev: Pre open hc connection. Drop support for dev_rem.

hc_connection will be used for both descriptor retrieval and pipe registration,
so it's better to do it in advance.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/src/devdrv.c

    r7267fa1 rc0fdc0e  
    170170                return ENOTSUP;
    171171        /* Just tell the driver to stop whatever it is doing, keep structures */
    172         return driver->ops->device_rem(gen_dev->driver_data);
     172        const int ret = driver->ops->device_rem(gen_dev->driver_data);
     173        if (ret != EOK)
     174                return ret;
     175        return ENOTSUP;
    173176}
    174177/*----------------------------------------------------------------------------*/
     
    481484        usb_dev->pipes = NULL;
    482485
     486        /* Initialize hc connection. */
    483487        usb_hc_connection_initialize_from_device(&usb_dev->hc_conn, ddf_dev);
    484488        const usb_address_t address =
    485489            usb_get_address_by_handle(ddf_dev->handle);
     490
    486491        /* Initialize backing wire and control pipe. */
    487492        int rc = usb_device_connection_initialize(
     
    494499        /* This pipe was registered by the hub driver,
    495500         * during device initialization. */
    496         rc = usb_pipe_initialize_default_control(&usb_dev->ctrl_pipe,
    497             &usb_dev->wire);
     501        rc = usb_pipe_initialize_default_control(
     502            &usb_dev->ctrl_pipe, &usb_dev->wire);
    498503        if (rc != EOK) {
    499504                *errstr_ptr = "default control pipe initialization";
     505                return rc;
     506        }
     507
     508        rc = usb_hc_connection_open(&usb_dev->hc_conn);
     509        if (rc != EOK) {
     510                *errstr_ptr = "hc connection open";
    500511                return rc;
    501512        }
     
    503514        /* Get our interface. */
    504515        usb_dev->interface_no = usb_device_get_assigned_interface(ddf_dev);
    505 
    506516        /* Retrieve standard descriptors. */
    507         rc = usb_device_retrieve_descriptors(&usb_dev->ctrl_pipe,
    508             &usb_dev->descriptors);
     517        rc = usb_device_retrieve_descriptors(
     518            &usb_dev->ctrl_pipe, &usb_dev->descriptors);
    509519        if (rc != EOK) {
    510520                *errstr_ptr = "descriptor retrieval";
     521                usb_hc_connection_close(&usb_dev->hc_conn);
    511522                return rc;
    512523        }
     
    525536        rc = initialize_other_pipes(endpoints, usb_dev, alternate_iface);
    526537        if (rc != EOK) {
     538                usb_hc_connection_close(&usb_dev->hc_conn);
    527539                /* Full configuration descriptor is allocated. */
    528540                usb_device_release_descriptors(&usb_dev->descriptors);
     
    533545        }
    534546
     547        usb_hc_connection_close(&usb_dev->hc_conn);
    535548        return EOK;
    536549}
Note: See TracChangeset for help on using the changeset viewer.