Changeset 5e718d9 in mainline for uspace/srv/devman/main.c


Ignore:
Timestamp:
2012-08-21T10:04:16Z (12 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
67edca6
Parents:
0da6c04 (diff), 6a97f2e (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.
Message:

Merge with upstream (lp:~wtachi/helenos/bithenge)

File:
1 edited

Legend:

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

    r0da6c04 r5e718d9  
    432432       
    433433        fun_node_t *fun = create_fun_node();
     434        /* One reference for creation, one for us */
     435        fun_add_ref(fun);
    434436        fun_add_ref(fun);
    435437        fun->ftype = ftype;
     438       
     439        /*
     440         * We can lock the function here even when holding the tree because
     441         * we know it cannot be held by anyone else yet.
     442         */
     443        fun_busy_lock(fun);
    436444       
    437445        if (!insert_fun_node(&device_tree, fun, fun_name, pdev)) {
    438446                fibril_rwlock_write_unlock(&tree->rwlock);
    439447                dev_del_ref(pdev);
     448                fun_busy_unlock(fun);
     449                fun_del_ref(fun);
    440450                delete_fun_node(fun);
    441451                async_answer_0(callid, ENOMEM);
     
    450460        rc = online_function(fun);
    451461        if (rc != EOK) {
    452                 /* XXX clean up */
     462                /* XXX Set some failed state? */
     463                fun_busy_unlock(fun);
     464                fun_del_ref(fun);
    453465                async_answer_0(callid, rc);
    454466                return;
    455467        }
     468       
     469        fun_busy_unlock(fun);
     470        fun_del_ref(fun);
    456471       
    457472        /* Return device handle to parent's driver. */
     
    522537        }
    523538       
     539        fun_busy_lock(fun);
     540       
    524541        fibril_rwlock_read_lock(&device_tree.rwlock);
    525542        if (fun->dev == NULL || fun->dev->drv != drv) {
    526543                fibril_rwlock_read_unlock(&device_tree.rwlock);
     544                fun_busy_unlock(fun);
    527545                fun_del_ref(fun);
    528546                async_answer_0(iid, ENOENT);
     
    533551        rc = online_function(fun);
    534552        if (rc != EOK) {
     553                fun_busy_unlock(fun);
    535554                fun_del_ref(fun);
    536555                async_answer_0(iid, (sysarg_t) rc);
     
    538557        }
    539558       
     559        fun_busy_unlock(fun);
    540560        fun_del_ref(fun);
    541561       
     
    559579        }
    560580       
     581        fun_busy_lock(fun);
     582       
    561583        fibril_rwlock_write_lock(&device_tree.rwlock);
    562584        if (fun->dev == NULL || fun->dev->drv != drv) {
     585                fun_busy_unlock(fun);
    563586                fun_del_ref(fun);
    564587                async_answer_0(iid, ENOENT);
     
    569592        rc = offline_function(fun);
    570593        if (rc != EOK) {
     594                fun_busy_unlock(fun);
    571595                fun_del_ref(fun);
    572596                async_answer_0(iid, (sysarg_t) rc);
     
    574598        }
    575599       
     600        fun_busy_unlock(fun);
    576601        fun_del_ref(fun);
    577602        async_answer_0(iid, (sysarg_t) EOK);
     
    591616        }
    592617       
     618        fun_busy_lock(fun);
     619       
    593620        fibril_rwlock_write_lock(&tree->rwlock);
    594621       
     
    598625        if (fun->state == FUN_REMOVED) {
    599626                fibril_rwlock_write_unlock(&tree->rwlock);
     627                fun_busy_unlock(fun);
     628                fun_del_ref(fun);
    600629                async_answer_0(callid, ENOENT);
    601630                return;
     
    638667                                if (gone_rc == EOK)
    639668                                        gone_rc = ENOTSUP;
     669                                fun_busy_unlock(fun);
     670                                fun_del_ref(fun);
    640671                                async_answer_0(callid, gone_rc);
    641672                                return;
     
    664695                                    "service.");
    665696                                fibril_rwlock_write_unlock(&tree->rwlock);
     697                                fun_busy_unlock(fun);
    666698                                fun_del_ref(fun);
    667699                                async_answer_0(callid, EIO);
     
    673705        remove_fun_node(&device_tree, fun);
    674706        fibril_rwlock_write_unlock(&tree->rwlock);
     707        fun_busy_unlock(fun);
    675708       
    676709        /* Delete ref added when inserting function into tree */
Note: See TracChangeset for help on using the changeset viewer.