Ignore:
File:
1 edited

Legend:

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

    r99172baf 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};
     
    363361static void async_transaction_destroy(async_transaction_t *trans)
    364362{
    365         if (trans == NULL)
    366                 return;
    367        
    368         if (trans->buffer != NULL)
     363        if (trans == NULL) {
     364                return;
     365        }
     366        if (trans->buffer != NULL) {
    369367                free(trans->buffer);
    370        
     368        }
     369
    371370        free(trans);
    372371}
     
    385384        return trans;
    386385}
    387 
     386/*----------------------------------------------------------------------------*/
    388387void remote_usbhc_request_address(ddf_fun_t *fun, void *iface,
    389388    ipc_callid_t callid, ipc_call_t *call)
     
    407406        }
    408407}
    409 
     408/*----------------------------------------------------------------------------*/
    410409void remote_usbhc_bind_address(ddf_fun_t *fun, void *iface,
    411410    ipc_callid_t callid, ipc_call_t *call)
     
    424423        async_answer_0(callid, ret);
    425424}
    426 
     425/*----------------------------------------------------------------------------*/
    427426void remote_usbhc_get_handle(ddf_fun_t *fun, void *iface,
    428427    ipc_callid_t callid, ipc_call_t *call)
     
    445444        }
    446445}
    447 
     446/*----------------------------------------------------------------------------*/
    448447void remote_usbhc_release_address(ddf_fun_t *fun, void *iface,
    449448    ipc_callid_t callid, ipc_call_t *call)
     
    461460        async_answer_0(callid, ret);
    462461}
    463 
     462/*----------------------------------------------------------------------------*/
    464463static void callback_out(ddf_fun_t *fun,
    465464    int outcome, void *arg)
     
    471470        async_transaction_destroy(trans);
    472471}
    473 
     472/*----------------------------------------------------------------------------*/
    474473static void callback_in(ddf_fun_t *fun,
    475474    int outcome, size_t actual_size, void *arg)
     
    495494        async_transaction_destroy(trans);
    496495}
    497 
     496/*----------------------------------------------------------------------------*/
    498497void remote_usbhc_register_endpoint(ddf_fun_t *fun, void *iface,
    499498    ipc_callid_t callid, ipc_call_t *call)
     
    584583                async_answer_0(callid, ENOMEM);
    585584                async_transaction_destroy(trans);
    586                 return;
    587585        }
    588586
     
    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.