Changeset 59c163c in mainline for uspace/lib/usbdev/src/recognise.c


Ignore:
Timestamp:
2011-10-31T11:49:15Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1e6dc5b
Parents:
90d7033
Message:

libusbdev: Automatically create attached device info for new devices.

File:
1 edited

Legend:

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

    r90d7033 r59c163c  
    3535#include <sys/types.h>
    3636#include <fibril_synch.h>
     37#include <usb/debug.h>
     38#include <usb/dev/hub.h>
    3739#include <usb/dev/pipes.h>
    3840#include <usb/dev/recognise.h>
     
    353355                return EINVAL;
    354356
     357        if (!dev_ops && dev_data) {
     358                usb_log_warning("Using standard fun ops with arbitrary "
     359                    "driver data. This does not have to work.\n");
     360        }
     361
    355362        size_t this_device_name_index;
    356363
     
    366373        usb_pipe_t ctrl_pipe;
    367374
    368         rc = usb_device_connection_initialize(&dev_connection, hc_handle, address);
    369         if (rc != EOK) {
    370                 goto failure;
    371         }
    372 
    373         rc = usb_pipe_initialize_default_control(&ctrl_pipe,
    374             &dev_connection);
     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);
    375382        if (rc != EOK) {
    376383                goto failure;
     
    405412
    406413        child->driver_data = dev_data;
     414        /* Store the attached device in fun driver data if there is no
     415         * other data */
     416        if (!dev_data) {
     417                usb_hub_attached_device_t *new_device = ddf_fun_data_alloc(
     418                    child, sizeof(usb_hub_attached_device_t));
     419                if (!new_device) {
     420                        rc = ENOMEM;
     421                        goto failure;
     422                }
     423                new_device->address = address;
     424                new_device->fun = child;
     425        }
     426
    407427
    408428        rc = usb_device_create_match_ids(&ctrl_pipe, &child->match_ids);
     
    421441failure:
    422442        if (child != NULL) {
    423                 /* This was not malloced by us, does not even have to be
    424                  * on heap. */
    425                 child->driver_data = NULL;
     443                /* We know nothing about the data if it came from outside. */
     444                if (dev_data) {
     445                        child->driver_data = NULL;
     446                }
    426447                /* This takes care of match_id deallocation as well. */
    427448                ddf_fun_destroy(child);
Note: See TracChangeset for help on using the changeset viewer.