Changeset 8565a42 in mainline for uspace/srv/devman/driver.c


Ignore:
Timestamp:
2018-03-02T20:34:50Z (7 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.

File:
1 edited

Legend:

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

    r3061bc1 r8565a42  
    5454{
    5555        assert(drv_list != NULL);
    56        
     56
    5757        list_initialize(&drv_list->drivers);
    5858        fibril_mutex_initialize(&drv_list->drivers_mutex);
     
    112112        log_msg(LOG_DEFAULT, LVL_DEBUG, "get_driver_info(base_path=\"%s\", name=\"%s\")",
    113113            base_path, name);
    114        
     114
    115115        assert(base_path != NULL && name != NULL && drv != NULL);
    116        
     116
    117117        bool suc = false;
    118118        char *match_path = NULL;
    119119        size_t name_size = 0;
    120        
     120
    121121        /* Read the list of match ids from the driver's configuration file. */
    122122        match_path = get_abs_path(base_path, name, MATCH_EXT);
    123123        if (match_path == NULL)
    124124                goto cleanup;
    125        
     125
    126126        if (!read_match_ids(match_path, &drv->match_ids))
    127127                goto cleanup;
    128        
     128
    129129        /* Allocate and fill driver's name. */
    130130        name_size = str_size(name) + 1;
     
    133133                goto cleanup;
    134134        str_cpy(drv->name, name_size, name);
    135        
     135
    136136        /* Initialize path with driver's binary. */
    137137        drv->binary_path = get_abs_path(base_path, name, "");
    138138        if (drv->binary_path == NULL)
    139139                goto cleanup;
    140        
     140
    141141        /* Check whether the driver's binary exists. */
    142142        vfs_stat_t s;
     
    146146                goto cleanup;
    147147        }
    148        
     148
    149149        suc = true;
    150        
     150
    151151cleanup:
    152152        if (!suc) {
     
    156156                init_driver(drv);
    157157        }
    158        
     158
    159159        free(match_path);
    160        
     160
    161161        return suc;
    162162}
     
    171171{
    172172        log_msg(LOG_DEFAULT, LVL_DEBUG, "lookup_available_drivers(dir=\"%s\")", dir_path);
    173        
     173
    174174        int drv_cnt = 0;
    175175        DIR *dir = NULL;
     
    177177
    178178        dir = opendir(dir_path);
    179        
     179
    180180        if (dir != NULL) {
    181181                driver_t *drv = create_driver();
     
    190190                closedir(dir);
    191191        }
    192        
     192
    193193        return drv_cnt;
    194194}
     
    213213        driver_t *best_drv = NULL;
    214214        int best_score = 0, score = 0;
    215        
     215
    216216        fibril_mutex_lock(&drivers_list->drivers_mutex);
    217        
     217
    218218        list_foreach(drivers_list->drivers, drivers, driver_t, drv) {
    219219                score = get_match_score(drv, node);
     
    223223                }
    224224        }
    225        
     225
    226226        fibril_mutex_unlock(&drivers_list->drivers_mutex);
    227        
     227
    228228        return best_drv;
    229229}
     
    239239        log_msg(LOG_DEFAULT, LVL_DEBUG, "attach_driver(dev=\"%s\",drv=\"%s\")",
    240240            dev->pfun->pathname, drv->name);
    241        
     241
    242242        fibril_mutex_lock(&drv->driver_mutex);
    243243        fibril_rwlock_write_lock(&tree->rwlock);
    244        
     244
    245245        dev->drv = drv;
    246246        list_append(&dev->driver_devices, &drv->devices);
    247        
     247
    248248        fibril_rwlock_write_unlock(&tree->rwlock);
    249249        fibril_mutex_unlock(&drv->driver_mutex);
     
    259259{
    260260        driver_t *drv = dev->drv;
    261        
     261
    262262        assert(drv != NULL);
    263        
     263
    264264        log_msg(LOG_DEFAULT, LVL_DEBUG, "detach_driver(dev=\"%s\",drv=\"%s\")",
    265265            dev->pfun->pathname, drv->name);
    266        
     266
    267267        fibril_mutex_lock(&drv->driver_mutex);
    268268        fibril_rwlock_write_lock(&tree->rwlock);
    269        
     269
    270270        dev->drv = NULL;
    271271        list_remove(&dev->driver_devices);
    272        
     272
    273273        fibril_rwlock_write_unlock(&tree->rwlock);
    274274        fibril_mutex_unlock(&drv->driver_mutex);
     
    286286
    287287        assert(fibril_mutex_is_locked(&drv->driver_mutex));
    288        
     288
    289289        log_msg(LOG_DEFAULT, LVL_DEBUG, "start_driver(drv=\"%s\")", drv->name);
    290        
     290
    291291        rc = task_spawnl(NULL, NULL, drv->binary_path, drv->binary_path, NULL);
    292292        if (rc != EOK) {
     
    295295                return false;
    296296        }
    297        
     297
    298298        drv->state = DRIVER_STARTING;
    299299        return true;
     
    310310        async_exch_t *exch;
    311311        errno_t retval;
    312        
     312
    313313        log_msg(LOG_DEFAULT, LVL_DEBUG, "stop_driver(drv=\"%s\")", drv->name);
    314314
     
    316316        retval = async_req_0_0(exch, DRIVER_STOP);
    317317        loc_exchange_end(exch);
    318        
     318
    319319        if (retval != EOK)
    320320                return retval;
    321        
     321
    322322        drv->state = DRIVER_NOT_STARTED;
    323323        async_hangup(drv->sess);
     
    336336{
    337337        driver_t *res = NULL;
    338        
     338
    339339        fibril_mutex_lock(&drv_list->drivers_mutex);
    340        
     340
    341341        list_foreach(drv_list->drivers, drivers, driver_t, drv) {
    342342                if (drv->handle == handle) {
     
    345345                }
    346346        }
    347        
     347
    348348        fibril_mutex_unlock(&drv_list->drivers_mutex);
    349        
     349
    350350        return res;
    351351}
     
    362362{
    363363        driver_t *res = NULL;
    364        
     364
    365365        fibril_mutex_lock(&drv_list->drivers_mutex);
    366        
     366
    367367        list_foreach(drv_list->drivers, drivers, driver_t, drv) {
    368368                if (str_cmp(drv->name, drv_name) == 0) {
     
    371371                }
    372372        }
    373        
     373
    374374        fibril_mutex_unlock(&drv_list->drivers_mutex);
    375        
     375
    376376        return res;
    377377}
     
    399399                dev = list_get_instance(link, dev_node_t, driver_devices);
    400400                fibril_rwlock_write_lock(&tree->rwlock);
    401                
     401
    402402                if (dev->passed_to_driver) {
    403403                        fibril_rwlock_write_unlock(&tree->rwlock);
     
    461461        log_msg(LOG_DEFAULT, LVL_DEBUG, "initialize_running_driver(driver=\"%s\")",
    462462            driver->name);
    463        
     463
    464464        /*
    465465         * Pass devices which have been already assigned to the driver to the
     
    507507{
    508508        assert(drv != NULL);
    509        
     509
    510510        clean_driver(drv);
    511511        free(drv);
     
    525525        assert(drivers_list != NULL);
    526526        assert(tree != NULL);
    527        
     527
    528528        /*
    529529         * Find the driver which is the most suitable for handling this device.
     
    535535                return false;
    536536        }
    537        
     537
    538538        /* Attach the driver to the device. */
    539539        attach_driver(tree, dev, drv);
    540        
     540
    541541        fibril_mutex_lock(&drv->driver_mutex);
    542542        if (drv->state == DRIVER_NOT_STARTED) {
     
    550550        if (is_running)
    551551                add_device(drv, dev, tree);
    552        
     552
    553553        fibril_mutex_lock(&drv->driver_mutex);
    554554        fibril_mutex_unlock(&drv->driver_mutex);
     
    575575        log_msg(LOG_DEFAULT, LVL_DEBUG, "add_device(drv=\"%s\", dev=\"%s\")",
    576576            drv->name, dev->pfun->name);
    577        
     577
    578578        /* Send the device to the driver. */
    579579        devman_handle_t parent_handle;
     
    583583                parent_handle = 0;
    584584        }
    585        
     585
    586586        async_exch_t *exch = async_exchange_begin(drv->sess);
    587        
     587
    588588        ipc_call_t answer;
    589589        aid_t req = async_send_2(exch, DRIVER_DEV_ADD, dev->handle,
    590590            parent_handle, &answer);
    591        
     591
    592592        /* Send the device name to the driver. */
    593593        errno_t rc = async_data_write_start(exch, dev->pfun->name,
    594594            str_size(dev->pfun->name) + 1);
    595        
     595
    596596        async_exchange_end(exch);
    597        
     597
    598598        if (rc != EOK) {
    599599                async_forget(req);
     
    614614                break;
    615615        }
    616        
     616
    617617        dev->passed_to_driver = true;
    618618}
     
    624624        driver_t *drv;
    625625        devman_handle_t handle;
    626        
     626
    627627        assert(dev != NULL);
    628        
     628
    629629        log_msg(LOG_DEFAULT, LVL_DEBUG, "driver_dev_remove(%p)", dev);
    630        
     630
    631631        fibril_rwlock_read_lock(&tree->rwlock);
    632632        drv = dev->drv;
    633633        handle = dev->handle;
    634634        fibril_rwlock_read_unlock(&tree->rwlock);
    635        
     635
    636636        exch = async_exchange_begin(drv->sess);
    637637        retval = async_req_1_0(exch, DRIVER_DEV_REMOVE, handle);
    638638        async_exchange_end(exch);
    639        
     639
    640640        return retval;
    641641}
     
    647647        driver_t *drv;
    648648        devman_handle_t handle;
    649        
     649
    650650        assert(dev != NULL);
    651        
     651
    652652        log_msg(LOG_DEFAULT, LVL_DEBUG, "driver_dev_gone(%p)", dev);
    653        
     653
    654654        fibril_rwlock_read_lock(&tree->rwlock);
    655655        drv = dev->drv;
    656656        handle = dev->handle;
    657657        fibril_rwlock_read_unlock(&tree->rwlock);
    658        
     658
    659659        exch = async_exchange_begin(drv->sess);
    660660        retval = async_req_1_0(exch, DRIVER_DEV_GONE, handle);
    661661        async_exchange_end(exch);
    662        
     662
    663663        return retval;
    664664}
     
    670670        driver_t *drv;
    671671        devman_handle_t handle;
    672        
     672
    673673        log_msg(LOG_DEFAULT, LVL_DEBUG, "driver_fun_online(%p)", fun);
    674674
    675675        fibril_rwlock_read_lock(&tree->rwlock);
    676        
     676
    677677        if (fun->dev == NULL) {
    678678                /* XXX root function? */
     
    680680                return EINVAL;
    681681        }
    682        
     682
    683683        drv = fun->dev->drv;
    684684        handle = fun->handle;
    685685        fibril_rwlock_read_unlock(&tree->rwlock);
    686        
     686
    687687        exch = async_exchange_begin(drv->sess);
    688688        retval = async_req_1_0(exch, DRIVER_FUN_ONLINE, handle);
    689689        loc_exchange_end(exch);
    690        
     690
    691691        return retval;
    692692}
     
    698698        driver_t *drv;
    699699        devman_handle_t handle;
    700        
     700
    701701        log_msg(LOG_DEFAULT, LVL_DEBUG, "driver_fun_offline(%p)", fun);
    702702
     
    707707                return EINVAL;
    708708        }
    709        
     709
    710710        drv = fun->dev->drv;
    711711        handle = fun->handle;
    712712        fibril_rwlock_read_unlock(&tree->rwlock);
    713        
     713
    714714        exch = async_exchange_begin(drv->sess);
    715715        retval = async_req_1_0(exch, DRIVER_FUN_OFFLINE, handle);
    716716        loc_exchange_end(exch);
    717        
     717
    718718        return retval;
    719719
Note: See TracChangeset for help on using the changeset viewer.