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


Ignore:
Timestamp:
2011-04-14T08:24:29Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5e07e2b5
Parents:
3f2af64 (diff), 34e8bab (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 development/ changes

File:
1 edited

Legend:

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

    r3f2af64 rd8b275d  
    9595        /* Find driver structure. */
    9696        driver = find_driver(&drivers_list, drv_name);
    97        
    9897        if (driver == NULL) {
    9998                log_msg(LVL_ERROR, "No driver named `%s' was found.", drv_name);
     
    107106        drv_name = NULL;
    108107       
     108        fibril_mutex_lock(&driver->driver_mutex);
     109       
     110        if (driver->phone >= 0) {
     111                /* We already have a connection to the driver. */
     112                log_msg(LVL_ERROR, "Driver '%s' already started.\n",
     113                    driver->name);
     114                fibril_mutex_unlock(&driver->driver_mutex);
     115                async_answer_0(iid, EEXISTS);
     116                return NULL;
     117        }
     118       
     119        switch (driver->state) {
     120        case DRIVER_NOT_STARTED:
     121                /* Somebody started the driver manually. */
     122                log_msg(LVL_NOTE, "Driver '%s' started manually.\n",
     123                    driver->name);
     124                driver->state = DRIVER_STARTING;
     125                break;
     126        case DRIVER_STARTING:
     127                /* The expected case */
     128                break;
     129        case DRIVER_RUNNING:
     130                /* Should not happen since we do not have a connected phone */
     131                assert(false);
     132        }
     133       
    109134        /* Create connection to the driver. */
    110135        log_msg(LVL_DEBUG, "Creating connection to the `%s' driver.",
     
    113138        ipc_callid_t callid = async_get_call(&call);
    114139        if (IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) {
     140                fibril_mutex_unlock(&driver->driver_mutex);
    115141                async_answer_0(callid, ENOTSUP);
    116142                async_answer_0(iid, ENOTSUP);
     
    119145       
    120146        /* Remember driver's phone. */
    121         set_driver_phone(driver, IPC_GET_ARG5(call));
     147        driver->phone = IPC_GET_ARG5(call);
     148       
     149        fibril_mutex_unlock(&driver->driver_mutex);
    122150       
    123151        log_msg(LVL_NOTE,
     
    579607                method = DRIVER_CLIENT;
    580608       
    581         if (driver->phone <= 0) {
     609        if (driver->phone < 0) {
    582610                log_msg(LVL_ERROR,
    583611                    "Could not forward to driver `%s' (phone is %d).",
     
    619647        dev = fun->dev;
    620648       
    621         if (dev->state != DEVICE_USABLE || dev->drv->phone <= 0) {
     649        if (dev->state != DEVICE_USABLE || dev->drv->phone < 0) {
    622650                async_answer_0(iid, EINVAL);
    623651                return;
Note: See TracChangeset for help on using the changeset viewer.