Changeset 90994fa in mainline


Ignore:
Timestamp:
2011-10-12T20:03:36Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
162726b
Parents:
205f0766
Message:

usb: Hubs should store child functions not just handles.

Location:
uspace
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/uhcirh/port.c

    r205f0766 r90994fa  
    100100        port->number = number;
    101101        port->wait_period_usec = usec;
    102         port->attached_device.handle = 0;
     102        port->attached_device.fun = NULL;
    103103        port->attached_device.address = -1;
    104104        port->rh = rh;
     
    169169
    170170                /* Remove any old device */
    171                 if (instance->attached_device.handle) {
     171                if (instance->attached_device.fun) {
    172172                        usb_log_debug2("%s: Removing device.\n",
    173173                            instance->id_string);
     
    261261                ret = usb_hc_new_device_wrapper(port->rh, &port->hc_connection,
    262262                    speed, uhci_port_reset_enable, port->number, port,
    263                     &port->attached_device.address,
    264                     &port->attached_device.handle, NULL, NULL, NULL);
     263                    &port->attached_device.address, NULL, NULL, NULL,
     264                    &port->attached_device.fun);
    265265        } while (ret != EOK && ++count < 4);
    266266
     
    274274        usb_log_info("New device at port %u, address %d (handle %" PRIun ").\n",
    275275            port->number, port->attached_device.address,
    276             port->attached_device.handle);
     276            port->attached_device.fun->handle);
    277277        return EOK;
    278278}
     
    287287        assert(port);
    288288        /* There is nothing to remove. */
    289         if (port->attached_device.handle == 0) {
     289        if (port->attached_device.fun == NULL) {
    290290                usb_log_warning("%s: Removed a ghost device.\n",
    291291                    port->id_string);
     
    297297
    298298        /* Stop driver first */
    299         int ret = devman_remove_function(port->attached_device.handle);
     299        int ret = ddf_fun_unbind(port->attached_device.fun);
    300300        if (ret != EOK) {
    301301                usb_log_error("%s: Failed to remove child function: %s.\n",
     
    303303                return ret;
    304304        }
    305         port->attached_device.handle = 0;
     305        ddf_fun_destroy(port->attached_device.fun);
     306        port->attached_device.fun = NULL;
    306307
    307308        /* Driver stopped, free used address */
  • uspace/drv/bus/usb/usbhub/port.c

    r205f0766 r90994fa  
    257257                usb_log_debug("Removing device on port %zu.\n",
    258258                    port->port_number);
    259                 const int ret =
    260                     devman_remove_function(port->attached_device.handle);
     259                const int ret = ddf_fun_unbind(port->attached_device.fun);
    261260                if (ret == EOK) {
     261                        ddf_fun_destroy(port->attached_device.fun);
    262262                        const int ret =
    263263                            usb_hc_unregister_device(&hub->connection,
     
    269269                        }
    270270                } else {
    271                         usb_log_error("Failed to remove child function on port"
     271                        usb_log_error("Failed to unbind child function on port"
    272272                           " %zu: %s.\n", port->port_number, str_error(ret));
    273273                }
    274274                port->attached_device.address = -1;
    275                 port->attached_device.handle = 0;
     275                port->attached_device.fun = NULL;
    276276                fibril_mutex_unlock(&port->mutex);
    277277                usb_log_info("Removed device on port %zu.\n",
     
    418418
    419419        usb_address_t new_address;
    420         devman_handle_t child_handle;
     420        ddf_fun_t *child_fun;
    421421
    422422        const int rc = usb_hc_new_device_wrapper(data->hub->usb_device->ddf_dev,
    423423            &data->hub->connection, data->speed,
    424424            enable_port_callback, (int) data->port->port_number,
    425             data->port, &new_address, &child_handle,
    426             NULL, NULL, NULL);
     425            data->port, &new_address, NULL,
     426            NULL, NULL, &child_fun);
    427427
    428428        if (rc != EOK) {
     
    433433
    434434        fibril_mutex_lock(&data->port->mutex);
    435         data->port->attached_device.handle = child_handle;
     435        data->port->attached_device.fun = child_fun;
    436436        data->port->attached_device.address = new_address;
    437437        fibril_mutex_unlock(&data->port->mutex);
     
    440440            "address %d (handle %" PRIun ").\n",
    441441            data->hub->usb_device->ddf_dev->name, data->port->port_number,
    442             new_address, child_handle);
     442            new_address, child_fun->handle);
    443443
    444444leave:
  • uspace/drv/bus/usb/usbhub/port.h

    r205f0766 r90994fa  
    7070        assert(port);
    7171        port->attached_device.address = -1;
    72         port->attached_device.handle = 0;
     72        port->attached_device.fun = NULL;
    7373        port->port_number = port_number;
    7474        port->control_pipe = control_pipe;
  • uspace/lib/usbdev/include/usb/dev/hub.h

    r205f0766 r90994fa  
    3838#define LIBUSBDEV_HUB_H_
    3939
     40#include <ddf/driver.h>
    4041#include <sys/types.h>
    4142#include <usb/hc.h>
     
    5556        /** Device address. */
    5657        usb_address_t address;
    57         /** Devman handle of the device. */
    58         devman_handle_t handle;
     58        /** DDF function (external) of the device. */
     59        ddf_fun_t *fun;
    5960} usb_hub_attached_device_t;
    6061
  • uspace/lib/usbdev/src/hub.c

    r205f0766 r90994fa  
    105105        int rc = async_req_3_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    106106            IPC_M_USBHC_BIND_ADDRESS,
    107             attached_device->address, attached_device->handle);
     107            attached_device->address, attached_device->fun->handle);
    108108        async_exchange_end(exch);
    109109       
     
    320320         */
    321321        /* FIXME: create device_register that will get opened ctrl pipe. */
    322         devman_handle_t child_handle;
     322        ddf_fun_t *child_fun;
    323323        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);
     324            parent, NULL,
     325            dev_ops, new_dev_data, &child_fun);
    326326        if (rc != EOK) {
    327327                rc = ESTALL;
     
    334334        usb_hub_attached_device_t new_device = {
    335335                .address = dev_addr,
    336                 .handle = child_handle
     336                .fun = child_fun,
    337337        };
    338338        rc = usb_hc_register_device(&hc_conn, &new_device);
     
    351351        }
    352352        if (assigned_handle != NULL) {
    353                 *assigned_handle = child_handle;
     353                *assigned_handle = child_fun->handle;
     354        }
     355        if (new_fun != NULL) {
     356                *new_fun = child_fun;
    354357        }
    355358
Note: See TracChangeset for help on using the changeset viewer.