Changes in / [17279ead:53debe0] in mainline


Ignore:
Location:
uspace
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/driver.c

    r17279ead r53debe0  
    4747#include <stdlib.h>
    4848#include <str.h>
    49 #include <str_error.h>
    5049#include <ctype.h>
    5150#include <errno.h>
     
    656655int ddf_driver_main(driver_t *drv)
    657656{
    658         int rc;
    659 
    660657        /*
    661658         * Remember the driver structure - driver_ops will be called by generic
     
    671668       
    672669        /*
    673          * Register driver with device manager using generic handler for
    674          * incoming connections.
     670         * Register driver by device manager with generic handler for incoming
     671         * connections.
    675672         */
    676         rc = devman_driver_register(driver->name, driver_connection);
    677         if (rc != EOK) {
    678                 printf("Error: Failed to register driver with device manager "
    679                     "(%s).\n", (rc == EEXISTS) ? "driver already started" :
    680                     str_error(rc));
    681                
    682                 return 1;
    683         }
    684        
    685         /* Return success from the task since server has started. */
    686         rc = task_retval(0);
    687         if (rc != EOK)
    688                 return 1;
    689 
     673        devman_driver_register(driver->name, driver_connection);
     674       
    690675        async_manager();
    691676       
  • uspace/srv/devman/devman.c

    r17279ead r53debe0  
    555555}
    556556
     557/** Remember the driver's phone.
     558 *
     559 * @param driver        The driver.
     560 * @param phone         The phone to the driver.
     561 */
     562void set_driver_phone(driver_t *driver, sysarg_t phone)
     563{
     564        fibril_mutex_lock(&driver->driver_mutex);
     565        assert(driver->state == DRIVER_STARTING);
     566        driver->phone = phone;
     567        fibril_mutex_unlock(&driver->driver_mutex);
     568}
     569
    557570/** Notify driver about the devices to which it was assigned.
    558571 *
     
    672685        list_initialize(&drv->devices);
    673686        fibril_mutex_initialize(&drv->driver_mutex);
    674         drv->phone = -1;
    675687}
    676688
  • uspace/srv/devman/devman.h

    r17279ead r53debe0  
    8888       
    8989        /** Phone asociated with this driver. */
    90         int phone;
     90        sysarg_t phone;
    9191        /** Name of the device driver. */
    9292        char *name;
     
    316316
    317317extern driver_t *find_driver(driver_list_t *, const char *);
     318extern void set_driver_phone(driver_t *, sysarg_t);
    318319extern void initialize_running_driver(driver_t *, dev_tree_t *);
    319320
  • uspace/srv/devman/main.c

    r17279ead r53debe0  
    9595        /* Find driver structure. */
    9696        driver = find_driver(&drivers_list, drv_name);
     97       
    9798        if (driver == NULL) {
    9899                log_msg(LVL_ERROR, "No driver named `%s' was found.", drv_name);
     
    106107        drv_name = NULL;
    107108       
    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        
    134109        /* Create connection to the driver. */
    135110        log_msg(LVL_DEBUG, "Creating connection to the `%s' driver.",
     
    138113        ipc_callid_t callid = async_get_call(&call);
    139114        if (IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) {
    140                 fibril_mutex_unlock(&driver->driver_mutex);
    141115                async_answer_0(callid, ENOTSUP);
    142116                async_answer_0(iid, ENOTSUP);
     
    145119       
    146120        /* Remember driver's phone. */
    147         driver->phone = IPC_GET_ARG5(call);
    148        
    149         fibril_mutex_unlock(&driver->driver_mutex);
     121        set_driver_phone(driver, IPC_GET_ARG5(call));
    150122       
    151123        log_msg(LVL_NOTE,
     
    606578                method = DRIVER_CLIENT;
    607579       
    608         if (driver->phone < 0) {
     580        if (driver->phone <= 0) {
    609581                log_msg(LVL_ERROR,
    610582                    "Could not forward to driver `%s' (phone is %d).",
     
    646618        dev = fun->dev;
    647619       
    648         if (dev->state != DEVICE_USABLE || dev->drv->phone < 0) {
     620        if (dev->state != DEVICE_USABLE || dev->drv->phone <= 0) {
    649621                async_answer_0(iid, EINVAL);
    650622                return;
Note: See TracChangeset for help on using the changeset viewer.