Ignore:
File:
1 edited

Legend:

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

    r79ae36dd rfb422312  
    3737#include <usb/dev/request.h>
    3838#include <usb/dev/recognise.h>
     39#include <usb/debug.h>
    3940#include <usbhc_iface.h>
    4041#include <errno.h>
     
    5758                assert((conn)); \
    5859                if (!usb_hc_connection_is_opened((conn))) { \
    59                         return ENOENT; \
     60                        usb_log_error("Connection not open.\n"); \
     61                        return ENOTCONN; \
    6062                } \
    6163        } while (false)
     
    9597 */
    9698int usb_hc_register_device(usb_hc_connection_t * connection,
    97     const usb_hc_attached_device_t *attached_device)
     99    const usb_hub_attached_device_t *attached_device)
    98100{
    99101        CHECK_CONNECTION(connection);
     
    105107        int rc = async_req_3_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    106108            IPC_M_USBHC_BIND_ADDRESS,
    107             attached_device->address, attached_device->handle);
     109            attached_device->address, attached_device->fun->handle);
    108110        async_exchange_end(exch);
    109111       
     
    155157 * The @p enable_port function is expected to enable signaling on given
    156158 * port.
    157  * The two arguments to it can have arbitrary meaning
    158  * (the @p port_no is only a suggestion)
    159  * and are not touched at all by this function
    160  * (they are passed as is to the @p enable_port function).
     159 * The argument can have arbitrary meaning and it is not touched at all
     160 * by this function (it is passed as is to the @p enable_port function).
    161161 *
    162162 * If the @p enable_port fails (i.e. does not return EOK), the device
     
    175175 * @param[in] enable_port Function for enabling signaling through the port the
    176176 *      device is attached to.
    177  * @param[in] port_no Port number (passed through to @p enable_port).
    178177 * @param[in] arg Any data argument to @p enable_port.
    179178 * @param[out] assigned_address USB address of the device.
    180  * @param[out] assigned_handle Devman handle of the new device.
    181179 * @param[in] dev_ops Child device ops.
    182180 * @param[in] new_dev_data Arbitrary pointer to be stored in the child
     
    194192int usb_hc_new_device_wrapper(ddf_dev_t *parent, usb_hc_connection_t *connection,
    195193    usb_speed_t dev_speed,
    196     int (*enable_port)(int port_no, void *arg), int port_no, void *arg,
    197     usb_address_t *assigned_address, devman_handle_t *assigned_handle,
     194    int (*enable_port)(void *arg), void *arg, usb_address_t *assigned_address,
    198195    ddf_dev_ops_t *dev_ops, void *new_dev_data, ddf_fun_t **new_fun)
    199196{
     
    224221        usb_address_t dev_addr = usb_hc_request_address(&hc_conn, dev_speed);
    225222        if (dev_addr < 0) {
    226                 usb_hc_connection_close(&hc_conn);
    227                 return EADDRNOTAVAIL;
     223                rc = EADDRNOTAVAIL;
     224                goto close_connection;
    228225        }
    229226
     
    279276         * device address.
    280277         */
    281         rc = enable_port(port_no, arg);
     278        rc = enable_port(arg);
    282279        if (rc != EOK) {
    283280                goto leave_release_default_address;
     
    320317         */
    321318        /* FIXME: create device_register that will get opened ctrl pipe. */
    322         devman_handle_t child_handle;
     319        ddf_fun_t *child_fun;
    323320        rc = usb_device_register_child_in_devman(dev_addr, dev_conn.hc_handle,
    324             parent, &child_handle,
    325             dev_ops, new_dev_data, new_fun);
     321            parent, dev_ops, new_dev_data, &child_fun);
    326322        if (rc != EOK) {
    327323                rc = ESTALL;
     
    332328         * And now inform the host controller about the handle.
    333329         */
    334         usb_hc_attached_device_t new_device = {
     330        usb_hub_attached_device_t new_device = {
    335331                .address = dev_addr,
    336                 .handle = child_handle
     332                .fun = child_fun,
    337333        };
    338334        rc = usb_hc_register_device(&hc_conn, &new_device);
     
    341337                goto leave_release_free_address;
    342338        }
    343        
    344         usb_hc_connection_close(&hc_conn);
     339
    345340
    346341        /*
     
    350345                *assigned_address = dev_addr;
    351346        }
    352         if (assigned_handle != NULL) {
    353                 *assigned_handle = child_handle;
    354         }
    355 
    356         return EOK;
    357 
    358 
     347        if (new_fun != NULL) {
     348                *new_fun = child_fun;
     349        }
     350
     351        rc = EOK;
     352        goto close_connection;
    359353
    360354        /*
     
    368362        usb_hc_unregister_device(&hc_conn, dev_addr);
    369363
    370         usb_hc_connection_close(&hc_conn);
     364close_connection:
     365        if (usb_hc_connection_close(&hc_conn) != EOK)
     366                usb_log_warning("usb_hc_new_device_wrapper(): Failed to close "
     367                    "connection.\n");
    371368
    372369        return rc;
Note: See TracChangeset for help on using the changeset viewer.