Changeset b68b279 in mainline


Ignore:
Timestamp:
2011-02-20T14:20:59Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
95120c3
Parents:
357a302
Message:

MID driver handles get_address requests correctly

Also, splitted some error messages to get more details.

Location:
uspace/drv/usbmid
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbmid/main.c

    r357a302 rb68b279  
    4848        usbmid_device_t *dev = usbmid_device_create(gen_dev);
    4949        if (dev == NULL) {
    50                 usb_log_error("Initialization of new USB MID device failed.\n");
    5150                return ENOMEM;
    5251        }
  • uspace/drv/usbmid/usbmid.c

    r357a302 rb68b279  
    3838#include <stdlib.h>
    3939#include <usb_iface.h>
     40#include <usb/ddfiface.h>
    4041#include <usb/pipes.h>
    4142#include <usb/classes/classes.h>
     
    4445
    4546/** Callback for DDF USB interface. */
    46 static int iface_get_hc_handle(device_t *dev, devman_handle_t *handle)
     47static int usb_iface_get_address_impl(device_t *device, devman_handle_t handle,
     48    usb_address_t *address)
    4749{
    48         device_t *parent = dev->parent;
     50        assert(device);
     51        device_t *parent = device->parent;
    4952
    50         usb_log_debug("iface_get_hc_handle(dev=%zu)\n", (size_t) dev->handle);
     53        /* Default error, device does not support this operation. */
     54        int rc = ENOTSUP;
    5155
    5256        if (parent && parent->ops && parent->ops->interfaces[USB_DEV_IFACE]) {
     
    5458                    = (usb_iface_t *) parent->ops->interfaces[USB_DEV_IFACE];
    5559                assert(usb_iface != NULL);
    56                 if (usb_iface->get_hc_handle) {
    57                         int rc = usb_iface->get_hc_handle(parent, handle);
    58                         return rc;
     60
     61                if (usb_iface->get_address) {
     62                        rc = usb_iface->get_address(parent, parent->handle,
     63                            address);
    5964                }
    60                 return ENOTSUP;
    61         } else {
    62                 return usb_hc_find(dev->handle, handle);
    6365        }
     66
     67        return rc;
    6468}
    6569
    66 static usb_iface_t usb_iface = {
    67         .get_hc_handle = iface_get_hc_handle
     70static usb_iface_t child_usb_iface = {
     71        .get_hc_handle = usb_iface_get_hc_handle_hub_child_impl,
     72        .get_address = usb_iface_get_address_impl
    6873};
    6974
    70 static device_ops_t device_ops = {
    71         .interfaces[USB_DEV_IFACE] = &usb_iface
     75
     76static device_ops_t child_device_ops = {
     77        .interfaces[USB_DEV_IFACE] = &child_usb_iface
     78};
     79
     80static device_ops_t mid_device_ops = {
     81        .interfaces[USB_DEV_IFACE] = &usb_iface_hub_impl
    7282};
    7383
     
    8292        usbmid_device_t *mid = malloc(sizeof(usbmid_device_t));
    8393        if (mid == NULL) {
     94                usb_log_error("Out of memory (wanted %zu bytes).\n",
     95                    sizeof(usbmid_device_t));
    8496                return NULL;
    8597        }
     
    88100        rc = usb_device_connection_initialize_from_device(&mid->wire, dev);
    89101        if (rc != EOK) {
     102                usb_log_error("Failed to initialize `USB wire': %s.\n",
     103                    str_error(rc));
    90104                free(mid);
    91105                return NULL;
     
    95109            &mid->wire);
    96110        if (rc != EOK) {
     111                usb_log_error("Failed to initialize control pipe: %s.\n",
     112                    str_error(rc));
    97113                free(mid);
    98114                return NULL;
     
    100116
    101117        mid->dev = dev;
    102         dev->ops = &device_ops;
     118        dev->ops = &mid_device_ops;
    103119
    104120        return mid;
     
    141157        child->parent = parent->dev;
    142158        child->name = child_name;
    143         child->ops = &device_ops;
     159        child->ops = &child_device_ops;
    144160
    145161        rc = usb_device_create_match_ids_from_interface(interface_descriptor,
Note: See TracChangeset for help on using the changeset viewer.