Ignore:
File:
1 edited

Legend:

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

    r5aa06ad rc3d9aaf5  
    11/*
    2  * Copyright (c) 2018 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * Copyright (c) 2010 Lenka Trochtova
    44 * All rights reserved.
     
    284284        dev->drv = drv;
    285285        dev->passed_to_driver = false;
    286         dev->state = DEVICE_NOT_INITIALIZED;
     286        fibril_mutex_lock(&dev->state_lock);
     287        dev->state = DEVICE_ATTACHING;
     288        fibril_mutex_unlock(&dev->state_lock);
     289        fibril_condvar_broadcast(&dev->state_cv);
    287290        list_append(&dev->driver_devices, &drv->devices);
    288291
     
    631634void add_device(driver_t *drv, dev_node_t *dev, dev_tree_t *tree)
    632635{
     636        link_t *link;
     637        fun_node_t *fun;
     638
    633639        /*
    634640         * We do not expect to have driver's mutex locked as we do not
     
    664670                async_wait_for(req, &rc);
    665671        }
     672
     673        if (rc == EOK) {
     674                log_msg(LOG_DEFAULT, LVL_DEBUG, "Device was added. Wait for "
     675                    "child functions' devices to stabilize.");
     676                fibril_rwlock_read_lock(&tree->rwlock);
     677                link = list_first(&dev->functions);
     678                while (link != NULL) {
     679                        fun = list_get_instance(link, fun_node_t,
     680                            dev_functions);
     681
     682                        if (fun->child != NULL) {
     683                                log_msg(LOG_DEFAULT, LVL_DEBUG2, "Wait for "
     684                                    "child device %p.", (void *)fun->child);
     685                                fun_add_ref(fun);
     686                                fibril_rwlock_read_unlock(&tree->rwlock);
     687                                dev_wait_stable(fun->child);
     688                                fibril_rwlock_read_lock(&tree->rwlock);
     689                                fun_del_ref(fun);
     690                        }
     691
     692                        link = list_next(link, &dev->functions);
     693                }
     694
     695                fibril_rwlock_read_unlock(&tree->rwlock);
     696                log_msg(LOG_DEFAULT, LVL_DEBUG,
     697                    "Finished waiting for children.");
     698        }
     699
     700        fibril_mutex_lock(&dev->state_lock);
    666701
    667702        switch (rc) {
     
    677712        }
    678713
     714        fibril_mutex_unlock(&dev->state_lock);
     715        fibril_condvar_broadcast(&dev->state_cv);
     716
    679717        dev->passed_to_driver = true;
    680718}
Note: See TracChangeset for help on using the changeset viewer.