Changeset 56bdd9a4 in mainline for uspace/lib/usb


Ignore:
Timestamp:
2011-11-25T15:20:04Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
02fc5c4
Parents:
317a463
Message:

usb: Provide IPC wrappers instead of IPC call numbers.

Put IPC protocol in one file.
This is does not make much difference for usb_iface, but will be useful
for more complicated interfaces.

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

Legend:

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

    r317a463 r56bdd9a4  
    3636#include <devman.h>
    3737#include <async.h>
     38#include <usb_iface.h>
    3839#include <usb/ddfiface.h>
    3940#include <usb/hc.h>
     
    104105
    105106        async_exch_t *exch = async_exchange_begin(parent_sess);
     107        if (!exch) {
     108                async_hangup(parent_sess);
     109                return ENOMEM;
     110        }
    106111
    107         sysarg_t addr;
    108         int rc = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
    109             IPC_M_USB_GET_MY_ADDRESS, &addr);
     112        const int ret = usb_get_my_address(exch, address);
    110113
    111114        async_exchange_end(exch);
    112115        async_hangup(parent_sess);
    113116
    114         if (rc != EOK)
    115                 return rc;
    116 
    117         if (address != NULL)
    118                 *address = (usb_address_t) addr;
    119 
    120         return EOK;
     117        return ret;
    121118}
    122119
  • uspace/lib/usb/src/hc.c

    r317a463 r56bdd9a4  
    181181        if (!parent_sess)
    182182                return ENOMEM;
    183        
     183
    184184        async_exch_t *exch = async_exchange_begin(parent_sess);
    185        
    186         sysarg_t address;
    187         int rc = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
    188             IPC_M_USB_GET_MY_ADDRESS, &address);
    189        
     185        if (!exch) {
     186                async_hangup(parent_sess);
     187                return ENOMEM;
     188        }
     189        usb_address_t address;
     190        const int ret = usb_get_my_address(exch, &address);
     191
    190192        async_exchange_end(exch);
    191193        async_hangup(parent_sess);
    192        
    193         if (rc != EOK)
    194                 return rc;
    195        
    196         return (usb_address_t) address;
     194
     195        if (ret != EOK)
     196                return ret;
     197
     198        return address;
    197199}
    198200
     
    231233        if (!parent_sess)
    232234                return ENOMEM;
    233        
     235
    234236        async_exch_t *exch = async_exchange_begin(parent_sess);
    235        
    236         devman_handle_t h;
    237         int rc = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
    238             IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h);
    239        
     237        if (!exch) {
     238                async_hangup(parent_sess);
     239                return ENOMEM;
     240        }
     241        const int ret = usb_get_hc_handle(exch, hc_handle);
     242
    240243        async_exchange_end(exch);
    241244        async_hangup(parent_sess);
    242        
    243         if (rc != EOK)
    244                 return rc;
    245        
    246         if (hc_handle != NULL)
    247                 *hc_handle = h;
    248        
    249         return EOK;
     245
     246        return ret;
    250247}
    251248
Note: See TracChangeset for help on using the changeset viewer.