Changeset fd9b3a67 in mainline for uspace/lib/usbdev/src/devdrv.c


Ignore:
Timestamp:
2013-01-27T00:44:23Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
71384bd3
Parents:
8b68bdf
Message:

libusbdev: Make usb_device_t opaque.

File:
1 edited

Legend:

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

    r8b68bdf rfd9b3a67  
    4040#include <str_error.h>
    4141#include <assert.h>
     42
     43/** USB device structure. */
     44typedef struct usb_device {
     45        /** Connection to USB hc, used by wire and arbitrary requests. */
     46        usb_hc_connection_t hc_conn;
     47        /** Connection backing the pipes.
     48         * Typically, you will not need to use this attribute at all.
     49         */
     50        usb_device_connection_t wire;
     51        /** The default control pipe. */
     52        usb_pipe_t ctrl_pipe;
     53
     54        /** Other endpoint pipes.
     55         * This is an array of other endpoint pipes in the same order as
     56         * in usb_driver_t.
     57         */
     58        usb_endpoint_mapping_t *pipes;
     59        /** Number of other endpoint pipes. */
     60        size_t pipes_count;
     61        /** Current interface.
     62         * Usually, drivers operate on single interface only.
     63         * This item contains the value of the interface or -1 for any.
     64         */
     65        int interface_no;
     66        /** Alternative interfaces. */
     67        usb_alternate_interfaces_t alternate_interfaces;
     68
     69        /** Some useful descriptors for USB device. */
     70        struct {
     71                /** Standard device descriptor. */
     72                usb_standard_device_descriptor_t device;
     73                /** Full configuration descriptor of current configuration. */
     74                const uint8_t *configuration;
     75                size_t configuration_size;
     76        } descriptors;
     77
     78        /** Generic DDF device backing this one. DO NOT TOUCH! */
     79        ddf_dev_t *ddf_dev;
     80        /** Custom driver data.
     81         * Do not use the entry in generic device, that is already used
     82         * by the framework.
     83         */
     84        void *driver_data;
     85
     86        usb_dev_session_t *bus_session;
     87} usb_device_t;
    4288
    4389/** Count number of pipes the driver expects.
     
    350396 * @return Error code.
    351397 */
    352 int usb_device_init(usb_device_t *usb_dev, ddf_dev_t *ddf_dev,
     398static int usb_device_init(usb_device_t *usb_dev, ddf_dev_t *ddf_dev,
    353399    const usb_endpoint_description_t **endpoints, const char **errstr_ptr)
    354400{
     
    446492 * Does not free/destroy supplied pointer.
    447493 */
    448 void usb_device_deinit(usb_device_t *dev)
     494static void usb_device_fini(usb_device_t *dev)
    449495{
    450496        if (dev) {
     
    461507}
    462508
     509int usb_device_create_ddf(ddf_dev_t *ddf_dev,
     510    const usb_endpoint_description_t **desc, const char **err)
     511{
     512        assert(ddf_dev);
     513        assert(err);
     514        usb_device_t *dev = ddf_dev_data_alloc(ddf_dev, sizeof(usb_device_t));
     515        if (dev == NULL) {
     516                *err = "DDF data alloc";
     517                return ENOMEM;
     518        }
     519        return usb_device_init(dev, ddf_dev, desc, err);
     520}
     521
     522void usb_device_destroy_ddf(ddf_dev_t *ddf_dev)
     523{
     524        assert(ddf_dev);
     525        usb_device_t *dev = ddf_dev_data_get(ddf_dev);
     526        assert(dev);
     527        usb_device_fini(dev);
     528        return;
     529}
     530
    463531const char *usb_device_get_name(usb_device_t *usb_dev)
    464532{
Note: See TracChangeset for help on using the changeset viewer.