Changeset 2179cf95 in mainline


Ignore:
Timestamp:
2011-11-04T21:55:48Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
37e4025
Parents:
3238506
Message:

libusbdev: usb_device_register_child_in_devman takes open control pipe.

Instead of doing all the initialization again.

Location:
uspace/lib/usbdev
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/include/usb/dev/recognise.h

    r3238506 r2179cf95  
    5050int usb_device_create_match_ids(usb_pipe_t *, match_id_list_t *);
    5151
    52 int usb_device_register_child_in_devman(usb_address_t, devman_handle_t,
     52int usb_device_register_child_in_devman(usb_pipe_t *ctrl_pipe,
    5353    ddf_dev_t *, ddf_dev_ops_t *, void *, ddf_fun_t **);
    5454
  • uspace/lib/usbdev/src/hub.c

    r3238506 r2179cf95  
    348348        /* FIXME: create device_register that will get opened ctrl pipe. */
    349349        ddf_fun_t *child_fun;
    350         rc = usb_device_register_child_in_devman(dev_addr, dev_conn.hc_handle,
     350        rc = usb_device_register_child_in_devman(&ctrl_pipe,
    351351            parent, dev_ops, new_dev_data, &child_fun);
    352352        if (rc != EOK) {
  • uspace/lib/usbdev/src/recognise.c

    r3238506 r2179cf95  
    316316    match_id_list_t *matches)
    317317{
     318        assert(ctrl_pipe);
    318319        int rc;
    319320        /*
     
    338339/** Probe for device kind and register it in devman.
    339340 *
    340  * @param[in] address Address of the (unknown) attached device.
    341  * @param[in] hc_handle Handle of the host controller.
     341 * @param[in] ctrl_pipe Control pipe to the device.
    342342 * @param[in] parent Parent device.
    343343 * @param[in] dev_ops Child device ops. Default child_ops will be used if NULL.
     
    348348 * @return Error code.
    349349 */
    350 int usb_device_register_child_in_devman(usb_address_t address,
    351     devman_handle_t hc_handle, ddf_dev_t *parent,
    352     ddf_dev_ops_t *dev_ops, void *dev_data, ddf_fun_t **child_fun)
     350int usb_device_register_child_in_devman(usb_pipe_t *ctrl_pipe,
     351    ddf_dev_t *parent, ddf_dev_ops_t *dev_ops, void *dev_data,
     352    ddf_fun_t **child_fun)
    353353{
    354         if (child_fun == NULL)
     354        if (child_fun == NULL || ctrl_pipe == NULL)
    355355                return EINVAL;
    356356
     
    360360        }
    361361
    362         size_t this_device_name_index;
    363 
    364362        fibril_mutex_lock(&device_name_index_mutex);
    365         this_device_name_index = device_name_index;
    366         device_name_index++;
     363        const size_t this_device_name_index = device_name_index++;
    367364        fibril_mutex_unlock(&device_name_index_mutex);
    368365
    369366        ddf_fun_t *child = NULL;
    370         char *child_name = NULL;
    371367        int rc;
    372         usb_device_connection_t dev_connection;
    373         usb_pipe_t ctrl_pipe;
    374 
    375         rc = usb_device_connection_initialize(
    376             &dev_connection, hc_handle, address);
    377         if (rc != EOK) {
    378                 goto failure;
    379         }
    380 
    381         rc = usb_pipe_initialize_default_control(&ctrl_pipe, &dev_connection);
    382         if (rc != EOK) {
    383                 goto failure;
    384         }
    385         rc = usb_pipe_probe_default_control(&ctrl_pipe);
    386         if (rc != EOK) {
    387                 goto failure;
    388         }
    389368
    390369        /*
     
    392371         * naming etc., something more descriptive could be created.
    393372         */
    394         rc = asprintf(&child_name, "usb%02zu_a%d",
    395             this_device_name_index, address);
     373        char child_name[12]; /* The format is: "usbAB_aXYZ", length 11 */
     374        rc = snprintf(child_name, sizeof(child_name),
     375            "usb%02zu_a%d", this_device_name_index, ctrl_pipe->wire->address);
    396376        if (rc < 0) {
    397377                goto failure;
     
    399379
    400380        child = ddf_fun_create(parent, fun_inner, child_name);
    401         free(child_name);
    402381        if (child == NULL) {
    403382                rc = ENOMEM;
     
    421400                        goto failure;
    422401                }
    423                 new_device->address = address;
     402                new_device->address = ctrl_pipe->wire->address;
    424403                new_device->fun = child;
    425404        }
    426405
    427406
    428         rc = usb_device_create_match_ids(&ctrl_pipe, &child->match_ids);
     407        rc = usb_device_create_match_ids(ctrl_pipe, &child->match_ids);
    429408        if (rc != EOK) {
    430409                goto failure;
Note: See TracChangeset for help on using the changeset viewer.