Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/remote_usbhc.c

    r50b581d r7f80313  
    3737#include <errno.h>
    3838#include <assert.h>
     39#include <macros.h>
    3940
    4041#include "usbhc_iface.h"
     
    165166{
    166167        if (!exch || !address)
    167                 return EINVAL;
     168                return EBADMEM;
    168169        sysarg_t new_address;
    169170        const int ret = async_req_4_1(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
     
    173174        return ret;
    174175}
    175 /*----------------------------------------------------------------------------*/
     176
    176177int usbhc_bind_address(async_exch_t *exch, usb_address_t address,
    177178    devman_handle_t handle)
    178179{
    179180        if (!exch)
    180                 return EINVAL;
     181                return EBADMEM;
    181182        return async_req_3_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    182183            IPC_M_USBHC_BIND_ADDRESS, address, handle);
    183184}
    184 /*----------------------------------------------------------------------------*/
     185
    185186int usbhc_get_handle(async_exch_t *exch, usb_address_t address,
    186187    devman_handle_t *handle)
    187188{
    188189        if (!exch)
    189                 return EINVAL;
     190                return EBADMEM;
    190191        sysarg_t h;
    191192        const int ret = async_req_2_1(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
     
    195196        return ret;
    196197}
    197 /*----------------------------------------------------------------------------*/
     198
    198199int usbhc_release_address(async_exch_t *exch, usb_address_t address)
    199200{
    200201        if (!exch)
    201                 return EINVAL;
     202                return EBADMEM;
    202203        return async_req_2_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    203204            IPC_M_USBHC_RELEASE_ADDRESS, address);
    204205}
    205 /*----------------------------------------------------------------------------*/
     206
    206207int usbhc_register_endpoint(async_exch_t *exch, usb_address_t address,
    207208    usb_endpoint_t endpoint, usb_transfer_type_t type,
     
    209210{
    210211        if (!exch)
    211                 return EINVAL;
     212                return EBADMEM;
    212213        const usb_target_t target =
    213214            {{ .address = address, .endpoint = endpoint }};
     
    220221#undef _PACK2
    221222}
    222 /*----------------------------------------------------------------------------*/
     223
    223224int usbhc_unregister_endpoint(async_exch_t *exch, usb_address_t address,
    224225    usb_endpoint_t endpoint, usb_direction_t direction)
    225226{
    226227        if (!exch)
    227                 return EINVAL;
     228                return EBADMEM;
    228229        return async_req_4_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    229230            IPC_M_USBHC_UNREGISTER_ENDPOINT, address, endpoint, direction);
    230231}
    231 /*----------------------------------------------------------------------------*/
     232
    232233int usbhc_read(async_exch_t *exch, usb_address_t address,
    233234    usb_endpoint_t endpoint, uint64_t setup, void *data, size_t size,
    234235    size_t *rec_size)
    235236{
     237        if (!exch)
     238                return EBADMEM;
     239
    236240        if (size == 0 && setup == 0)
    237241                return EOK;
    238242
    239         if (!exch)
    240                 return EINVAL;
    241243        const usb_target_t target =
    242244            {{ .address = address, .endpoint = endpoint }};
     
    284286        return EOK;
    285287}
    286 /*----------------------------------------------------------------------------*/
     288
    287289int usbhc_write(async_exch_t *exch, usb_address_t address,
    288290    usb_endpoint_t endpoint, uint64_t setup, const void *data, size_t size)
    289291{
     292        if (!exch)
     293                return EBADMEM;
     294
    290295        if (size == 0 && setup == 0)
    291296                return EOK;
    292297
    293         if (!exch)
    294                 return EINVAL;
    295298        const usb_target_t target =
    296299            {{ .address = address, .endpoint = endpoint }};
     
    319322        return (int) opening_request_rc;
    320323}
    321 /*----------------------------------------------------------------------------*/
     324
    322325
    323326static void remote_usbhc_request_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     
    332335
    333336/** Remote USB host controller interface operations. */
    334 static remote_iface_func_ptr_t remote_usbhc_iface_ops[] = {
     337static const remote_iface_func_ptr_t remote_usbhc_iface_ops[] = {
    335338        [IPC_M_USBHC_REQUEST_ADDRESS] = remote_usbhc_request_address,
    336339        [IPC_M_USBHC_RELEASE_ADDRESS] = remote_usbhc_release_address,
     
    347350/** Remote USB host controller interface structure.
    348351 */
    349 remote_iface_t remote_usbhc_iface = {
    350         .method_count = sizeof(remote_usbhc_iface_ops) /
    351             sizeof(remote_usbhc_iface_ops[0]),
     352const remote_iface_t remote_usbhc_iface = {
     353        .method_count = ARRAY_SIZE(remote_usbhc_iface_ops),
    352354        .methods = remote_usbhc_iface_ops
    353355};
     
    384386        return trans;
    385387}
    386 /*----------------------------------------------------------------------------*/
     388
    387389void remote_usbhc_request_address(ddf_fun_t *fun, void *iface,
    388390    ipc_callid_t callid, ipc_call_t *call)
     
    406408        }
    407409}
    408 /*----------------------------------------------------------------------------*/
     410
    409411void remote_usbhc_bind_address(ddf_fun_t *fun, void *iface,
    410412    ipc_callid_t callid, ipc_call_t *call)
     
    423425        async_answer_0(callid, ret);
    424426}
    425 /*----------------------------------------------------------------------------*/
     427
    426428void remote_usbhc_get_handle(ddf_fun_t *fun, void *iface,
    427429    ipc_callid_t callid, ipc_call_t *call)
     
    444446        }
    445447}
    446 /*----------------------------------------------------------------------------*/
     448
    447449void remote_usbhc_release_address(ddf_fun_t *fun, void *iface,
    448450    ipc_callid_t callid, ipc_call_t *call)
     
    460462        async_answer_0(callid, ret);
    461463}
    462 /*----------------------------------------------------------------------------*/
     464
    463465static void callback_out(ddf_fun_t *fun,
    464466    int outcome, void *arg)
     
    470472        async_transaction_destroy(trans);
    471473}
    472 /*----------------------------------------------------------------------------*/
     474
    473475static void callback_in(ddf_fun_t *fun,
    474476    int outcome, size_t actual_size, void *arg)
     
    494496        async_transaction_destroy(trans);
    495497}
    496 /*----------------------------------------------------------------------------*/
     498
    497499void remote_usbhc_register_endpoint(ddf_fun_t *fun, void *iface,
    498500    ipc_callid_t callid, ipc_call_t *call)
     
    594596        }
    595597}
    596 /*----------------------------------------------------------------------------*/
     598
    597599void remote_usbhc_write(
    598600    ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
Note: See TracChangeset for help on using the changeset viewer.