Ignore:
File:
1 edited

Legend:

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

    r7f80313 r50b581d  
    3737#include <errno.h>
    3838#include <assert.h>
    39 #include <macros.h>
    4039
    4140#include "usbhc_iface.h"
     
    166165{
    167166        if (!exch || !address)
    168                 return EBADMEM;
     167                return EINVAL;
    169168        sysarg_t new_address;
    170169        const int ret = async_req_4_1(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
     
    174173        return ret;
    175174}
    176 
     175/*----------------------------------------------------------------------------*/
    177176int usbhc_bind_address(async_exch_t *exch, usb_address_t address,
    178177    devman_handle_t handle)
    179178{
    180179        if (!exch)
    181                 return EBADMEM;
     180                return EINVAL;
    182181        return async_req_3_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    183182            IPC_M_USBHC_BIND_ADDRESS, address, handle);
    184183}
    185 
     184/*----------------------------------------------------------------------------*/
    186185int usbhc_get_handle(async_exch_t *exch, usb_address_t address,
    187186    devman_handle_t *handle)
    188187{
    189188        if (!exch)
    190                 return EBADMEM;
     189                return EINVAL;
    191190        sysarg_t h;
    192191        const int ret = async_req_2_1(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
     
    196195        return ret;
    197196}
    198 
     197/*----------------------------------------------------------------------------*/
    199198int usbhc_release_address(async_exch_t *exch, usb_address_t address)
    200199{
    201200        if (!exch)
    202                 return EBADMEM;
     201                return EINVAL;
    203202        return async_req_2_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    204203            IPC_M_USBHC_RELEASE_ADDRESS, address);
    205204}
    206 
     205/*----------------------------------------------------------------------------*/
    207206int usbhc_register_endpoint(async_exch_t *exch, usb_address_t address,
    208207    usb_endpoint_t endpoint, usb_transfer_type_t type,
     
    210209{
    211210        if (!exch)
    212                 return EBADMEM;
     211                return EINVAL;
    213212        const usb_target_t target =
    214213            {{ .address = address, .endpoint = endpoint }};
     
    221220#undef _PACK2
    222221}
    223 
     222/*----------------------------------------------------------------------------*/
    224223int usbhc_unregister_endpoint(async_exch_t *exch, usb_address_t address,
    225224    usb_endpoint_t endpoint, usb_direction_t direction)
    226225{
    227226        if (!exch)
    228                 return EBADMEM;
     227                return EINVAL;
    229228        return async_req_4_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    230229            IPC_M_USBHC_UNREGISTER_ENDPOINT, address, endpoint, direction);
    231230}
    232 
     231/*----------------------------------------------------------------------------*/
    233232int usbhc_read(async_exch_t *exch, usb_address_t address,
    234233    usb_endpoint_t endpoint, uint64_t setup, void *data, size_t size,
    235234    size_t *rec_size)
    236235{
    237         if (!exch)
    238                 return EBADMEM;
    239 
    240236        if (size == 0 && setup == 0)
    241237                return EOK;
    242238
     239        if (!exch)
     240                return EINVAL;
    243241        const usb_target_t target =
    244242            {{ .address = address, .endpoint = endpoint }};
     
    286284        return EOK;
    287285}
    288 
     286/*----------------------------------------------------------------------------*/
    289287int usbhc_write(async_exch_t *exch, usb_address_t address,
    290288    usb_endpoint_t endpoint, uint64_t setup, const void *data, size_t size)
    291289{
    292         if (!exch)
    293                 return EBADMEM;
    294 
    295290        if (size == 0 && setup == 0)
    296291                return EOK;
    297292
     293        if (!exch)
     294                return EINVAL;
    298295        const usb_target_t target =
    299296            {{ .address = address, .endpoint = endpoint }};
     
    322319        return (int) opening_request_rc;
    323320}
    324 
     321/*----------------------------------------------------------------------------*/
    325322
    326323static void remote_usbhc_request_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     
    335332
    336333/** Remote USB host controller interface operations. */
    337 static const remote_iface_func_ptr_t remote_usbhc_iface_ops[] = {
     334static remote_iface_func_ptr_t remote_usbhc_iface_ops[] = {
    338335        [IPC_M_USBHC_REQUEST_ADDRESS] = remote_usbhc_request_address,
    339336        [IPC_M_USBHC_RELEASE_ADDRESS] = remote_usbhc_release_address,
     
    350347/** Remote USB host controller interface structure.
    351348 */
    352 const remote_iface_t remote_usbhc_iface = {
    353         .method_count = ARRAY_SIZE(remote_usbhc_iface_ops),
     349remote_iface_t remote_usbhc_iface = {
     350        .method_count = sizeof(remote_usbhc_iface_ops) /
     351            sizeof(remote_usbhc_iface_ops[0]),
    354352        .methods = remote_usbhc_iface_ops
    355353};
     
    386384        return trans;
    387385}
    388 
     386/*----------------------------------------------------------------------------*/
    389387void remote_usbhc_request_address(ddf_fun_t *fun, void *iface,
    390388    ipc_callid_t callid, ipc_call_t *call)
     
    408406        }
    409407}
    410 
     408/*----------------------------------------------------------------------------*/
    411409void remote_usbhc_bind_address(ddf_fun_t *fun, void *iface,
    412410    ipc_callid_t callid, ipc_call_t *call)
     
    425423        async_answer_0(callid, ret);
    426424}
    427 
     425/*----------------------------------------------------------------------------*/
    428426void remote_usbhc_get_handle(ddf_fun_t *fun, void *iface,
    429427    ipc_callid_t callid, ipc_call_t *call)
     
    446444        }
    447445}
    448 
     446/*----------------------------------------------------------------------------*/
    449447void remote_usbhc_release_address(ddf_fun_t *fun, void *iface,
    450448    ipc_callid_t callid, ipc_call_t *call)
     
    462460        async_answer_0(callid, ret);
    463461}
    464 
     462/*----------------------------------------------------------------------------*/
    465463static void callback_out(ddf_fun_t *fun,
    466464    int outcome, void *arg)
     
    472470        async_transaction_destroy(trans);
    473471}
    474 
     472/*----------------------------------------------------------------------------*/
    475473static void callback_in(ddf_fun_t *fun,
    476474    int outcome, size_t actual_size, void *arg)
     
    496494        async_transaction_destroy(trans);
    497495}
    498 
     496/*----------------------------------------------------------------------------*/
    499497void remote_usbhc_register_endpoint(ddf_fun_t *fun, void *iface,
    500498    ipc_callid_t callid, ipc_call_t *call)
     
    596594        }
    597595}
    598 
     596/*----------------------------------------------------------------------------*/
    599597void remote_usbhc_write(
    600598    ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
Note: See TracChangeset for help on using the changeset viewer.