Changeset 02fc5c4 in mainline for uspace/lib/usbdev/src/hub.c


Ignore:
Timestamp:
2011-11-25T17:41: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:
095bddfc
Parents:
56bdd9a4
Message:

usbhc: Export IPC wrapper instead of IPC call numbers.

Hide IPC protocol in one file, instead of multiple client implementations.
Rename 'find_by_address' ⇒ 'get_handle'

File:
1 edited

Legend:

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

    r56bdd9a4 r02fc5c4  
    7676{
    7777        CHECK_CONNECTION(connection);
    78        
     78
    7979        async_exch_t *exch = async_exchange_begin(connection->hc_sess);
    80        
    81         sysarg_t address;
    82         int rc = async_req_4_1(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    83             IPC_M_USBHC_REQUEST_ADDRESS, preferred, strict, speed, &address);
    84        
     80        if (!exch)
     81                return (usb_address_t)ENOMEM;
     82
     83        usb_address_t address = preferred;
     84        const int ret = usbhc_request_address(exch, &address, strict, speed);
     85
    8586        async_exchange_end(exch);
    86        
    87         if (rc != EOK)
    88                 return (usb_address_t) rc;
    89        
    90         return (usb_address_t) address;
     87        return ret == EOK ? address : ret;
    9188}
    9289
     
    9794 * @return Error code.
    9895 */
    99 int usb_hc_register_device(usb_hc_connection_t * connection,
     96int usb_hc_register_device(usb_hc_connection_t *connection,
    10097    const usb_hub_attached_device_t *attached_device)
    10198{
    10299        CHECK_CONNECTION(connection);
    103        
    104         if (attached_device == NULL)
    105                 return EBADMEM;
    106        
     100        if (attached_device == NULL || attached_device->fun == NULL)
     101                return EINVAL;
     102
    107103        async_exch_t *exch = async_exchange_begin(connection->hc_sess);
    108         int rc = async_req_3_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    109             IPC_M_USBHC_BIND_ADDRESS,
     104        if (!exch)
     105                return ENOMEM;
     106        const int ret = usbhc_bind_address(exch,
    110107            attached_device->address, attached_device->fun->handle);
    111108        async_exchange_end(exch);
    112        
    113         return rc;
     109
     110        return ret;
    114111}
    115112
     
    124121{
    125122        CHECK_CONNECTION(connection);
    126        
     123
    127124        async_exch_t *exch = async_exchange_begin(connection->hc_sess);
    128         int rc = async_req_2_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    129             IPC_M_USBHC_RELEASE_ADDRESS, address);
     125        if (!exch)
     126                return ENOMEM;
     127        const int ret = usbhc_release_address(exch, address);
    130128        async_exchange_end(exch);
    131        
    132         return rc;
     129
     130        return ret;
    133131}
    134132
Note: See TracChangeset for help on using the changeset viewer.