Changeset a35b458 in mainline for uspace/srv/devman/main.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/main.c

    r3061bc1 ra35b458  
    7171        devman_handle_t handle = IPC_GET_ARG2(*icall);
    7272        dev_node_t *dev = NULL;
    73        
     73
    7474        fun_node_t *fun = find_fun_node(&device_tree, handle);
    7575        if (fun == NULL) {
     
    7777        } else {
    7878                fibril_rwlock_read_lock(&device_tree.rwlock);
    79                
     79
    8080                dev = fun->dev;
    8181                if (dev != NULL)
    8282                        dev_add_ref(dev);
    83                
     83
    8484                fibril_rwlock_read_unlock(&device_tree.rwlock);
    8585        }
    86        
     86
    8787        /*
    8888         * For a valid function to connect to we need a device. The root
     
    9797                goto cleanup;
    9898        }
    99        
     99
    100100        if (fun == NULL) {
    101101                log_msg(LOG_DEFAULT, LVL_ERROR, NAME ": devman_forward error - cannot "
     
    105105                goto cleanup;
    106106        }
    107        
     107
    108108        fibril_rwlock_read_lock(&device_tree.rwlock);
    109        
     109
    110110        /* Connect to the specified function */
    111111        driver_t *driver = dev->drv;
    112        
     112
    113113        fibril_rwlock_read_unlock(&device_tree.rwlock);
    114        
     114
    115115        if (driver == NULL) {
    116116                log_msg(LOG_DEFAULT, LVL_ERROR, "IPC forwarding refused - " \
     
    119119                goto cleanup;
    120120        }
    121        
     121
    122122        if (!driver->sess) {
    123123                log_msg(LOG_DEFAULT, LVL_ERROR,
     
    126126                goto cleanup;
    127127        }
    128        
     128
    129129        if (fun != NULL) {
    130130                log_msg(LOG_DEFAULT, LVL_DEBUG,
     
    136136                    dev->pfun->pathname, driver->name);
    137137        }
    138        
     138
    139139        async_exch_t *exch = async_exchange_begin(driver->sess);
    140140        async_forward_fast(iid, exch, INTERFACE_DDF_CLIENT, handle, 0, IPC_FF_NONE);
    141141        async_exchange_end(exch);
    142        
     142
    143143cleanup:
    144144        if (dev != NULL)
    145145                dev_del_ref(dev);
    146        
     146
    147147        if (fun != NULL)
    148148                fun_del_ref(fun);
     
    154154        devman_handle_t handle = IPC_GET_ARG2(*icall);
    155155        dev_node_t *dev = NULL;
    156        
     156
    157157        fun_node_t *fun = find_fun_node(&device_tree, handle);
    158158        if (fun == NULL) {
     
    160160        } else {
    161161                fibril_rwlock_read_lock(&device_tree.rwlock);
    162                
     162
    163163                dev = fun->dev;
    164164                if (dev != NULL)
    165165                        dev_add_ref(dev);
    166                
     166
    167167                fibril_rwlock_read_unlock(&device_tree.rwlock);
    168168        }
    169        
     169
    170170        /*
    171171         * For a valid function to connect to we need a device. The root
     
    180180                goto cleanup;
    181181        }
    182        
     182
    183183        driver_t *driver = NULL;
    184        
     184
    185185        fibril_rwlock_read_lock(&device_tree.rwlock);
    186        
     186
    187187        /* Connect to parent function of a device (or device function). */
    188188        if (dev->pfun->dev != NULL)
    189189                driver = dev->pfun->dev->drv;
    190        
     190
    191191        devman_handle_t fun_handle = dev->pfun->handle;
    192        
     192
    193193        fibril_rwlock_read_unlock(&device_tree.rwlock);
    194        
     194
    195195        if (driver == NULL) {
    196196                log_msg(LOG_DEFAULT, LVL_ERROR, "IPC forwarding refused - " \
     
    199199                goto cleanup;
    200200        }
    201        
     201
    202202        if (!driver->sess) {
    203203                log_msg(LOG_DEFAULT, LVL_ERROR,
     
    206206                goto cleanup;
    207207        }
    208        
     208
    209209        if (fun != NULL) {
    210210                log_msg(LOG_DEFAULT, LVL_DEBUG,
     
    216216                    dev->pfun->pathname, driver->name);
    217217        }
    218        
     218
    219219        async_exch_t *exch = async_exchange_begin(driver->sess);
    220220        async_forward_fast(iid, exch, INTERFACE_DDF_DRIVER, fun_handle, 0, IPC_FF_NONE);
    221221        async_exchange_end(exch);
    222        
     222
    223223cleanup:
    224224        if (dev != NULL)
    225225                dev_del_ref(dev);
    226        
     226
    227227        if (fun != NULL)
    228228                fun_del_ref(fun);
     
    233233        iface_t iface = IPC_GET_ARG1(*icall);
    234234        service_id_t service_id = IPC_GET_ARG2(*icall);
    235        
     235
    236236        fun_node_t *fun = find_loc_tree_function(&device_tree, service_id);
    237        
     237
    238238        fibril_rwlock_read_lock(&device_tree.rwlock);
    239        
     239
    240240        if ((fun == NULL) || (fun->dev == NULL) || (fun->dev->drv == NULL)) {
    241241                log_msg(LOG_DEFAULT, LVL_WARN, "devman_forward(): function "
     
    245245                return;
    246246        }
    247        
     247
    248248        dev_node_t *dev = fun->dev;
    249249        driver_t *driver = dev->drv;
    250250        devman_handle_t handle = fun->handle;
    251        
     251
    252252        fibril_rwlock_read_unlock(&device_tree.rwlock);
    253        
     253
    254254        async_exch_t *exch = async_exchange_begin(driver->sess);
    255255        async_forward_fast(iid, exch, iface, handle, 0, IPC_FF_NONE);
    256256        async_exchange_end(exch);
    257        
     257
    258258        log_msg(LOG_DEFAULT, LVL_DEBUG,
    259259            "Forwarding service request for `%s' function to driver `%s'.",
    260260            fun->pathname, driver->name);
    261        
     261
    262262        fun_del_ref(fun);
    263263}
     
    266266{
    267267        client_t *client;
    268        
     268
    269269        client = calloc(1, sizeof(client_t));
    270270        if (client == NULL)
    271271                return NULL;
    272        
     272
    273273        fibril_mutex_initialize(&client->mutex);
    274274        return client;
     
    284284{
    285285        log_msg(LOG_DEFAULT, LVL_DEBUG, "devman_init - looking for available drivers.");
    286        
     286
    287287        /* Initialize list of available drivers. */
    288288        init_driver_list(&drivers_list);
     
    292292                return false;
    293293        }
    294        
     294
    295295        log_msg(LOG_DEFAULT, LVL_DEBUG, "devman_init - list of drivers has been initialized.");
    296        
     296
    297297        /* Create root device node. */
    298298        if (!init_device_tree(&device_tree, &drivers_list)) {
     
    300300                return false;
    301301        }
    302        
     302
    303303        /*
    304304         * Caution: As the device manager is not a real loc
     
    309309         */
    310310        loc_server_register(NAME);
    311        
     311
    312312        return true;
    313313}
     
    316316{
    317317        printf("%s: HelenOS Device Manager\n", NAME);
    318        
     318
    319319        errno_t rc = log_init(NAME);
    320320        if (rc != EOK) {
     
    322322                return rc;
    323323        }
    324        
     324
    325325        /* Set handlers for incoming connections. */
    326326        async_set_client_data_constructor(devman_client_data_create);
    327327        async_set_client_data_destructor(devman_client_data_destroy);
    328        
     328
    329329        port_id_t port;
    330330        rc = async_create_port(INTERFACE_DDF_DRIVER,
     
    334334                return rc;
    335335        }
    336        
     336
    337337        rc = async_create_port(INTERFACE_DDF_CLIENT,
    338338            devman_connection_client, NULL, &port);
     
    341341                return rc;
    342342        }
    343        
     343
    344344        rc = async_create_port(INTERFACE_DEVMAN_DEVICE,
    345345            devman_connection_device, NULL, &port);
     
    348348                return rc;
    349349        }
    350        
     350
    351351        rc = async_create_port(INTERFACE_DEVMAN_PARENT,
    352352            devman_connection_parent, NULL, &port);
     
    355355                return rc;
    356356        }
    357        
     357
    358358        async_set_fallback_port_handler(devman_forward, NULL);
    359        
     359
    360360        if (!devman_init()) {
    361361                log_msg(LOG_DEFAULT, LVL_ERROR, "Error while initializing service.");
    362362                return -1;
    363363        }
    364        
     364
    365365        /* Register device manager at naming service. */
    366366        rc = service_register(SERVICE_DEVMAN);
     
    369369                return rc;
    370370        }
    371        
     371
    372372        printf("%s: Accepting connections.\n", NAME);
    373373        task_retval(0);
    374374        async_manager();
    375        
     375
    376376        /* Never reached. */
    377377        return 0;
Note: See TracChangeset for help on using the changeset viewer.