Changeset 8565a42 in mainline for uspace/lib/drv/generic


Ignore:
Timestamp:
2018-03-02T20:34:50Z (8 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1a81f69, d5e5fd1
Parents:
3061bc1 (diff), 34e1206 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
git-committer:
GitHub <noreply@…> (2018-03-02 20:34:50)
Message:

Remove all trailing whitespace, everywhere.

See individual commit messages for details.

Location:
uspace/lib/drv/generic
Files:
13 edited

Legend:

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

    r3061bc1 r8565a42  
    9797{
    9898        assert(fibril_mutex_is_locked(&devices_mutex));
    99        
     99
    100100        list_foreach(devices, link, ddf_dev_t, dev) {
    101101                if (dev->handle == handle)
    102102                        return dev;
    103103        }
    104        
     104
    105105        return NULL;
    106106}
     
    109109{
    110110        assert(fibril_mutex_is_locked(&functions_mutex));
    111        
     111
    112112        list_foreach(functions, link, ddf_fun_t, fun) {
    113113                if (fun->handle == handle)
    114114                        return fun;
    115115        }
    116        
     116
    117117        return NULL;
    118118}
     
    122122        devman_handle_t dev_handle = IPC_GET_ARG1(*icall);
    123123        devman_handle_t parent_fun_handle = IPC_GET_ARG2(*icall);
    124        
     124
    125125        char *dev_name = NULL;
    126126        errno_t rc = async_data_write_accept((void **) &dev_name, true, 0, 0, 0, 0);
     
    129129                return;
    130130        }
    131        
     131
    132132        fibril_rwlock_read_lock(&stopping_lock);
    133133
     
    137137                return;
    138138        }
    139        
     139
    140140        ddf_dev_t *dev = create_device();
    141141        if (!dev) {
     
    145145                return;
    146146        }
    147        
     147
    148148        /* Add one reference that will be dropped by driver_dev_remove() */
    149149        dev_add_ref(dev);
    150150        dev->handle = dev_handle;
    151151        dev->name = dev_name;
    152        
     152
    153153        /*
    154154         * Currently not used, parent fun handle is stored in context
     
    156156         */
    157157        (void) parent_fun_handle;
    158        
     158
    159159        errno_t res = driver->driver_ops->dev_add(dev);
    160        
     160
    161161        if (res != EOK) {
    162162                fibril_rwlock_read_unlock(&stopping_lock);
     
    165165                return;
    166166        }
    167        
     167
    168168        fibril_mutex_lock(&devices_mutex);
    169169        list_append(&dev->link, &devices);
    170170        fibril_mutex_unlock(&devices_mutex);
    171171        fibril_rwlock_read_unlock(&stopping_lock);
    172        
     172
    173173        async_answer_0(iid, res);
    174174}
     
    177177{
    178178        devman_handle_t devh = IPC_GET_ARG1(*icall);
    179        
     179
    180180        fibril_mutex_lock(&devices_mutex);
    181181        ddf_dev_t *dev = driver_get_device(devh);
     
    183183                dev_add_ref(dev);
    184184        fibril_mutex_unlock(&devices_mutex);
    185        
     185
    186186        if (dev == NULL) {
    187187                async_answer_0(iid, ENOENT);
    188188                return;
    189189        }
    190        
     190
    191191        errno_t rc;
    192        
     192
    193193        if (driver->driver_ops->dev_remove != NULL)
    194194                rc = driver->driver_ops->dev_remove(dev);
    195195        else
    196196                rc = ENOTSUP;
    197        
     197
    198198        if (rc == EOK) {
    199199                fibril_mutex_lock(&devices_mutex);
     
    202202                dev_del_ref(dev);
    203203        }
    204        
     204
    205205        dev_del_ref(dev);
    206206        async_answer_0(iid, rc);
     
    210210{
    211211        devman_handle_t devh = IPC_GET_ARG1(*icall);
    212        
     212
    213213        fibril_mutex_lock(&devices_mutex);
    214214        ddf_dev_t *dev = driver_get_device(devh);
     
    216216                dev_add_ref(dev);
    217217        fibril_mutex_unlock(&devices_mutex);
    218        
     218
    219219        if (dev == NULL) {
    220220                async_answer_0(iid, ENOENT);
    221221                return;
    222222        }
    223        
     223
    224224        errno_t rc;
    225        
     225
    226226        if (driver->driver_ops->dev_gone != NULL)
    227227                rc = driver->driver_ops->dev_gone(dev);
    228228        else
    229229                rc = ENOTSUP;
    230        
     230
    231231        if (rc == EOK) {
    232232                fibril_mutex_lock(&devices_mutex);
     
    235235                dev_del_ref(dev);
    236236        }
    237        
     237
    238238        dev_del_ref(dev);
    239239        async_answer_0(iid, rc);
     
    243243{
    244244        devman_handle_t funh = IPC_GET_ARG1(*icall);
    245        
     245
    246246        /*
    247247         * Look the function up. Bump reference count so that
     
    250250         */
    251251        fibril_mutex_lock(&functions_mutex);
    252        
     252
    253253        ddf_fun_t *fun = driver_get_function(funh);
    254254        if (fun != NULL)
    255255                fun_add_ref(fun);
    256        
     256
    257257        fibril_mutex_unlock(&functions_mutex);
    258        
     258
    259259        if (fun == NULL) {
    260260                async_answer_0(iid, ENOENT);
    261261                return;
    262262        }
    263        
     263
    264264        /* Call driver entry point */
    265265        errno_t rc;
    266        
     266
    267267        if (driver->driver_ops->fun_online != NULL)
    268268                rc = driver->driver_ops->fun_online(fun);
    269269        else
    270270                rc = ENOTSUP;
    271        
     271
    272272        fun_del_ref(fun);
    273        
     273
    274274        async_answer_0(iid, rc);
    275275}
     
    278278{
    279279        devman_handle_t funh = IPC_GET_ARG1(*icall);
    280        
     280
    281281        /*
    282282         * Look the function up. Bump reference count so that
     
    285285         */
    286286        fibril_mutex_lock(&functions_mutex);
    287        
     287
    288288        ddf_fun_t *fun = driver_get_function(funh);
    289289        if (fun != NULL)
    290290                fun_add_ref(fun);
    291        
     291
    292292        fibril_mutex_unlock(&functions_mutex);
    293        
     293
    294294        if (fun == NULL) {
    295295                async_answer_0(iid, ENOENT);
    296296                return;
    297297        }
    298        
     298
    299299        /* Call driver entry point */
    300300        errno_t rc;
    301        
     301
    302302        if (driver->driver_ops->fun_offline != NULL)
    303303                rc = driver->driver_ops->fun_offline(fun);
    304304        else
    305305                rc = ENOTSUP;
    306        
     306
    307307        async_answer_0(iid, rc);
    308308}
     
    342342        /* Accept connection */
    343343        async_answer_0(iid, EOK);
    344        
     344
    345345        while (true) {
    346346                ipc_call_t call;
    347347                ipc_callid_t callid = async_get_call(&call);
    348                
     348
    349349                if (!IPC_GET_IMETHOD(call))
    350350                        break;
    351                
     351
    352352                switch (IPC_GET_IMETHOD(call)) {
    353353                case DRIVER_DEV_ADD:
     
    394394                fun_add_ref(fun);
    395395        fibril_mutex_unlock(&functions_mutex);
    396        
     396
    397397        if (fun == NULL) {
    398398                printf("%s: driver_connection_gen error - no function with handle"
     
    401401                return;
    402402        }
    403        
     403
    404404        if (fun->conn_handler != NULL) {
    405405                /* Driver has a custom connection handler. */
     
    408408                return;
    409409        }
    410        
     410
    411411        /*
    412412         * TODO - if the client is not a driver, check whether it is allowed to
    413413         * use the device.
    414414         */
    415        
     415
    416416        errno_t ret = EOK;
    417417        /* Open device function */
    418418        if (fun->ops != NULL && fun->ops->open != NULL)
    419419                ret = (*fun->ops->open)(fun);
    420        
     420
    421421        async_answer_0(iid, ret);
    422422        if (ret != EOK) {
     
    424424                return;
    425425        }
    426        
     426
    427427        while (true) {
    428428                ipc_callid_t callid;
     
    430430                callid = async_get_call(&call);
    431431                sysarg_t method = IPC_GET_IMETHOD(call);
    432                
     432
    433433                if (!method) {
    434434                        /* Close device function */
     
    439439                        return;
    440440                }
    441                
     441
    442442                /* Convert ipc interface id to interface index */
    443                
     443
    444444                int iface_idx = DEV_IFACE_IDX(method);
    445                
     445
    446446                if (!is_valid_iface_idx(iface_idx)) {
    447447                        remote_handler_t *default_handler =
     
    451451                                continue;
    452452                        }
    453                        
     453
    454454                        /*
    455455                         * Function has no such interface and
     
    462462                        continue;
    463463                }
    464                
     464
    465465                /* Calling one of the function's interfaces */
    466                
     466
    467467                /* Get the interface ops structure. */
    468468                void *ops = function_get_ops(fun, iface_idx);
     
    474474                        continue;
    475475                }
    476                
     476
    477477                /*
    478478                 * Get the corresponding interface for remote request
     
    481481                const remote_iface_t *rem_iface = get_remote_iface(iface_idx);
    482482                assert(rem_iface != NULL);
    483                
     483
    484484                /* get the method of the remote interface */
    485485                sysarg_t iface_method_idx = IPC_GET_ARG1(call);
     
    493493                        continue;
    494494                }
    495                
     495
    496496                /*
    497497                 * Call the remote interface's method, which will
     
    624624{
    625625        assert(dev->driver_data == NULL);
    626        
     626
    627627        void *data = calloc(1, size);
    628628        if (data == NULL)
    629629                return NULL;
    630        
     630
    631631        dev->driver_data = data;
    632632        return data;
     
    732732        if (fun == NULL)
    733733                return NULL;
    734        
     734
    735735        /* Add one reference that will be dropped by ddf_fun_destroy() */
    736736        fun->dev = dev;
    737737        fun_add_ref(fun);
    738        
     738
    739739        fun->bound = false;
    740740        fun->ftype = ftype;
    741        
     741
    742742        if (name != NULL) {
    743743                fun->name = str_dup(name);
     
    747747                }
    748748        }
    749        
     749
    750750        return fun;
    751751}
     
    756756        assert(fun->bound == false);
    757757        assert(fun->driver_data == NULL);
    758        
     758
    759759        void *data = calloc(1, size);
    760760        if (data == NULL)
    761761                return NULL;
    762        
     762
    763763        fun->driver_data = data;
    764764        return data;
     
    792792{
    793793        assert(fun->bound == false);
    794        
     794
    795795        /*
    796796         * Drop the reference added by ddf_fun_create(). This will deallocate
     
    807807        if (fun->ops == NULL)
    808808                return NULL;
    809        
     809
    810810        return fun->ops->interfaces[idx];
    811811}
     
    830830        assert(fun->name != NULL);
    831831        assert(fun->dev != NULL);
    832        
     832
    833833        add_to_functions_list(fun);
    834834        errno_t res = devman_add_function(fun->name, fun->ftype, &fun->match_ids,
     
    838838                return res;
    839839        }
    840        
     840
    841841        fun->bound = true;
    842842        return res;
     
    856856{
    857857        assert(fun->bound == true);
    858        
     858
    859859        errno_t res = devman_remove_function(fun->handle);
    860860        if (res != EOK)
    861861                return res;
    862        
     862
    863863        remove_from_functions_list(fun);
    864        
     864
    865865        fun->bound = false;
    866866        return EOK;
     
    877877{
    878878        assert(fun->bound == true);
    879        
     879
    880880        errno_t res = devman_drv_fun_online(fun->handle);
    881881        if (res != EOK)
    882882                return res;
    883        
     883
    884884        return EOK;
    885885}
     
    895895{
    896896        assert(fun->bound == true);
    897        
     897
    898898        errno_t res = devman_drv_fun_offline(fun->handle);
    899899        if (res != EOK)
    900900                return res;
    901        
     901
    902902        return EOK;
    903903}
     
    921921        assert(fun->bound == false);
    922922        assert(fun->ftype == fun_inner);
    923        
     923
    924924        match_id_t *match_id = create_match_id();
    925925        if (match_id == NULL)
    926926                return ENOMEM;
    927        
     927
    928928        match_id->id = str_dup(match_id_str);
    929929        match_id->score = match_score;
    930        
     930
    931931        add_match_id(&fun->match_ids, match_id);
    932932        return EOK;
     
    967967        assert(fun->bound == true);
    968968        assert(fun->ftype == fun_exposed);
    969        
     969
    970970        return devman_add_device_to_category(fun->handle, cat_name);
    971971}
     
    978978         */
    979979        driver = drv;
    980        
     980
    981981        /*
    982982         * Register driver with device manager using generic handler for
     
    990990                return rc;
    991991        }
    992        
     992
    993993        rc = async_create_port(INTERFACE_DDF_DEVMAN, driver_connection_devman,
    994994            NULL, &port);
     
    997997                return rc;
    998998        }
    999        
     999
    10001000        async_set_fallback_port_handler(driver_connection_client, NULL);
    1001        
     1001
    10021002        rc = devman_driver_register(driver->name);
    10031003        if (rc != EOK) {
     
    10051005                    "(%s).\n", (rc == EEXIST) ? "driver already started" :
    10061006                    str_error(rc));
    1007                
     1007
    10081008                return rc;
    10091009        }
    1010        
     1010
    10111011        /* Return success from the task since server has started. */
    10121012        rc = task_retval(0);
     
    10151015                return rc;
    10161016        }
    1017        
     1017
    10181018        async_manager();
    1019        
     1019
    10201020        /* Never reached. */
    10211021        return EOK;
  • uspace/lib/drv/generic/log.c

    r3061bc1 r8565a42  
    5656{
    5757        va_list args;
    58        
     58
    5959        va_start(args, fmt);
    6060        log_msgv(LOG_DEFAULT, level, fmt, args);
  • uspace/lib/drv/generic/private/driver.h

    r3061bc1 r8565a42  
    4949         */
    5050        devman_handle_t handle;
    51        
     51
    5252        /** Reference count */
    5353        atomic_t refcnt;
    54        
     54
    5555        /** Session with the parent device driver */
    5656        async_sess_t *parent_sess;
    57        
     57
    5858        /** Device name */
    5959        char *name;
    60        
     60
    6161        /** Driver-specific data associated with this device */
    6262        void *driver_data;
    63        
     63
    6464        /** Link in the list of devices handled by the driver */
    6565        link_t link;
     
    7070        /** True if bound to the device manager */
    7171        bool bound;
    72        
     72
    7373        /** Function indentifier (asigned by device manager) */
    7474        devman_handle_t handle;
    75        
     75
    7676        /** Reference count */
    7777        atomic_t refcnt;
    78        
     78
    7979        /** Device which this function belogs to */
    8080        struct ddf_dev *dev;
    81        
     81
    8282        /** Function type */
    8383        fun_type_t ftype;
    84        
     84
    8585        /** Function name */
    8686        char *name;
    87        
     87
    8888        /** List of device ids for driver matching */
    8989        match_id_list_t match_ids;
    90        
     90
    9191        /** Driver-specific data associated with this function */
    9292        void *driver_data;
    93        
     93
    9494        /** Implementation of operations provided by this function */
    9595        const ddf_dev_ops_t *ops;
    96        
     96
    9797        /** Connection handler or @c NULL to use the DDF default handler. */
    9898        async_port_handler_t conn_handler;
    99        
     99
    100100        /** Link in the list of functions handled by the driver */
    101101        link_t link;
  • uspace/lib/drv/generic/remote_ahci.c

    r3061bc1 r8565a42  
    6262{
    6363        // FIXME: Use a better way than substring match
    64        
     64
    6565        *name = NULL;
    66        
     66
    6767        char devn[MAX_NAME_LENGTH];
    6868        errno_t rc = devman_fun_get_name(funh, devn, MAX_NAME_LENGTH);
    6969        if (rc != EOK)
    7070                return NULL;
    71        
     71
    7272        size_t devn_size = str_size(devn);
    73        
     73
    7474        if ((devn_size > 5) && (str_lcmp(devn, "ahci_", 5) == 0)) {
    7575                async_sess_t *sess = devman_device_connect(funh, IPC_FLAG_BLOCKING);
    76                
     76
    7777                if (sess) {
    7878                        *name = str_dup(devn);
     
    8080                }
    8181        }
    82        
     82
    8383        return NULL;
    8484}
     
    9090        if (!exch)
    9191                return EINVAL;
    92        
     92
    9393        aid_t req = async_send_2(exch, DEV_IFACE_ID(AHCI_DEV_IFACE),
    9494            IPC_M_AHCI_GET_SATA_DEVICE_NAME, sata_dev_name_length, NULL);
    95        
     95
    9696        async_data_read_start(exch, sata_dev_name, sata_dev_name_length);
    97        
     97
    9898        errno_t rc;
    9999        async_wait_for(req, &rc);
    100        
     100
    101101        return rc;
    102102}
     
    107107        if (!exch)
    108108                return EINVAL;
    109        
     109
    110110        sysarg_t blocks_hi;
    111111        sysarg_t blocks_lo;
    112112        errno_t rc = async_req_1_2(exch, DEV_IFACE_ID(AHCI_DEV_IFACE),
    113113            IPC_M_AHCI_GET_NUM_BLOCKS, &blocks_hi, &blocks_lo);
    114        
     114
    115115        async_exchange_end(exch);
    116        
     116
    117117        if (rc == EOK) {
    118118                *blocks = (((uint64_t) blocks_hi) << 32)
    119119                    | (((uint64_t) blocks_lo) & 0xffffffff);
    120120        }
    121        
     121
    122122        return rc;
    123123}
     
    128128        if (!exch)
    129129                return EINVAL;
    130        
     130
    131131        sysarg_t bs;
    132132        errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(AHCI_DEV_IFACE),
    133133            IPC_M_AHCI_GET_BLOCK_SIZE, &bs);
    134        
     134
    135135        async_exchange_end(exch);
    136        
     136
    137137        if (rc == EOK)
    138138                *blocks_size = (size_t) bs;
    139        
     139
    140140        return rc;
    141141}
     
    147147        if (!exch)
    148148                return EINVAL;
    149        
     149
    150150        aid_t req;
    151151        req = async_send_4(exch, DEV_IFACE_ID(AHCI_DEV_IFACE),
    152152            IPC_M_AHCI_READ_BLOCKS, HI(blocknum),  LO(blocknum), count, NULL);
    153        
     153
    154154        async_share_out_start(exch, buf, AS_AREA_READ | AS_AREA_WRITE);
    155        
     155
    156156        async_exchange_end(exch);
    157        
     157
    158158        errno_t rc;
    159159        async_wait_for(req, &rc);
    160        
     160
    161161        return rc;
    162162}
     
    168168        if (!exch)
    169169                return EINVAL;
    170        
     170
    171171        aid_t req = async_send_4(exch, DEV_IFACE_ID(AHCI_DEV_IFACE),
    172172            IPC_M_AHCI_WRITE_BLOCKS, HI(blocknum),  LO(blocknum), count, NULL);
    173        
     173
    174174        async_share_out_start(exch, buf, AS_AREA_READ | AS_AREA_WRITE);
    175        
     175
    176176        async_exchange_end(exch);
    177        
     177
    178178        errno_t rc;
    179179        async_wait_for(req, &rc);
    180        
     180
    181181        return rc;
    182182}
     
    213213{
    214214        const ahci_iface_t *ahci_iface = (ahci_iface_t *) iface;
    215        
     215
    216216        if (ahci_iface->get_sata_device_name == NULL) {
    217217                async_answer_0(callid, ENOTSUP);
    218218                return;
    219219        }
    220        
     220
    221221        const size_t sata_dev_name_length =
    222222            (size_t) DEV_IPC_GET_ARG1(*call);
    223        
     223
    224224        char* sata_dev_name = malloc(sata_dev_name_length);
    225225        if (sata_dev_name == NULL) {
     
    227227                return;
    228228        }
    229        
     229
    230230        const errno_t ret = ahci_iface->get_sata_device_name(fun,
    231231            sata_dev_name_length, sata_dev_name);
    232        
     232
    233233        size_t real_size;
    234234        ipc_callid_t cid;
     
    236236            (real_size == sata_dev_name_length))
    237237                async_data_read_finalize(cid, sata_dev_name, sata_dev_name_length);
    238        
     238
    239239        free(sata_dev_name);
    240240        async_answer_0(callid, ret);
     
    245245{
    246246        const ahci_iface_t *ahci_iface = (ahci_iface_t *) iface;
    247        
     247
    248248        if (ahci_iface->get_num_blocks == NULL) {
    249249                async_answer_0(callid, ENOTSUP);
    250250                return;
    251251        }
    252        
     252
    253253        uint64_t blocks;
    254254        const errno_t ret = ahci_iface->get_num_blocks(fun, &blocks);
    255        
     255
    256256        if (ret != EOK)
    257257                async_answer_0(callid, ret);
     
    264264{
    265265        const ahci_iface_t *ahci_iface = (ahci_iface_t *) iface;
    266        
     266
    267267        if (ahci_iface->get_block_size == NULL) {
    268268                async_answer_0(callid, ENOTSUP);
    269269                return;
    270270        }
    271        
     271
    272272        size_t blocks;
    273273        const errno_t ret = ahci_iface->get_block_size(fun, &blocks);
    274        
     274
    275275        if (ret != EOK)
    276276                async_answer_0(callid, ret);
     
    283283{
    284284        const ahci_iface_t *ahci_iface = (ahci_iface_t *) iface;
    285        
     285
    286286        if (ahci_iface->read_blocks == NULL) {
    287287                async_answer_0(callid, ENOTSUP);
    288288                return;
    289289        }
    290        
     290
    291291        size_t maxblock_size;
    292292        unsigned int flags;
    293        
     293
    294294        ipc_callid_t cid;
    295295        async_share_out_receive(&cid, &maxblock_size, &flags);
    296        
     296
    297297        void *buf;
    298298        async_share_out_finalize(cid, &buf);
    299        
     299
    300300        const uint64_t blocknum =
    301301            (((uint64_t) (DEV_IPC_GET_ARG1(*call))) << 32) |
    302302            (((uint64_t) (DEV_IPC_GET_ARG2(*call))) & 0xffffffff);
    303303        const size_t cnt = (size_t) DEV_IPC_GET_ARG3(*call);
    304        
     304
    305305        const errno_t ret = ahci_iface->read_blocks(fun, blocknum, cnt, buf);
    306        
     306
    307307        async_answer_0(callid, ret);
    308308}
     
    312312{
    313313        const ahci_iface_t *ahci_iface = (ahci_iface_t *) iface;
    314        
     314
    315315        if (ahci_iface->read_blocks == NULL) {
    316316                async_answer_0(callid, ENOTSUP);
    317317                return;
    318318        }
    319        
     319
    320320        size_t maxblock_size;
    321321        unsigned int flags;
    322        
     322
    323323        ipc_callid_t cid;
    324324        async_share_out_receive(&cid, &maxblock_size, &flags);
    325        
     325
    326326        void *buf;
    327327        async_share_out_finalize(cid, &buf);
    328        
     328
    329329        const uint64_t blocknum =
    330330            (((uint64_t)(DEV_IPC_GET_ARG1(*call))) << 32) |
    331331            (((uint64_t)(DEV_IPC_GET_ARG2(*call))) & 0xffffffff);
    332332        const size_t cnt = (size_t) DEV_IPC_GET_ARG3(*call);
    333        
     333
    334334        const errno_t ret = ahci_iface->write_blocks(fun, blocknum, cnt, buf);
    335        
     335
    336336        async_answer_0(callid, ret);
    337337}
  • uspace/lib/drv/generic/remote_audio_pcm.c

    r3061bc1 r8565a42  
    318318
    319319        async_exch_t *exch = async_exchange_begin(sess);
    320        
     320
    321321        errno_t ret = async_req_1_0(exch, DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
    322322            IPC_M_AUDIO_PCM_REGISTER_EVENTS);
     
    326326                    event_callback, arg, &port);
    327327        }
    328        
     328
    329329        async_exchange_end(exch);
    330330        return ret;
  • uspace/lib/drv/generic/remote_hw_res.c

    r3061bc1 r8565a42  
    7272{
    7373        hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops;
    74        
     74
    7575        if (hw_res_ops->enable_interrupt == NULL) {
    7676                async_answer_0(callid, ENOTSUP);
    7777                return;
    7878        }
    79        
     79
    8080        const int irq = DEV_IPC_GET_ARG1(*call);
    8181        const errno_t ret = hw_res_ops->enable_interrupt(fun, irq);
     
    8787{
    8888        hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops;
    89        
     89
    9090        if (hw_res_ops->disable_interrupt == NULL) {
    9191                async_answer_0(callid, ENOTSUP);
    9292                return;
    9393        }
    94        
     94
    9595        const int irq = DEV_IPC_GET_ARG1(*call);
    9696        const errno_t ret = hw_res_ops->disable_interrupt(fun, irq);
     
    102102{
    103103        hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops;
    104        
     104
    105105        if (hw_res_ops->clear_interrupt == NULL) {
    106106                async_answer_0(callid, ENOTSUP);
    107107                return;
    108108        }
    109        
     109
    110110        const int irq = DEV_IPC_GET_ARG1(*call);
    111111        const errno_t ret = hw_res_ops->enable_interrupt(fun, irq);
     
    122122                return;
    123123        }
    124        
     124
    125125        hw_resource_list_t *hw_resources = hw_res_ops->get_resource_list(fun);
    126126        if (hw_resources == NULL){
     
    128128                return;
    129129        }
    130        
     130
    131131        async_answer_1(callid, EOK, hw_resources->count);
    132132
  • uspace/lib/drv/generic/remote_ieee80211.c

    r3061bc1 r8565a42  
    6666{
    6767        assert(results);
    68        
     68
    6969        async_exch_t *exch = async_exchange_begin(dev_sess);
    70        
     70
    7171        aid_t aid = async_send_2(exch, DEV_IFACE_ID(IEEE80211_DEV_IFACE),
    7272            IEEE80211_GET_SCAN_RESULTS, now, NULL);
     
    7474            sizeof(ieee80211_scan_results_t));
    7575        async_exchange_end(exch);
    76        
     76
    7777        errno_t res;
    7878        async_wait_for(aid, &res);
    79        
     79
    8080        if(res != EOK)
    8181                return (errno_t) res;
    82        
     82
    8383        return rc;
    8484}
     
    9090                        return false;
    9191        }
    92        
     92
    9393        return true;
    9494}
     
    9999        inet_link_info_t link_info;
    100100        size_t count;
    101        
     101
    102102        errno_t rc = inetcfg_get_link_list(&link_list, &count);
    103103        if (rc != EOK)
    104104                return -1;
    105        
     105
    106106        for (size_t i = 0; i < count; i++) {
    107107                rc = inetcfg_link_get(link_list[i], &link_info);
    108108                if (rc != EOK)
    109109                        return -1;
    110                
     110
    111111                if (mac_matches(mac, link_info.mac_addr))
    112112                        return link_list[i];
    113113        }
    114        
     114
    115115        return -1;
    116116}
     
    129129{
    130130        assert(ssid_start);
    131        
     131
    132132        errno_t rc_orig;
    133        
     133
    134134        async_exch_t *exch = async_exchange_begin(dev_sess);
    135        
     135
    136136        aid_t aid = async_send_1(exch, DEV_IFACE_ID(IEEE80211_DEV_IFACE),
    137137            IEEE80211_CONNECT, NULL);
    138        
     138
    139139        errno_t rc = async_data_write_start(exch, ssid_start,
    140140            str_size(ssid_start) + 1);
     
    142142                async_exchange_end(exch);
    143143                async_wait_for(aid, &rc_orig);
    144                
     144
    145145                if (rc_orig == EOK)
    146146                        return (errno_t) rc;
    147                
     147
    148148                return (errno_t) rc_orig;
    149149        }
    150        
     150
    151151        // FIXME: Typecasting string literal
    152152        if (password == NULL)
    153153                password = (char *) "";
    154        
     154
    155155        rc = async_data_write_start(exch, password, str_size(password) + 1);
    156156        if (rc != EOK) {
    157157                async_exchange_end(exch);
    158158                async_wait_for(aid, &rc_orig);
    159                
     159
    160160                if (rc_orig == EOK)
    161161                        return (errno_t) rc;
    162                
     162
    163163                return (errno_t) rc_orig;
    164164        }
    165        
     165
    166166        async_exchange_end(exch);
    167        
     167
    168168        async_wait_for(aid, &rc);
    169169        if (rc != EOK)
    170170                return rc;
    171        
     171
    172172        /* Send DHCP discover. */
    173173        nic_address_t wifi_mac;
     
    175175        if (rc != EOK)
    176176                return rc;
    177        
     177
    178178        sysarg_t link_id = get_link_id(wifi_mac.address);
    179179        if (link_id == ((sysarg_t) -1))
    180180                return EINVAL;
    181        
     181
    182182        rc = dhcp_discover(link_id);
    183        
     183
    184184        return (errno_t) rc;
    185185}
     
    199199            IEEE80211_DISCONNECT);
    200200        async_exchange_end(exch);
    201        
    202         if (rc != EOK)
    203                 return rc;
    204        
     201
     202        if (rc != EOK)
     203                return rc;
     204
    205205        nic_address_t wifi_mac;
    206206        rc = nic_get_address(dev_sess, &wifi_mac);
    207207        if (rc != EOK)
    208208                return rc;
    209        
     209
    210210        inet_link_info_t link_info;
    211211        inet_addr_info_t addr_info;
     
    214214        sysarg_t *route_list;
    215215        size_t count;
    216        
     216
    217217        /* Remove previous DHCP address. */
    218218        rc = inetcfg_get_addr_list(&addr_list, &count);
    219219        if (rc != EOK)
    220220                return rc;
    221        
     221
    222222        for (size_t i = 0; i < count; i++) {
    223223                rc = inetcfg_addr_get(addr_list[i], &addr_info);
    224224                if (rc != EOK)
    225225                        return rc;
    226                
     226
    227227                rc = inetcfg_link_get(addr_info.ilink, &link_info);
    228228                if (rc != EOK)
    229229                        return rc;
    230                
     230
    231231                if (mac_matches(wifi_mac.address, link_info.mac_addr)) {
    232232                        if (str_test_prefix(addr_info.name, "dhcp")) {
     
    234234                                if (rc != EOK)
    235235                                        return rc;
    236                                
     236
    237237                                break;
    238238                        }
    239239                }
    240240        }
    241        
     241
    242242        /*
    243243         * TODO: At this moment there can be only one DHCP route,
     
    249249        if (rc != EOK)
    250250                return rc;
    251        
     251
    252252        for (size_t i = 0; i < count; i++) {
    253253                rc = inetcfg_sroute_get(route_list[i], &route_info);
    254254                if (rc != EOK)
    255255                        return rc;
    256                
     256
    257257                if (str_test_prefix(route_info.name, "dhcp")) {
    258258                        rc = inetcfg_sroute_delete(route_list[i]);
    259259                        if (rc != EOK)
    260260                                return rc;
    261                        
     261
    262262                        break;
    263263                }
    264264        }
    265        
     265
    266266        return rc;
    267267}
     
    272272        ieee80211_iface_t *ieee80211_iface = (ieee80211_iface_t *) iface;
    273273        assert(ieee80211_iface->get_scan_results);
    274        
     274
    275275        ieee80211_scan_results_t scan_results;
    276276        memset(&scan_results, 0, sizeof(ieee80211_scan_results_t));
    277        
     277
    278278        bool now = IPC_GET_ARG2(*call);
    279        
     279
    280280        errno_t rc = ieee80211_iface->get_scan_results(fun, &scan_results, now);
    281281        if (rc == EOK) {
     
    287287                        return;
    288288                }
    289                
     289
    290290                if (max_len < sizeof(ieee80211_scan_results_t)) {
    291291                        async_answer_0(data_callid, ELIMIT);
     
    293293                        return;
    294294                }
    295                
     295
    296296                async_data_read_finalize(data_callid, &scan_results,
    297297                    sizeof(ieee80211_scan_results_t));
    298298        }
    299        
     299
    300300        async_answer_0(callid, rc);
    301301}
     
    306306        ieee80211_iface_t *ieee80211_iface = (ieee80211_iface_t *) iface;
    307307        assert(ieee80211_iface->connect);
    308        
     308
    309309        char ssid_start[MAX_STRING_SIZE];
    310310        char password[MAX_STRING_SIZE];
    311        
     311
    312312        ipc_callid_t data_callid;
    313313        size_t len;
     
    317317                return;
    318318        }
    319        
     319
    320320        if (len > MAX_STRING_SIZE) {
    321321                async_answer_0(data_callid, EINVAL);
     
    323323                return;
    324324        }
    325        
     325
    326326        errno_t rc = async_data_write_finalize(data_callid, ssid_start, len);
    327327        if (rc != EOK) {
     
    330330                return;
    331331        }
    332        
     332
    333333        if (!async_data_write_receive(&data_callid, &len)) {
    334334                async_answer_0(data_callid, EINVAL);
     
    336336                return;
    337337        }
    338        
     338
    339339        if (len > MAX_STRING_SIZE) {
    340340                async_answer_0(data_callid, EINVAL);
     
    342342                return;
    343343        }
    344        
     344
    345345        rc = async_data_write_finalize(data_callid, password, len);
    346346        if (rc != EOK) {
     
    349349                return;
    350350        }
    351        
     351
    352352        rc = ieee80211_iface->connect(fun, ssid_start, password);
    353        
     353
    354354        async_answer_0(callid, rc);
    355355}
  • uspace/lib/drv/generic/remote_led_dev.c

    r3061bc1 r8565a42  
    7171        led_dev_ops_t *led_dev_ops = (led_dev_ops_t *) ops;
    7272        pixel_t color = DEV_IPC_GET_ARG1(*call);
    73        
     73
    7474        if (!led_dev_ops->color_set) {
    7575                async_answer_0(callid, ENOTSUP);
    7676                return;
    7777        }
    78        
     78
    7979        errno_t rc = (*led_dev_ops->color_set)(fun, color);
    8080        async_answer_0(callid, rc);
  • uspace/lib/drv/generic/remote_nic.c

    r3061bc1 r8565a42  
    101101{
    102102        async_exch_t *exch = async_exchange_begin(dev_sess);
    103        
     103
    104104        ipc_call_t answer;
    105105        aid_t req = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    106106            NIC_SEND_MESSAGE, &answer);
    107107        errno_t retval = async_data_write_start(exch, data, size);
    108        
    109         async_exchange_end(exch);
    110        
     108
     109        async_exchange_end(exch);
     110
    111111        if (retval != EOK) {
    112112                async_forget(req);
     
    132132        errno_t rc;
    133133        errno_t retval;
    134        
     134
    135135        async_exch_t *exch = async_exchange_begin(dev_sess);
    136136        aid_t req = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    137137            NIC_CALLBACK_CREATE, &answer);
    138        
     138
    139139        port_id_t port;
    140140        rc = async_create_callback_port(exch, INTERFACE_NIC_CB, 0, 0,
     
    145145        }
    146146        async_exchange_end(exch);
    147        
     147
    148148        async_wait_for(req, &retval);
    149149        return retval;
     
    161161{
    162162        assert(state);
    163        
     163
    164164        sysarg_t _state;
    165        
     165
    166166        async_exch_t *exch = async_exchange_begin(dev_sess);
    167167        errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    168168            NIC_GET_STATE, &_state);
    169169        async_exchange_end(exch);
    170        
     170
    171171        *state = (nic_device_state_t) _state;
    172        
     172
    173173        return rc;
    174174}
     
    188188            NIC_SET_STATE, state);
    189189        async_exchange_end(exch);
    190        
     190
    191191        return rc;
    192192}
     
    203203{
    204204        assert(address);
    205        
     205
    206206        async_exch_t *exch = async_exchange_begin(dev_sess);
    207207        aid_t aid = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
     
    209209        errno_t rc = async_data_read_start(exch, address, sizeof(nic_address_t));
    210210        async_exchange_end(exch);
    211        
     211
    212212        errno_t res;
    213213        async_wait_for(aid, &res);
    214        
     214
    215215        if (rc != EOK)
    216216                return rc;
    217        
     217
    218218        return res;
    219219}
     
    230230{
    231231        assert(address);
    232        
     232
    233233        async_exch_t *exch = async_exchange_begin(dev_sess);
    234234        aid_t aid = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
     
    236236        errno_t rc = async_data_write_start(exch, address, sizeof(nic_address_t));
    237237        async_exchange_end(exch);
    238        
     238
    239239        errno_t res;
    240240        async_wait_for(aid, &res);
    241        
     241
    242242        if (rc != EOK)
    243243                return rc;
    244        
     244
    245245        return res;
    246246}
     
    257257{
    258258        assert(stats);
    259        
    260         async_exch_t *exch = async_exchange_begin(dev_sess);
    261        
     259
     260        async_exch_t *exch = async_exchange_begin(dev_sess);
     261
    262262        errno_t rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    263263            NIC_GET_STATS);
     
    266266                return rc;
    267267        }
    268        
     268
    269269        rc = async_data_read_start(exch, stats, sizeof(nic_device_stats_t));
    270        
    271         async_exchange_end(exch);
    272        
     270
     271        async_exchange_end(exch);
     272
    273273        return rc;
    274274}
     
    287287{
    288288        assert(device_info);
    289        
    290         async_exch_t *exch = async_exchange_begin(dev_sess);
    291        
     289
     290        async_exch_t *exch = async_exchange_begin(dev_sess);
     291
    292292        aid_t aid = async_send_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    293293            NIC_GET_DEVICE_INFO, NULL);
     
    297297        errno_t res;
    298298        async_wait_for(aid, &res);
    299        
     299
    300300        if (rc != EOK)
    301301                return rc;
    302        
     302
    303303        return res;
    304304}
     
    315315{
    316316        assert(cable_state);
    317        
     317
    318318        sysarg_t _cable_state;
    319        
     319
    320320        async_exch_t *exch = async_exchange_begin(dev_sess);
    321321        errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    322322            NIC_GET_CABLE_STATE, &_cable_state);
    323323        async_exchange_end(exch);
    324        
     324
    325325        *cable_state = (nic_cable_state_t) _cable_state;
    326        
     326
    327327        return rc;
    328328}
     
    344344        sysarg_t _duplex;
    345345        sysarg_t _role;
    346        
     346
    347347        async_exch_t *exch = async_exchange_begin(dev_sess);
    348348        errno_t rc = async_req_1_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    349349            NIC_GET_OPERATION_MODE, &_speed, &_duplex, &_role);
    350350        async_exchange_end(exch);
    351        
     351
    352352        if (speed)
    353353                *speed = (int) _speed;
    354        
     354
    355355        if (duplex)
    356356                *duplex = (nic_channel_mode_t) _duplex;
    357        
     357
    358358        if (role)
    359359                *role = (nic_role_t) _role;
    360        
     360
    361361        return rc;
    362362}
     
    383383            (sysarg_t) role);
    384384        async_exchange_end(exch);
    385        
     385
    386386        return rc;
    387387}
     
    406406            NIC_AUTONEG_ENABLE, (sysarg_t) advertisement);
    407407        async_exchange_end(exch);
    408        
     408
    409409        return rc;
    410410}
     
    423423            NIC_AUTONEG_DISABLE);
    424424        async_exchange_end(exch);
    425        
     425
    426426        return rc;
    427427}
     
    452452        sysarg_t _result;
    453453        sysarg_t _their_result;
    454        
     454
    455455        async_exch_t *exch = async_exchange_begin(dev_sess);
    456456        errno_t rc = async_req_1_4(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
     
    458458            &_result, &_their_result);
    459459        async_exchange_end(exch);
    460        
     460
    461461        if (our_advertisement)
    462462                *our_advertisement = (uint32_t) _our_advertisement;
    463        
     463
    464464        if (*their_advertisement)
    465465                *their_advertisement = (uint32_t) _their_advertisement;
    466        
     466
    467467        if (result)
    468468                *result = (nic_result_t) _result;
    469        
     469
    470470        if (their_result)
    471471                *their_result = (nic_result_t) _their_result;
    472        
     472
    473473        return rc;
    474474}
     
    487487            NIC_AUTONEG_RESTART);
    488488        async_exchange_end(exch);
    489        
     489
    490490        return rc;
    491491}
     
    507507        sysarg_t _we_receive;
    508508        sysarg_t _pause;
    509        
     509
    510510        async_exch_t *exch = async_exchange_begin(dev_sess);
    511511        errno_t rc = async_req_1_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    512512            NIC_GET_PAUSE, &_we_send, &_we_receive, &_pause);
    513513        async_exchange_end(exch);
    514        
     514
    515515        if (we_send)
    516516                *we_send = _we_send;
    517        
     517
    518518        if (we_receive)
    519519                *we_receive = _we_receive;
    520        
     520
    521521        if (pause)
    522522                *pause = _pause;
    523        
     523
    524524        return rc;
    525525}
     
    546546            NIC_SET_PAUSE, allow_send, allow_receive, pause);
    547547        async_exchange_end(exch);
    548        
     548
    549549        return rc;
    550550}
     
    570570{
    571571        assert(mode);
    572        
     572
    573573        sysarg_t _mode;
    574574        sysarg_t _address_count;
    575        
     575
    576576        if (!address_list)
    577577                max_count = 0;
    578        
    579         async_exch_t *exch = async_exchange_begin(dev_sess);
    580        
     578
     579        async_exch_t *exch = async_exchange_begin(dev_sess);
     580
    581581        errno_t rc = async_req_2_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    582582            NIC_UNICAST_GET_MODE, max_count, &_mode, &_address_count);
     
    585585                return rc;
    586586        }
    587        
     587
    588588        *mode = (nic_unicast_mode_t) _mode;
    589589        if (address_count)
    590590                *address_count = (size_t) _address_count;
    591        
     591
    592592        if ((max_count) && (_address_count))
    593593                rc = async_data_read_start(exch, address_list,
    594594                    max_count * sizeof(nic_address_t));
    595        
    596         async_exchange_end(exch);
    597        
     595
     596        async_exchange_end(exch);
     597
    598598        return rc;
    599599}
     
    614614        if (address_list == NULL)
    615615                address_count = 0;
    616        
    617         async_exch_t *exch = async_exchange_begin(dev_sess);
    618        
     616
     617        async_exch_t *exch = async_exchange_begin(dev_sess);
     618
    619619        aid_t message_id = async_send_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    620620            NIC_UNICAST_SET_MODE, (sysarg_t) mode, address_count, NULL);
    621        
     621
    622622        errno_t rc;
    623623        if (address_count)
     
    626626        else
    627627                rc = EOK;
    628        
    629         async_exchange_end(exch);
    630        
     628
     629        async_exchange_end(exch);
     630
    631631        errno_t res;
    632632        async_wait_for(message_id, &res);
    633        
     633
    634634        if (rc != EOK)
    635635                return rc;
    636        
     636
    637637        return res;
    638638}
     
    659659{
    660660        assert(mode);
    661        
     661
    662662        sysarg_t _mode;
    663        
     663
    664664        if (!address_list)
    665665                max_count = 0;
    666        
    667         async_exch_t *exch = async_exchange_begin(dev_sess);
    668        
     666
     667        async_exch_t *exch = async_exchange_begin(dev_sess);
     668
    669669        sysarg_t ac;
    670670        errno_t rc = async_req_2_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
     
    674674                return rc;
    675675        }
    676        
     676
    677677        *mode = (nic_multicast_mode_t) _mode;
    678678        if (address_count)
    679679                *address_count = (size_t) ac;
    680        
     680
    681681        if ((max_count) && (ac))
    682682                rc = async_data_read_start(exch, address_list,
    683683                    max_count * sizeof(nic_address_t));
    684        
     684
    685685        async_exchange_end(exch);
    686686        return rc;
     
    702702        if (address_list == NULL)
    703703                address_count = 0;
    704        
    705         async_exch_t *exch = async_exchange_begin(dev_sess);
    706        
     704
     705        async_exch_t *exch = async_exchange_begin(dev_sess);
     706
    707707        aid_t message_id = async_send_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    708708            NIC_MULTICAST_SET_MODE, (sysarg_t) mode, address_count, NULL);
    709        
     709
    710710        errno_t rc;
    711711        if (address_count)
     
    714714        else
    715715                rc = EOK;
    716        
    717         async_exchange_end(exch);
    718        
     716
     717        async_exchange_end(exch);
     718
    719719        errno_t res;
    720720        async_wait_for(message_id, &res);
    721        
     721
    722722        if (rc != EOK)
    723723                return rc;
    724        
     724
    725725        return res;
    726726}
     
    737737{
    738738        assert(mode);
    739        
     739
    740740        sysarg_t _mode;
    741        
     741
    742742        async_exch_t *exch = async_exchange_begin(dev_sess);
    743743        errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    744744            NIC_BROADCAST_GET_MODE, &_mode);
    745745        async_exchange_end(exch);
    746        
     746
    747747        *mode = (nic_broadcast_mode_t) _mode;
    748        
     748
    749749        return rc;
    750750}
     
    764764            NIC_BROADCAST_SET_MODE, mode);
    765765        async_exchange_end(exch);
    766        
     766
    767767        return rc;
    768768}
     
    779779{
    780780        assert(mode);
    781        
     781
    782782        sysarg_t _mode;
    783        
     783
    784784        async_exch_t *exch = async_exchange_begin(dev_sess);
    785785        errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    786786            NIC_DEFECTIVE_GET_MODE, &_mode);
    787787        async_exchange_end(exch);
    788        
     788
    789789        *mode = (uint32_t) _mode;
    790        
     790
    791791        return rc;
    792792}
     
    806806            NIC_DEFECTIVE_SET_MODE, mode);
    807807        async_exchange_end(exch);
    808        
     808
    809809        return rc;
    810810}
     
    827827        if (!address_list)
    828828                max_count = 0;
    829        
    830         async_exch_t *exch = async_exchange_begin(dev_sess);
    831        
     829
     830        async_exch_t *exch = async_exchange_begin(dev_sess);
     831
    832832        sysarg_t ac;
    833833        errno_t rc = async_req_2_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
     
    837837                return rc;
    838838        }
    839        
     839
    840840        if (address_count)
    841841                *address_count = (size_t) ac;
    842        
     842
    843843        if ((max_count) && (ac))
    844844                rc = async_data_read_start(exch, address_list,
    845845                    max_count * sizeof(nic_address_t));
    846        
     846
    847847        async_exchange_end(exch);
    848848        return rc;
     
    863863        if (address_list == NULL)
    864864                address_count = 0;
    865        
    866         async_exch_t *exch = async_exchange_begin(dev_sess);
    867        
     865
     866        async_exch_t *exch = async_exchange_begin(dev_sess);
     867
    868868        aid_t message_id = async_send_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    869869            NIC_BLOCKED_SOURCES_SET, address_count, NULL);
    870        
     870
    871871        errno_t rc;
    872872        if (address_count)
     
    875875        else
    876876                rc = EOK;
    877        
    878         async_exchange_end(exch);
    879        
     877
     878        async_exchange_end(exch);
     879
    880880        errno_t res;
    881881        async_wait_for(message_id, &res);
    882        
     882
    883883        if (rc != EOK)
    884884                return rc;
    885        
     885
    886886        return res;
    887887}
     
    898898{
    899899        assert(mask);
    900        
     900
    901901        async_exch_t *exch = async_exchange_begin(dev_sess);
    902902        errno_t rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
     
    906906                return rc;
    907907        }
    908        
     908
    909909        rc = async_data_read_start(exch, mask, sizeof(nic_vlan_mask_t));
    910910        async_exchange_end(exch);
    911        
     911
    912912        return rc;
    913913}
     
    926926{
    927927        async_exch_t *exch = async_exchange_begin(dev_sess);
    928        
     928
    929929        aid_t message_id = async_send_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    930930            NIC_VLAN_SET_MASK, mask != NULL, NULL);
    931        
     931
    932932        errno_t rc;
    933933        if (mask != NULL)
     
    935935        else
    936936                rc = EOK;
    937        
    938         async_exchange_end(exch);
    939        
     937
     938        async_exchange_end(exch);
     939
    940940        errno_t res;
    941941        async_wait_for(message_id, &res);
    942        
     942
    943943        if (rc != EOK)
    944944                return rc;
    945        
     945
    946946        return res;
    947947}
     
    969969            NIC_VLAN_SET_TAG, (sysarg_t) tag, (sysarg_t) add, (sysarg_t) strip);
    970970        async_exchange_end(exch);
    971        
     971
    972972        return rc;
    973973}
     
    989989{
    990990        assert(id);
    991        
     991
    992992        bool send_data = ((data != NULL) && (length != 0));
    993993        async_exch_t *exch = async_exchange_begin(dev_sess);
    994        
     994
    995995        ipc_call_t result;
    996996        aid_t message_id = async_send_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    997997            NIC_WOL_VIRTUE_ADD, (sysarg_t) type, send_data, &result);
    998        
     998
    999999        errno_t res;
    10001000        if (send_data) {
     
    10061006                }
    10071007        }
    1008        
     1008
    10091009        async_exchange_end(exch);
    10101010        async_wait_for(message_id, &res);
    1011        
     1011
    10121012        *id = IPC_GET_ARG1(result);
    10131013        return res;
     
    10281028            NIC_WOL_VIRTUE_REMOVE, (sysarg_t) id);
    10291029        async_exchange_end(exch);
    1030        
     1030
    10311031        return rc;
    10321032}
     
    10501050        sysarg_t _type;
    10511051        sysarg_t _length;
    1052        
     1052
    10531053        if (data == NULL)
    10541054                max_length = 0;
    1055        
    1056         async_exch_t *exch = async_exchange_begin(dev_sess);
    1057        
     1055
     1056        async_exch_t *exch = async_exchange_begin(dev_sess);
     1057
    10581058        errno_t rc = async_req_3_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    10591059            NIC_WOL_VIRTUE_PROBE, (sysarg_t) id, max_length,
     
    10631063                return rc;
    10641064        }
    1065        
     1065
    10661066        if (type)
    10671067                *type = _type;
    1068        
     1068
    10691069        if (length)
    10701070                *length = _length;
    1071        
     1071
    10721072        if ((max_length) && (_length != 0))
    10731073                rc = async_data_read_start(exch, data, max_length);
    1074        
     1074
    10751075        async_exchange_end(exch);
    10761076        return rc;
     
    11001100        if (id_list == NULL)
    11011101                max_count = 0;
    1102        
    1103         async_exch_t *exch = async_exchange_begin(dev_sess);
    1104        
     1102
     1103        async_exch_t *exch = async_exchange_begin(dev_sess);
     1104
    11051105        sysarg_t count;
    11061106        errno_t rc = async_req_3_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    11071107            NIC_WOL_VIRTUE_LIST, (sysarg_t) type, max_count, &count);
    1108        
     1108
    11091109        if (id_count)
    11101110                *id_count = (size_t) count;
    1111        
     1111
    11121112        if ((rc != EOK) || (!max_count)) {
    11131113                async_exchange_end(exch);
    11141114                return rc;
    11151115        }
    1116        
     1116
    11171117        rc = async_data_read_start(exch, id_list,
    11181118            max_count * sizeof(nic_wv_id_t));
    1119        
     1119
    11201120        async_exchange_end(exch);
    11211121        return rc;
     
    11391139{
    11401140        assert(count);
    1141        
     1141
    11421142        sysarg_t _count;
    1143        
     1143
    11441144        async_exch_t *exch = async_exchange_begin(dev_sess);
    11451145        errno_t rc = async_req_2_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    11461146            NIC_WOL_VIRTUE_GET_CAPS, (sysarg_t) type, &_count);
    11471147        async_exchange_end(exch);
    1148        
     1148
    11491149        *count = (int) _count;
    11501150        return rc;
     
    11771177{
    11781178        assert(matched_type);
    1179        
     1179
    11801180        sysarg_t _matched_type;
    11811181        sysarg_t _frame_length;
    1182        
     1182
    11831183        if (frame == NULL)
    11841184                max_length = 0;
    1185        
    1186         async_exch_t *exch = async_exchange_begin(dev_sess);
    1187        
     1185
     1186        async_exch_t *exch = async_exchange_begin(dev_sess);
     1187
    11881188        errno_t rc = async_req_2_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    11891189            NIC_WOL_LOAD_INFO, max_length, &_matched_type, &_frame_length);
     
    11921192                return rc;
    11931193        }
    1194        
     1194
    11951195        *matched_type = (nic_wv_type_t) _matched_type;
    11961196        if (frame_length)
    11971197                *frame_length = (size_t) _frame_length;
    1198        
     1198
    11991199        if ((max_length != 0) && (_frame_length != 0))
    12001200                rc = async_data_read_start(exch, frame, max_length);
    1201        
     1201
    12021202        async_exchange_end(exch);
    12031203        return rc;
     
    12181218        assert(supported);
    12191219        assert(active);
    1220        
     1220
    12211221        sysarg_t _supported;
    12221222        sysarg_t _active;
    1223        
     1223
    12241224        async_exch_t *exch = async_exchange_begin(dev_sess);
    12251225        errno_t rc = async_req_1_2(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    12261226            NIC_OFFLOAD_PROBE, &_supported, &_active);
    12271227        async_exchange_end(exch);
    1228        
     1228
    12291229        *supported = (uint32_t) _supported;
    12301230        *active = (uint32_t) _active;
     
    12471247            NIC_AUTONEG_RESTART, (sysarg_t) mask, (sysarg_t) active);
    12481248        async_exchange_end(exch);
    1249        
     1249
    12501250        return rc;
    12511251}
     
    12651265{
    12661266        assert(mode);
    1267        
     1267
    12681268        sysarg_t _mode;
    1269        
    1270         async_exch_t *exch = async_exchange_begin(dev_sess);
    1271        
     1269
     1270        async_exch_t *exch = async_exchange_begin(dev_sess);
     1271
    12721272        errno_t rc = async_req_2_1(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    12731273            NIC_POLL_GET_MODE, period != NULL, &_mode);
     
    12761276                return rc;
    12771277        }
    1278        
     1278
    12791279        *mode = (nic_poll_mode_t) _mode;
    1280        
     1280
    12811281        if (period != NULL)
    12821282                rc = async_data_read_start(exch, period, sizeof(struct timeval));
    1283        
     1283
    12841284        async_exchange_end(exch);
    12851285        return rc;
     
    12991299{
    13001300        async_exch_t *exch = async_exchange_begin(dev_sess);
    1301        
     1301
    13021302        aid_t message_id = async_send_3(exch, DEV_IFACE_ID(NIC_DEV_IFACE),
    13031303            NIC_POLL_SET_MODE, (sysarg_t) mode, period != NULL, NULL);
    1304        
     1304
    13051305        errno_t rc;
    13061306        if (period)
     
    13081308        else
    13091309                rc = EOK;
    1310        
    1311         async_exchange_end(exch);
    1312        
     1310
     1311        async_exchange_end(exch);
     1312
    13131313        errno_t res;
    13141314        async_wait_for(message_id, &res);
    1315        
     1315
    13161316        if (rc != EOK)
    13171317                return rc;
    1318        
     1318
    13191319        return res;
    13201320}
     
    13321332        errno_t rc = async_req_1_0(exch, DEV_IFACE_ID(NIC_DEV_IFACE), NIC_POLL_NOW);
    13331333        async_exchange_end(exch);
    1334        
     1334
    13351335        return rc;
    13361336}
     
    13411341        nic_iface_t *nic_iface = (nic_iface_t *) iface;
    13421342        assert(nic_iface->send_frame);
    1343        
     1343
    13441344        void *data;
    13451345        size_t size;
    13461346        errno_t rc;
    1347        
     1347
    13481348        rc = async_data_write_accept(&data, false, 0, 0, 0, &size);
    13491349        if (rc != EOK) {
     
    13511351                return;
    13521352        }
    1353        
     1353
    13541354        rc = nic_iface->send_frame(dev, data, size);
    13551355        async_answer_0(callid, rc);
     
    13621362        nic_iface_t *nic_iface = (nic_iface_t *) iface;
    13631363        assert(nic_iface->callback_create);
    1364        
     1364
    13651365        errno_t rc = nic_iface->callback_create(dev);
    13661366        async_answer_0(callid, rc);
     
    13721372        nic_iface_t *nic_iface = (nic_iface_t *) iface;
    13731373        assert(nic_iface->get_state);
    1374        
     1374
    13751375        nic_device_state_t state = NIC_STATE_MAX;
    1376        
     1376
    13771377        errno_t rc = nic_iface->get_state(dev, &state);
    13781378        async_answer_1(callid, rc, state);
     
    13841384        nic_iface_t *nic_iface = (nic_iface_t *) iface;
    13851385        assert(nic_iface->set_state);
    1386        
     1386
    13871387        nic_device_state_t state = (nic_device_state_t) IPC_GET_ARG2(*call);
    1388        
     1388
    13891389        errno_t rc = nic_iface->set_state(dev, state);
    13901390        async_answer_0(callid, rc);
     
    13961396        nic_iface_t *nic_iface = (nic_iface_t *) iface;
    13971397        assert(nic_iface->get_address);
    1398        
     1398
    13991399        nic_address_t address;
    14001400        memset(&address, 0, sizeof(nic_address_t));
    1401        
     1401
    14021402        errno_t rc = nic_iface->get_address(dev, &address);
    14031403        if (rc == EOK) {
    14041404                size_t max_len;
    14051405                ipc_callid_t data_callid;
    1406                
     1406
    14071407                /* All errors will be translated into EPARTY anyway */
    14081408                if (!async_data_read_receive(&data_callid, &max_len)) {
     
    14111411                        return;
    14121412                }
    1413                
     1413
    14141414                if (max_len != sizeof(nic_address_t)) {
    14151415                        async_answer_0(data_callid, ELIMIT);
     
    14171417                        return;
    14181418                }
    1419                
     1419
    14201420                async_data_read_finalize(data_callid, &address,
    14211421                    sizeof(nic_address_t));
    14221422        }
    1423        
     1423
    14241424        async_answer_0(callid, rc);
    14251425}
     
    14291429{
    14301430        nic_iface_t *nic_iface = (nic_iface_t *) iface;
    1431        
     1431
    14321432        size_t length;
    14331433        ipc_callid_t data_callid;
     
    14371437                return;
    14381438        }
    1439        
     1439
    14401440        if (length > sizeof(nic_address_t)) {
    14411441                async_answer_0(data_callid, ELIMIT);
     
    14431443                return;
    14441444        }
    1445        
     1445
    14461446        nic_address_t address;
    14471447        if (async_data_write_finalize(data_callid, &address, length) != EOK) {
     
    14491449                return;
    14501450        }
    1451        
     1451
    14521452        if (nic_iface->set_address != NULL) {
    14531453                errno_t rc = nic_iface->set_address(dev, &address);
     
    14651465                return;
    14661466        }
    1467        
     1467
    14681468        nic_device_stats_t stats;
    14691469        memset(&stats, 0, sizeof(nic_device_stats_t));
    1470        
     1470
    14711471        errno_t rc = nic_iface->get_stats(dev, &stats);
    14721472        if (rc == EOK) {
     
    14781478                        return;
    14791479                }
    1480                
     1480
    14811481                if (max_len < sizeof(nic_device_stats_t)) {
    14821482                        async_answer_0(data_callid, ELIMIT);
     
    14841484                        return;
    14851485                }
    1486                
     1486
    14871487                async_data_read_finalize(data_callid, &stats,
    14881488                    sizeof(nic_device_stats_t));
    14891489        }
    1490        
     1490
    14911491        async_answer_0(callid, rc);
    14921492}
     
    15001500                return;
    15011501        }
    1502        
     1502
    15031503        nic_device_info_t info;
    15041504        memset(&info, 0, sizeof(nic_device_info_t));
    1505        
     1505
    15061506        errno_t rc = nic_iface->get_device_info(dev, &info);
    15071507        if (rc == EOK) {
     
    15131513                        return;
    15141514                }
    1515                
     1515
    15161516                if (max_len < sizeof (nic_device_info_t)) {
    15171517                        async_answer_0(data_callid, ELIMIT);
     
    15191519                        return;
    15201520                }
    1521                
     1521
    15221522                async_data_read_finalize(data_callid, &info,
    15231523                    sizeof(nic_device_info_t));
    15241524        }
    1525        
     1525
    15261526        async_answer_0(callid, rc);
    15271527}
     
    15351535                return;
    15361536        }
    1537        
     1537
    15381538        nic_cable_state_t cs = NIC_CS_UNKNOWN;
    1539        
     1539
    15401540        errno_t rc = nic_iface->get_cable_state(dev, &cs);
    15411541        async_answer_1(callid, rc, (sysarg_t) cs);
     
    15501550                return;
    15511551        }
    1552        
     1552
    15531553        int speed = 0;
    15541554        nic_channel_mode_t duplex = NIC_CM_UNKNOWN;
    15551555        nic_role_t role = NIC_ROLE_UNKNOWN;
    1556        
     1556
    15571557        errno_t rc = nic_iface->get_operation_mode(dev, &speed, &duplex, &role);
    15581558        async_answer_3(callid, rc, (sysarg_t) speed, (sysarg_t) duplex,
     
    15681568                return;
    15691569        }
    1570        
     1570
    15711571        int speed = (int) IPC_GET_ARG2(*call);
    15721572        nic_channel_mode_t duplex = (nic_channel_mode_t) IPC_GET_ARG3(*call);
    15731573        nic_role_t role = (nic_role_t) IPC_GET_ARG4(*call);
    1574        
     1574
    15751575        errno_t rc = nic_iface->set_operation_mode(dev, speed, duplex, role);
    15761576        async_answer_0(callid, rc);
     
    15851585                return;
    15861586        }
    1587        
     1587
    15881588        uint32_t advertisement = (uint32_t) IPC_GET_ARG2(*call);
    1589        
     1589
    15901590        errno_t rc = nic_iface->autoneg_enable(dev, advertisement);
    15911591        async_answer_0(callid, rc);
     
    16001600                return;
    16011601        }
    1602        
     1602
    16031603        errno_t rc = nic_iface->autoneg_disable(dev);
    16041604        async_answer_0(callid, rc);
     
    16131613                return;
    16141614        }
    1615        
     1615
    16161616        uint32_t our_adv = 0;
    16171617        uint32_t their_adv = 0;
    16181618        nic_result_t result = NIC_RESULT_NOT_AVAILABLE;
    16191619        nic_result_t their_result = NIC_RESULT_NOT_AVAILABLE;
    1620        
     1620
    16211621        errno_t rc = nic_iface->autoneg_probe(dev, &our_adv, &their_adv, &result,
    16221622            &their_result);
     
    16331633                return;
    16341634        }
    1635        
     1635
    16361636        errno_t rc = nic_iface->autoneg_restart(dev);
    16371637        async_answer_0(callid, rc);
     
    16461646                return;
    16471647        }
    1648        
     1648
    16491649        nic_result_t we_send;
    16501650        nic_result_t we_receive;
    16511651        uint16_t pause;
    1652        
     1652
    16531653        errno_t rc = nic_iface->get_pause(dev, &we_send, &we_receive, &pause);
    16541654        async_answer_3(callid, rc, we_send, we_receive, pause);
     
    16631663                return;
    16641664        }
    1665        
     1665
    16661666        int allow_send = (int) IPC_GET_ARG2(*call);
    16671667        int allow_receive = (int) IPC_GET_ARG3(*call);
    16681668        uint16_t pause = (uint16_t) IPC_GET_ARG4(*call);
    1669        
     1669
    16701670        errno_t rc = nic_iface->set_pause(dev, allow_send, allow_receive,
    16711671            pause);
     
    16811681                return;
    16821682        }
    1683        
     1683
    16841684        size_t max_count = IPC_GET_ARG2(*call);
    16851685        nic_address_t *address_list = NULL;
    1686        
     1686
    16871687        if (max_count != 0) {
    16881688                address_list = malloc(max_count * sizeof (nic_address_t));
     
    16921692                }
    16931693        }
    1694        
     1694
    16951695        memset(address_list, 0, max_count * sizeof(nic_address_t));
    16961696        nic_unicast_mode_t mode = NIC_UNICAST_DEFAULT;
    16971697        size_t address_count = 0;
    1698        
     1698
    16991699        errno_t rc = nic_iface->unicast_get_mode(dev, &mode, max_count, address_list,
    17001700            &address_count);
    1701        
     1701
    17021702        if ((rc != EOK) || (max_count == 0) || (address_count == 0)) {
    17031703                free(address_list);
     
    17051705                return;
    17061706        }
    1707        
     1707
    17081708        ipc_callid_t data_callid;
    17091709        size_t max_len;
     
    17141714                return;
    17151715        }
    1716        
     1716
    17171717        if (max_len > address_count * sizeof(nic_address_t))
    17181718                max_len = address_count * sizeof(nic_address_t);
    1719        
     1719
    17201720        if (max_len > max_count * sizeof(nic_address_t))
    17211721                max_len = max_count * sizeof(nic_address_t);
    1722        
     1722
    17231723        async_data_read_finalize(data_callid, address_list, max_len);
    17241724        async_answer_0(data_callid, EINVAL);
    1725        
     1725
    17261726        free(address_list);
    17271727        async_answer_2(callid, rc, mode, address_count);
     
    17321732{
    17331733        nic_iface_t *nic_iface = (nic_iface_t *) iface;
    1734        
     1734
    17351735        size_t length;
    17361736        nic_unicast_mode_t mode = IPC_GET_ARG2(*call);
    17371737        size_t address_count = IPC_GET_ARG3(*call);
    17381738        nic_address_t *address_list = NULL;
    1739        
     1739
    17401740        if (address_count) {
    17411741                ipc_callid_t data_callid;
     
    17451745                        return;
    17461746                }
    1747                
     1747
    17481748                if (length != address_count * sizeof(nic_address_t)) {
    17491749                        async_answer_0(data_callid, ELIMIT);
     
    17511751                        return;
    17521752                }
    1753                
     1753
    17541754                address_list = malloc(length);
    17551755                if (address_list == NULL) {
     
    17581758                        return;
    17591759                }
    1760                
     1760
    17611761                if (async_data_write_finalize(data_callid, address_list,
    17621762                    length) != EOK) {
     
    17661766                }
    17671767        }
    1768        
     1768
    17691769        if (nic_iface->unicast_set_mode != NULL) {
    17701770                errno_t rc = nic_iface->unicast_set_mode(dev, mode, address_list,
     
    17731773        } else
    17741774                async_answer_0(callid, ENOTSUP);
    1775        
     1775
    17761776        free(address_list);
    17771777}
     
    17851785                return;
    17861786        }
    1787        
     1787
    17881788        size_t max_count = IPC_GET_ARG2(*call);
    17891789        nic_address_t *address_list = NULL;
    1790        
     1790
    17911791        if (max_count != 0) {
    17921792                address_list = malloc(max_count * sizeof(nic_address_t));
     
    17961796                }
    17971797        }
    1798        
     1798
    17991799        memset(address_list, 0, max_count * sizeof(nic_address_t));
    18001800        nic_multicast_mode_t mode = NIC_MULTICAST_BLOCKED;
    18011801        size_t address_count = 0;
    1802        
     1802
    18031803        errno_t rc = nic_iface->multicast_get_mode(dev, &mode, max_count, address_list,
    18041804            &address_count);
    1805        
    1806        
     1805
     1806
    18071807        if ((rc != EOK) || (max_count == 0) || (address_count == 0)) {
    18081808                free(address_list);
     
    18101810                return;
    18111811        }
    1812        
     1812
    18131813        ipc_callid_t data_callid;
    18141814        size_t max_len;
     
    18191819                return;
    18201820        }
    1821        
     1821
    18221822        if (max_len > address_count * sizeof(nic_address_t))
    18231823                max_len = address_count * sizeof(nic_address_t);
    1824        
     1824
    18251825        if (max_len > max_count * sizeof(nic_address_t))
    18261826                max_len = max_count * sizeof(nic_address_t);
    1827        
     1827
    18281828        async_data_read_finalize(data_callid, address_list, max_len);
    1829        
     1829
    18301830        free(address_list);
    18311831        async_answer_2(callid, rc, mode, address_count);
     
    18361836{
    18371837        nic_iface_t *nic_iface = (nic_iface_t *) iface;
    1838        
     1838
    18391839        nic_multicast_mode_t mode = IPC_GET_ARG2(*call);
    18401840        size_t address_count = IPC_GET_ARG3(*call);
    18411841        nic_address_t *address_list = NULL;
    1842        
     1842
    18431843        if (address_count) {
    18441844                ipc_callid_t data_callid;
     
    18491849                        return;
    18501850                }
    1851                
     1851
    18521852                if (length != address_count * sizeof (nic_address_t)) {
    18531853                        async_answer_0(data_callid, ELIMIT);
     
    18551855                        return;
    18561856                }
    1857                
     1857
    18581858                address_list = malloc(length);
    18591859                if (address_list == NULL) {
     
    18621862                        return;
    18631863                }
    1864                
     1864
    18651865                if (async_data_write_finalize(data_callid, address_list,
    18661866                    length) != EOK) {
     
    18701870                }
    18711871        }
    1872        
     1872
    18731873        if (nic_iface->multicast_set_mode != NULL) {
    18741874                errno_t rc = nic_iface->multicast_set_mode(dev, mode, address_list,
     
    18771877        } else
    18781878                async_answer_0(callid, ENOTSUP);
    1879        
     1879
    18801880        free(address_list);
    18811881}
     
    18891889                return;
    18901890        }
    1891        
     1891
    18921892        nic_broadcast_mode_t mode = NIC_BROADCAST_ACCEPTED;
    1893        
     1893
    18941894        errno_t rc = nic_iface->broadcast_get_mode(dev, &mode);
    18951895        async_answer_1(callid, rc, mode);
     
    19041904                return;
    19051905        }
    1906        
     1906
    19071907        nic_broadcast_mode_t mode = IPC_GET_ARG2(*call);
    1908        
     1908
    19091909        errno_t rc = nic_iface->broadcast_set_mode(dev, mode);
    19101910        async_answer_0(callid, rc);
     
    19191919                return;
    19201920        }
    1921        
     1921
    19221922        uint32_t mode = 0;
    1923        
     1923
    19241924        errno_t rc = nic_iface->defective_get_mode(dev, &mode);
    19251925        async_answer_1(callid, rc, mode);
     
    19341934                return;
    19351935        }
    1936        
     1936
    19371937        uint32_t mode = IPC_GET_ARG2(*call);
    1938        
     1938
    19391939        errno_t rc = nic_iface->defective_set_mode(dev, mode);
    19401940        async_answer_0(callid, rc);
     
    19491949                return;
    19501950        }
    1951        
     1951
    19521952        size_t max_count = IPC_GET_ARG2(*call);
    19531953        nic_address_t *address_list = NULL;
    1954        
     1954
    19551955        if (max_count != 0) {
    19561956                address_list = malloc(max_count * sizeof(nic_address_t));
     
    19601960                }
    19611961        }
    1962        
     1962
    19631963        memset(address_list, 0, max_count * sizeof(nic_address_t));
    19641964        size_t address_count = 0;
    1965        
     1965
    19661966        errno_t rc = nic_iface->blocked_sources_get(dev, max_count, address_list,
    19671967            &address_count);
    1968        
     1968
    19691969        if ((rc != EOK) || (max_count == 0) || (address_count == 0)) {
    19701970                async_answer_1(callid, rc, address_count);
     
    19721972                return;
    19731973        }
    1974        
     1974
    19751975        ipc_callid_t data_callid;
    19761976        size_t max_len;
     
    19811981                return;
    19821982        }
    1983        
     1983
    19841984        if (max_len > address_count * sizeof(nic_address_t))
    19851985                max_len = address_count * sizeof(nic_address_t);
    1986        
     1986
    19871987        if (max_len > max_count * sizeof(nic_address_t))
    19881988                max_len = max_count * sizeof(nic_address_t);
    1989        
     1989
    19901990        async_data_read_finalize(data_callid, address_list, max_len);
    19911991        async_answer_0(data_callid, EINVAL);
    1992        
     1992
    19931993        free(address_list);
    19941994        async_answer_1(callid, rc, address_count);
     
    19991999{
    20002000        nic_iface_t *nic_iface = (nic_iface_t *) iface;
    2001        
     2001
    20022002        size_t length;
    20032003        size_t address_count = IPC_GET_ARG2(*call);
    20042004        nic_address_t *address_list = NULL;
    2005        
     2005
    20062006        if (address_count) {
    20072007                ipc_callid_t data_callid;
     
    20112011                        return;
    20122012                }
    2013                
     2013
    20142014                if (length != address_count * sizeof(nic_address_t)) {
    20152015                        async_answer_0(data_callid, ELIMIT);
     
    20172017                        return;
    20182018                }
    2019                
     2019
    20202020                address_list = malloc(length);
    20212021                if (address_list == NULL) {
     
    20242024                        return;
    20252025                }
    2026                
     2026
    20272027                if (async_data_write_finalize(data_callid, address_list,
    20282028                    length) != EOK) {
     
    20322032                }
    20332033        }
    2034        
     2034
    20352035        if (nic_iface->blocked_sources_set != NULL) {
    20362036                errno_t rc = nic_iface->blocked_sources_set(dev, address_list,
     
    20392039        } else
    20402040                async_answer_0(callid, ENOTSUP);
    2041        
     2041
    20422042        free(address_list);
    20432043}
     
    20512051                return;
    20522052        }
    2053        
     2053
    20542054        nic_vlan_mask_t vlan_mask;
    20552055        memset(&vlan_mask, 0, sizeof(nic_vlan_mask_t));
    2056        
     2056
    20572057        errno_t rc = nic_iface->vlan_get_mask(dev, &vlan_mask);
    20582058        if (rc == EOK) {
     
    20642064                        return;
    20652065                }
    2066                
     2066
    20672067                if (max_len != sizeof(nic_vlan_mask_t)) {
    20682068                        async_answer_0(data_callid, EINVAL);
     
    20702070                        return;
    20712071                }
    2072                
     2072
    20732073                async_data_read_finalize(data_callid, &vlan_mask, max_len);
    20742074        }
    2075        
     2075
    20762076        async_answer_0(callid, rc);
    20772077}
     
    20812081{
    20822082        nic_iface_t *nic_iface = (nic_iface_t *) iface;
    2083        
     2083
    20842084        nic_vlan_mask_t vlan_mask;
    20852085        nic_vlan_mask_t *vlan_mask_pointer = NULL;
    20862086        bool vlan_mask_set = (bool) IPC_GET_ARG2(*call);
    2087        
     2087
    20882088        if (vlan_mask_set) {
    20892089                ipc_callid_t data_callid;
     
    20942094                        return;
    20952095                }
    2096                
     2096
    20972097                if (length != sizeof(nic_vlan_mask_t)) {
    20982098                        async_answer_0(data_callid, ELIMIT);
     
    21002100                        return;
    21012101                }
    2102                
     2102
    21032103                if (async_data_write_finalize(data_callid, &vlan_mask,
    21042104                    length) != EOK) {
     
    21062106                        return;
    21072107                }
    2108                
     2108
    21092109                vlan_mask_pointer = &vlan_mask;
    21102110        }
    2111        
     2111
    21122112        if (nic_iface->vlan_set_mask != NULL) {
    21132113                errno_t rc = nic_iface->vlan_set_mask(dev, vlan_mask_pointer);
     
    21212121{
    21222122        nic_iface_t *nic_iface = (nic_iface_t *) iface;
    2123        
     2123
    21242124        if (nic_iface->vlan_set_tag == NULL) {
    21252125                async_answer_0(callid, ENOTSUP);
    21262126                return;
    21272127        }
    2128        
     2128
    21292129        uint16_t tag = (uint16_t) IPC_GET_ARG2(*call);
    21302130        bool add = (int) IPC_GET_ARG3(*call);
    21312131        bool strip = (int) IPC_GET_ARG4(*call);
    2132        
     2132
    21332133        errno_t rc = nic_iface->vlan_set_tag(dev, tag, add, strip);
    21342134        async_answer_0(callid, rc);
     
    21392139{
    21402140        nic_iface_t *nic_iface = (nic_iface_t *) iface;
    2141        
     2141
    21422142        int send_data = (int) IPC_GET_ARG3(*call);
    21432143        ipc_callid_t data_callid;
    2144        
     2144
    21452145        if (nic_iface->wol_virtue_add == NULL) {
    21462146                if (send_data) {
     
    21482148                        async_answer_0(data_callid, ENOTSUP);
    21492149                }
    2150                
    2151                 async_answer_0(callid, ENOTSUP);
    2152         }
    2153        
     2150
     2151                async_answer_0(callid, ENOTSUP);
     2152        }
     2153
    21542154        size_t length = 0;
    21552155        void *data = NULL;
    2156        
     2156
    21572157        if (send_data) {
    21582158                if (!async_data_write_receive(&data_callid, &length)) {
     
    21612161                        return;
    21622162                }
    2163                
     2163
    21642164                data = malloc(length);
    21652165                if (data == NULL) {
     
    21682168                        return;
    21692169                }
    2170                
     2170
    21712171                if (async_data_write_finalize(data_callid, data,
    21722172                    length) != EOK) {
     
    21762176                }
    21772177        }
    2178        
     2178
    21792179        nic_wv_id_t id = 0;
    21802180        nic_wv_type_t type = (nic_wv_type_t) IPC_GET_ARG2(*call);
    2181        
     2181
    21822182        errno_t rc = nic_iface->wol_virtue_add(dev, type, data, length, &id);
    21832183        async_answer_1(callid, rc, (sysarg_t) id);
     
    21892189{
    21902190        nic_iface_t *nic_iface = (nic_iface_t *) iface;
    2191        
     2191
    21922192        if (nic_iface->wol_virtue_remove == NULL) {
    21932193                async_answer_0(callid, ENOTSUP);
    21942194                return;
    21952195        }
    2196        
     2196
    21972197        nic_wv_id_t id = (nic_wv_id_t) IPC_GET_ARG2(*call);
    2198        
     2198
    21992199        errno_t rc = nic_iface->wol_virtue_remove(dev, id);
    22002200        async_answer_0(callid, rc);
     
    22052205{
    22062206        nic_iface_t *nic_iface = (nic_iface_t *) iface;
    2207        
     2207
    22082208        if (nic_iface->wol_virtue_probe == NULL) {
    22092209                async_answer_0(callid, ENOTSUP);
    22102210                return;
    22112211        }
    2212        
     2212
    22132213        nic_wv_id_t id = (nic_wv_id_t) IPC_GET_ARG2(*call);
    22142214        size_t max_length = IPC_GET_ARG3(*call);
     
    22172217        ipc_callid_t data_callid;
    22182218        void *data = NULL;
    2219        
     2219
    22202220        if (max_length != 0) {
    22212221                data = malloc(max_length);
     
    22252225                }
    22262226        }
    2227        
     2227
    22282228        memset(data, 0, max_length);
    2229        
     2229
    22302230        errno_t rc = nic_iface->wol_virtue_probe(dev, id, &type, max_length,
    22312231            data, &length);
    2232        
     2232
    22332233        if ((max_length != 0) && (length != 0)) {
    22342234                size_t req_length;
     
    22392239                        return;
    22402240                }
    2241                
     2241
    22422242                if (req_length > length)
    22432243                        req_length = length;
    2244                
     2244
    22452245                if (req_length > max_length)
    22462246                        req_length = max_length;
    2247                
     2247
    22482248                async_data_read_finalize(data_callid, data, req_length);
    22492249        }
    2250        
     2250
    22512251        async_answer_2(callid, rc, (sysarg_t) type, (sysarg_t) length);
    22522252        free(data);
     
    22612261                return;
    22622262        }
    2263        
     2263
    22642264        nic_wv_type_t type = (nic_wv_type_t) IPC_GET_ARG2(*call);
    22652265        size_t max_count = IPC_GET_ARG3(*call);
     
    22672267        nic_wv_id_t *id_list = NULL;
    22682268        ipc_callid_t data_callid;
    2269        
     2269
    22702270        if (max_count != 0) {
    22712271                id_list = malloc(max_count * sizeof(nic_wv_id_t));
     
    22752275                }
    22762276        }
    2277        
     2277
    22782278        memset(id_list, 0, max_count * sizeof (nic_wv_id_t));
    2279        
     2279
    22802280        errno_t rc = nic_iface->wol_virtue_list(dev, type, max_count, id_list,
    22812281            &count);
    2282        
     2282
    22832283        if ((max_count != 0) && (count != 0)) {
    22842284                size_t req_length;
     
    22892289                        return;
    22902290                }
    2291                
     2291
    22922292                if (req_length > count * sizeof(nic_wv_id_t))
    22932293                        req_length = count * sizeof(nic_wv_id_t);
    2294                
     2294
    22952295                if (req_length > max_count * sizeof(nic_wv_id_t))
    22962296                        req_length = max_count * sizeof(nic_wv_id_t);
    2297                
     2297
    22982298                rc = async_data_read_finalize(data_callid, id_list, req_length);
    22992299        }
    2300        
     2300
    23012301        async_answer_1(callid, rc, (sysarg_t) count);
    23022302        free(id_list);
     
    23112311                return;
    23122312        }
    2313        
     2313
    23142314        int count = -1;
    23152315        nic_wv_type_t type = (nic_wv_type_t) IPC_GET_ARG2(*call);
    2316        
     2316
    23172317        errno_t rc = nic_iface->wol_virtue_get_caps(dev, type, &count);
    23182318        async_answer_1(callid, rc, (sysarg_t) count);
     
    23272327                return;
    23282328        }
    2329        
     2329
    23302330        size_t max_length = (size_t) IPC_GET_ARG2(*call);
    23312331        size_t frame_length = 0;
    23322332        nic_wv_type_t type = NIC_WV_NONE;
    23332333        uint8_t *data = NULL;
    2334        
     2334
    23352335        if (max_length != 0) {
    23362336                data = malloc(max_length);
     
    23402340                }
    23412341        }
    2342        
     2342
    23432343        memset(data, 0, max_length);
    2344        
     2344
    23452345        errno_t rc = nic_iface->wol_load_info(dev, &type, max_length, data,
    23462346            &frame_length);
     
    23542354                        return;
    23552355                }
    2356                
     2356
    23572357                req_length = req_length > max_length ? max_length : req_length;
    23582358                req_length = req_length > frame_length ? frame_length : req_length;
    23592359                async_data_read_finalize(data_callid, data, req_length);
    23602360        }
    2361        
     2361
    23622362        async_answer_2(callid, rc, (sysarg_t) type, (sysarg_t) frame_length);
    23632363        free(data);
     
    23722372                return;
    23732373        }
    2374        
     2374
    23752375        uint32_t supported = 0;
    23762376        uint32_t active = 0;
    2377        
     2377
    23782378        errno_t rc = nic_iface->offload_probe(dev, &supported, &active);
    23792379        async_answer_2(callid, rc, supported, active);
     
    23882388                return;
    23892389        }
    2390        
     2390
    23912391        uint32_t mask = (uint32_t) IPC_GET_ARG2(*call);
    23922392        uint32_t active = (uint32_t) IPC_GET_ARG3(*call);
    2393        
     2393
    23942394        errno_t rc = nic_iface->offload_set(dev, mask, active);
    23952395        async_answer_0(callid, rc);
     
    24042404                return;
    24052405        }
    2406        
     2406
    24072407        nic_poll_mode_t mode = NIC_POLL_IMMEDIATE;
    24082408        int request_data = IPC_GET_ARG2(*call);
     
    24112411                .tv_usec = 0
    24122412        };
    2413        
     2413
    24142414        errno_t rc = nic_iface->poll_get_mode(dev, &mode, &period);
    24152415        if ((rc == EOK) && (request_data)) {
    24162416                size_t max_len;
    24172417                ipc_callid_t data_callid;
    2418                
     2418
    24192419                if (!async_data_read_receive(&data_callid, &max_len)) {
    24202420                        async_answer_0(data_callid, EINVAL);
     
    24222422                        return;
    24232423                }
    2424                
     2424
    24252425                if (max_len != sizeof(struct timeval)) {
    24262426                        async_answer_0(data_callid, ELIMIT);
     
    24282428                        return;
    24292429                }
    2430                
     2430
    24312431                async_data_read_finalize(data_callid, &period,
    24322432                    sizeof(struct timeval));
    24332433        }
    2434        
     2434
    24352435        async_answer_1(callid, rc, (sysarg_t) mode);
    24362436}
     
    24402440{
    24412441        nic_iface_t *nic_iface = (nic_iface_t *) iface;
    2442        
     2442
    24432443        nic_poll_mode_t mode = IPC_GET_ARG2(*call);
    24442444        int has_period = IPC_GET_ARG3(*call);
     
    24462446        struct timeval *period = NULL;
    24472447        size_t length;
    2448        
     2448
    24492449        if (has_period) {
    24502450                ipc_callid_t data_callid;
     
    24542454                        return;
    24552455                }
    2456                
     2456
    24572457                if (length != sizeof(struct timeval)) {
    24582458                        async_answer_0(data_callid, ELIMIT);
     
    24602460                        return;
    24612461                }
    2462                
     2462
    24632463                period = &period_buf;
    24642464                if (async_data_write_finalize(data_callid, period,
     
    24682468                }
    24692469        }
    2470        
     2470
    24712471        if (nic_iface->poll_set_mode != NULL) {
    24722472                errno_t rc = nic_iface->poll_set_mode(dev, mode, period);
     
    24842484                return;
    24852485        }
    2486        
     2486
    24872487        errno_t rc = nic_iface->poll_now(dev);
    24882488        async_answer_0(callid, rc);
  • uspace/lib/drv/generic/remote_pci.c

    r3061bc1 r8565a42  
    5454{
    5555        sysarg_t res = 0;
    56        
     56
    5757        async_exch_t *exch = async_exchange_begin(sess);
    5858        errno_t rc = async_req_2_1(exch, DEV_IFACE_ID(PCI_DEV_IFACE),
    5959            IPC_M_CONFIG_SPACE_READ_8, address, &res);
    6060        async_exchange_end(exch);
    61        
     61
    6262        *val = (uint8_t) res;
    6363        return rc;
     
    6868{
    6969        sysarg_t res = 0;
    70        
     70
    7171        async_exch_t *exch = async_exchange_begin(sess);
    7272        errno_t rc = async_req_2_1(exch, DEV_IFACE_ID(PCI_DEV_IFACE),
    7373            IPC_M_CONFIG_SPACE_READ_16, address, &res);
    7474        async_exchange_end(exch);
    75        
     75
    7676        *val = (uint16_t) res;
    7777        return rc;
     
    8282{
    8383        sysarg_t res = 0;
    84        
     84
    8585        async_exch_t *exch = async_exchange_begin(sess);
    8686        errno_t rc = async_req_2_1(exch, DEV_IFACE_ID(PCI_DEV_IFACE),
    8787            IPC_M_CONFIG_SPACE_READ_32, address, &res);
    8888        async_exchange_end(exch);
    89        
     89
    9090        *val = (uint32_t) res;
    9191        return rc;
     
    9898            IPC_M_CONFIG_SPACE_WRITE_8, address, val);
    9999        async_exchange_end(exch);
    100        
     100
    101101        return rc;
    102102}
     
    109109            IPC_M_CONFIG_SPACE_WRITE_16, address, val);
    110110        async_exchange_end(exch);
    111        
     111
    112112        return rc;
    113113}
     
    120120            IPC_M_CONFIG_SPACE_WRITE_32, address, val);
    121121        async_exchange_end(exch);
    122        
     122
    123123        return rc;
    124124}
  • uspace/lib/drv/generic/remote_pio_window.c

    r3061bc1 r8565a42  
    6262                return;
    6363        }
    64        
     64
    6565        pio_window_t *pio_window = pio_win_ops->get_pio_window(fun);
    6666        if (!pio_window) {
     
    6868                return;
    6969        }
    70        
     70
    7171        async_answer_0(callid, EOK);
    7272
  • uspace/lib/drv/generic/remote_usbdiag.c

    r3061bc1 r8565a42  
    188188                return;
    189189        }
    190        
     190
    191191        if (async_data_read_finalize(data_callid, &results, size) != EOK) {
    192192                async_answer_0(callid, EINVAL);
     
    242242                return;
    243243        }
    244        
     244
    245245        if (async_data_read_finalize(data_callid, &results, size) != EOK) {
    246246                async_answer_0(callid, EINVAL);
  • uspace/lib/drv/generic/remote_usbhid.c

    r3061bc1 r8565a42  
    6767         */
    6868        IPC_M_USBHID_GET_EVENT,
    69        
     69
    7070        /** Get the size of the report descriptor from the HID device.
    7171         *
     
    7878         */
    7979        IPC_M_USBHID_GET_REPORT_DESCRIPTOR_LENGTH,
    80        
     80
    8181        /** Get the report descriptor from the HID device.
    8282         *
     
    101101        if (!dev_sess)
    102102                return EINVAL;
    103        
     103
    104104        async_exch_t *exch = async_exchange_begin(dev_sess);
    105        
     105
    106106        sysarg_t len;
    107107        errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(USBHID_DEV_IFACE),
    108108            IPC_M_USBHID_GET_EVENT_LENGTH, &len);
    109        
     109
    110110        async_exchange_end(exch);
    111        
     111
    112112        if (rc == EOK) {
    113113                if (size != NULL)
    114114                        *size = (size_t) len;
    115115        }
    116        
     116
    117117        return rc;
    118118}
     
    137137        if (!dev_sess)
    138138                return EINVAL;
    139        
     139
    140140        if (buf == NULL)
    141141                return ENOMEM;
    142        
     142
    143143        if (size == 0)
    144144                return EINVAL;
    145        
     145
    146146        size_t buffer_size =  size;
    147147        uint8_t *buffer = malloc(buffer_size);
    148148        if (buffer == NULL)
    149149                return ENOMEM;
    150        
     150
    151151        async_exch_t *exch = async_exchange_begin(dev_sess);
    152        
     152
    153153        ipc_call_t opening_request_call;
    154154        aid_t opening_request = async_send_2(exch,
    155155            DEV_IFACE_ID(USBHID_DEV_IFACE), IPC_M_USBHID_GET_EVENT,
    156156            flags, &opening_request_call);
    157        
     157
    158158        if (opening_request == 0) {
    159159                async_exchange_end(exch);
     
    161161                return ENOMEM;
    162162        }
    163        
     163
    164164        ipc_call_t data_request_call;
    165165        aid_t data_request = async_data_read(exch, buffer, buffer_size,
    166166            &data_request_call);
    167        
     167
    168168        async_exchange_end(exch);
    169        
     169
    170170        if (data_request == 0) {
    171171                async_forget(opening_request);
     
    173173                return ENOMEM;
    174174        }
    175        
     175
    176176        errno_t data_request_rc;
    177177        errno_t opening_request_rc;
    178178        async_wait_for(data_request, &data_request_rc);
    179179        async_wait_for(opening_request, &opening_request_rc);
    180        
     180
    181181        if (data_request_rc != EOK) {
    182182                /* Prefer return code of the opening request. */
     
    186186                        return (errno_t) data_request_rc;
    187187        }
    188        
     188
    189189        if (opening_request_rc != EOK)
    190190                return (errno_t) opening_request_rc;
    191        
     191
    192192        size_t act_size = IPC_GET_ARG2(data_request_call);
    193        
     193
    194194        /* Copy the individual items. */
    195195        memcpy(buf, buffer, act_size);
    196        
     196
    197197        if (actual_size != NULL)
    198198                *actual_size = act_size;
    199        
     199
    200200        if (event_nr != NULL)
    201201                *event_nr = IPC_GET_ARG1(opening_request_call);
    202        
     202
    203203        return EOK;
    204204}
     
    209209        if (!dev_sess)
    210210                return EINVAL;
    211        
     211
    212212        async_exch_t *exch = async_exchange_begin(dev_sess);
    213        
     213
    214214        sysarg_t arg_size;
    215215        errno_t rc = async_req_1_1(exch, DEV_IFACE_ID(USBHID_DEV_IFACE),
    216216            IPC_M_USBHID_GET_REPORT_DESCRIPTOR_LENGTH, &arg_size);
    217        
     217
    218218        async_exchange_end(exch);
    219        
     219
    220220        if (rc == EOK) {
    221221                if (size != NULL)
    222222                        *size = (size_t) arg_size;
    223223        }
    224        
     224
    225225        return rc;
    226226}
     
    231231        if (!dev_sess)
    232232                return EINVAL;
    233        
     233
    234234        if (buf == NULL)
    235235                return ENOMEM;
    236        
     236
    237237        if (size == 0)
    238238                return EINVAL;
    239        
     239
    240240        async_exch_t *exch = async_exchange_begin(dev_sess);
    241        
     241
    242242        aid_t opening_request = async_send_1(exch,
    243243            DEV_IFACE_ID(USBHID_DEV_IFACE), IPC_M_USBHID_GET_REPORT_DESCRIPTOR,
     
    247247                return ENOMEM;
    248248        }
    249        
     249
    250250        ipc_call_t data_request_call;
    251251        aid_t data_request = async_data_read(exch, buf, size,
    252252            &data_request_call);
    253        
     253
    254254        async_exchange_end(exch);
    255        
     255
    256256        if (data_request == 0) {
    257257                async_forget(opening_request);
    258258                return ENOMEM;
    259259        }
    260        
     260
    261261        errno_t data_request_rc;
    262262        errno_t opening_request_rc;
    263263        async_wait_for(data_request, &data_request_rc);
    264264        async_wait_for(opening_request, &opening_request_rc);
    265        
     265
    266266        if (data_request_rc != EOK) {
    267267                /* Prefer return code of the opening request. */
     
    271271                        return (errno_t) data_request_rc;
    272272        }
    273        
     273
    274274        if (opening_request_rc != EOK)
    275275                return (errno_t) opening_request_rc;
    276        
     276
    277277        size_t act_size = IPC_GET_ARG2(data_request_call);
    278        
     278
    279279        if (actual_size != NULL)
    280280                *actual_size = act_size;
    281        
     281
    282282        return EOK;
    283283}
     
    312312{
    313313        printf("remote_usbhid_get_event_length()\n");
    314        
     314
    315315        usbhid_iface_t *hid_iface = (usbhid_iface_t *) iface;
    316316
     
    326326//      }
    327327        async_answer_1(callid, EOK, len);
    328        
     328
    329329//      if (len < 0) {
    330330//              async_answer_0(callid, len);
Note: See TracChangeset for help on using the changeset viewer.