Changeset ca56afa in mainline for uspace/lib/usb/src/ddfiface.c


Ignore:
Timestamp:
2011-02-25T09:46:23Z (13 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d493ac17
Parents:
15b0432 (diff), a80849c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge with /usb/development

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/src/ddfiface.c

    r15b0432 rca56afa  
    3434 */
    3535#include <ipc/devman.h>
     36#include <devman.h>
     37#include <async.h>
    3638#include <usb/ddfiface.h>
     39#include <usb/debug.h>
    3740#include <errno.h>
     41#include <assert.h>
    3842
    3943/** DDF interface for USB device, implementation for typical hub. */
     
    5660 * @return Error code.
    5761 */
    58 int usb_iface_get_hc_handle_hub_impl(device_t *device, devman_handle_t *handle)
     62int usb_iface_get_hc_handle_hub_impl(ddf_fun_t *fun, devman_handle_t *handle)
    5963{
    60         assert(device);
    61         return usb_hc_find(device->handle, handle);
     64        assert(fun);
     65        return usb_hc_find(fun->handle, handle);
    6266}
    6367
     
    6973 * @return Error code.
    7074 */
    71 int usb_iface_get_hc_handle_hub_child_impl(device_t *device,
     75int usb_iface_get_hc_handle_hub_child_impl(ddf_fun_t *fun,
    7276    devman_handle_t *handle)
    7377{
    74         assert(device);
    75         device_t *parent = device->parent;
     78        assert(fun != NULL);
    7679
    77         /* Default error, device does not support this operation. */
    78         int rc = ENOTSUP;
    79 
    80         if (parent && parent->ops && parent->ops->interfaces[USB_DEV_IFACE]) {
    81                 usb_iface_t *usb_iface
    82                     = (usb_iface_t *) parent->ops->interfaces[USB_DEV_IFACE];
    83                 assert(usb_iface != NULL);
    84 
    85                 if (usb_iface->get_hc_handle) {
    86                         rc = usb_iface->get_hc_handle(parent, handle);
    87                 }
     80        int parent_phone = devman_parent_device_connect(fun->handle,
     81            IPC_FLAG_BLOCKING);
     82        if (parent_phone < 0) {
     83                return parent_phone;
    8884        }
    8985
    90         return rc;
     86        sysarg_t hc_handle;
     87        int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
     88            IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &hc_handle);
     89
     90        if (rc != EOK) {
     91                return rc;
     92        }
     93
     94        *handle = hc_handle;
     95
     96        return EOK;
    9197}
    9298
     
    97103 * @return Always EOK.
    98104 */
    99 int usb_iface_get_hc_handle_hc_impl(device_t *device, devman_handle_t *handle)
     105int usb_iface_get_hc_handle_hc_impl(ddf_fun_t *fun, devman_handle_t *handle)
    100106{
    101         assert(device);
     107        assert(fun);
    102108
    103109        if (handle != NULL) {
    104                 *handle = device->handle;
     110                *handle = fun->handle;
    105111        }
    106112
     
    115121 * @return Error code.
    116122 */
    117 int usb_iface_get_address_hub_impl(device_t *device, devman_handle_t handle,
     123int usb_iface_get_address_hub_impl(ddf_fun_t *fun, devman_handle_t handle,
    118124    usb_address_t *address)
    119125{
    120         assert(device);
    121         int parent_phone = devman_parent_device_connect(device->handle,
     126        assert(fun);
     127        int parent_phone = devman_parent_device_connect(fun->handle,
    122128            IPC_FLAG_BLOCKING);
    123129        if (parent_phone < 0) {
     
    150156 * @return Error code.
    151157 */
    152 int usb_iface_get_address_hub_child_impl(device_t *device,
     158int usb_iface_get_address_hub_child_impl(ddf_fun_t *fun,
    153159    devman_handle_t handle, usb_address_t *address)
    154160{
    155         assert(device);
    156         device_t *parent = device->parent;
    157 
    158         /* Default error, device does not support this operation. */
    159         int rc = ENOTSUP;
    160 
    161         if (parent && parent->ops && parent->ops->interfaces[USB_DEV_IFACE]) {
    162                 usb_iface_t *usb_iface
    163                     = (usb_iface_t *) parent->ops->interfaces[USB_DEV_IFACE];
    164                 assert(usb_iface != NULL);
    165 
    166                 if (usb_iface->get_address) {
    167                         rc = usb_iface->get_address(parent, handle, address);
    168                 }
     161        if (handle == 0) {
     162                handle = fun->handle;
    169163        }
    170 
    171         return rc;
     164        return usb_iface_get_address_hub_impl(fun, handle, address);
    172165}
    173166
Note: See TracChangeset for help on using the changeset viewer.