Ignore:
File:
1 edited

Legend:

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

    rfb422312 r79ae36dd  
    3737#include <usb/dev/request.h>
    3838#include <usb/dev/recognise.h>
    39 #include <usb/debug.h>
    4039#include <usbhc_iface.h>
    4140#include <errno.h>
     
    5857                assert((conn)); \
    5958                if (!usb_hc_connection_is_opened((conn))) { \
    60                         usb_log_error("Connection not open.\n"); \
    61                         return ENOTCONN; \
     59                        return ENOENT; \
    6260                } \
    6361        } while (false)
     
    9795 */
    9896int usb_hc_register_device(usb_hc_connection_t * connection,
    99     const usb_hub_attached_device_t *attached_device)
     97    const usb_hc_attached_device_t *attached_device)
    10098{
    10199        CHECK_CONNECTION(connection);
     
    107105        int rc = async_req_3_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    108106            IPC_M_USBHC_BIND_ADDRESS,
    109             attached_device->address, attached_device->fun->handle);
     107            attached_device->address, attached_device->handle);
    110108        async_exchange_end(exch);
    111109       
     
    157155 * The @p enable_port function is expected to enable signaling on given
    158156 * port.
    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).
     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).
    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).
    177178 * @param[in] arg Any data argument to @p enable_port.
    178179 * @param[out] assigned_address USB address of the device.
     180 * @param[out] assigned_handle Devman handle of the new device.
    179181 * @param[in] dev_ops Child device ops.
    180182 * @param[in] new_dev_data Arbitrary pointer to be stored in the child
     
    192194int usb_hc_new_device_wrapper(ddf_dev_t *parent, usb_hc_connection_t *connection,
    193195    usb_speed_t dev_speed,
    194     int (*enable_port)(void *arg), void *arg, usb_address_t *assigned_address,
     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,
    195198    ddf_dev_ops_t *dev_ops, void *new_dev_data, ddf_fun_t **new_fun)
    196199{
     
    221224        usb_address_t dev_addr = usb_hc_request_address(&hc_conn, dev_speed);
    222225        if (dev_addr < 0) {
    223                 rc = EADDRNOTAVAIL;
    224                 goto close_connection;
     226                usb_hc_connection_close(&hc_conn);
     227                return EADDRNOTAVAIL;
    225228        }
    226229
     
    276279         * device address.
    277280         */
    278         rc = enable_port(arg);
     281        rc = enable_port(port_no, arg);
    279282        if (rc != EOK) {
    280283                goto leave_release_default_address;
     
    317320         */
    318321        /* FIXME: create device_register that will get opened ctrl pipe. */
    319         ddf_fun_t *child_fun;
     322        devman_handle_t child_handle;
    320323        rc = usb_device_register_child_in_devman(dev_addr, dev_conn.hc_handle,
    321             parent, dev_ops, new_dev_data, &child_fun);
     324            parent, &child_handle,
     325            dev_ops, new_dev_data, new_fun);
    322326        if (rc != EOK) {
    323327                rc = ESTALL;
     
    328332         * And now inform the host controller about the handle.
    329333         */
    330         usb_hub_attached_device_t new_device = {
     334        usb_hc_attached_device_t new_device = {
    331335                .address = dev_addr,
    332                 .fun = child_fun,
     336                .handle = child_handle
    333337        };
    334338        rc = usb_hc_register_device(&hc_conn, &new_device);
     
    337341                goto leave_release_free_address;
    338342        }
    339 
     343       
     344        usb_hc_connection_close(&hc_conn);
    340345
    341346        /*
     
    345350                *assigned_address = dev_addr;
    346351        }
    347         if (new_fun != NULL) {
    348                 *new_fun = child_fun;
    349         }
    350 
    351         rc = EOK;
    352         goto close_connection;
     352        if (assigned_handle != NULL) {
     353                *assigned_handle = child_handle;
     354        }
     355
     356        return EOK;
     357
     358
    353359
    354360        /*
     
    362368        usb_hc_unregister_device(&hc_conn, dev_addr);
    363369
    364 close_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");
     370        usb_hc_connection_close(&hc_conn);
    368371
    369372        return rc;
Note: See TracChangeset for help on using the changeset viewer.