Changeset 59c163c in mainline


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.

Location:
uspace/lib/usbdev/src
Files:
2 edited

Legend:

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

    r90d7033 r59c163c  
    179179 * @param[in] dev_ops Child device ops. Will use default if not provided.
    180180 * @param[in] new_dev_data Arbitrary pointer to be stored in the child
    181  *      as @c driver_data.
     181 *      as @c driver_data. Will allocate and assign usb_hub_attached_device_t
     182 *      structure if NULL.
    182183 * @param[out] new_fun Storage where pointer to allocated child function
    183184 *      will be written. Must be non-null.
     
    219220        }
    220221
    221 
    222222        /*
    223223         * Request new address.
     
    328328        }
    329329
    330         /*
    331          * And now inform the host controller about the handle.
    332          */
    333330        const usb_hub_attached_device_t new_device = {
    334331                .address = dev_addr,
    335332                .fun = child_fun,
    336333        };
     334
     335
     336        /*
     337         * And now inform the host controller about the handle.
     338         */
    337339        rc = usb_hc_register_device(&hc_conn, &new_device);
    338340        if (rc != EOK) {
     341                /* We know nothing about that data. */
     342                if (new_dev_data)
     343                        child_fun->driver_data = NULL;
    339344                /* The child function is already created. */
    340                 child_fun->driver_data = NULL;
    341345                ddf_fun_destroy(child_fun);
    342346                rc = EDESTADDRREQ;
  • 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.