Ignore:
File:
1 edited

Legend:

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

    r8a637a4 r8820544  
    5353#include <devman.h>
    5454
     55#include <ipc/driver.h>
     56
    5557#include "dev_iface.h"
    5658#include "ddf/driver.h"
     
    128130       
    129131        char *dev_name = NULL;
    130         int rc = async_data_write_accept((void **) &dev_name, true, 0, 0, 0, 0);
    131         if (rc != EOK) {
    132                 async_answer_0(iid, rc);
    133                 return;
    134         }
    135        
     132        async_data_write_accept((void **) &dev_name, true, 0, 0, 0, 0);
    136133        dev->name = dev_name;
    137134       
     
    281278}
    282279
    283 static void driver_connection_devman(ipc_callid_t iid, ipc_call_t *icall,
    284     void *arg)
     280static void driver_connection_devman(ipc_callid_t iid, ipc_call_t *icall)
    285281{
    286282        /* Accept connection */
     
    440436}
    441437
    442 static void driver_connection_driver(ipc_callid_t iid, ipc_call_t *icall,
    443     void *arg)
     438static void driver_connection_driver(ipc_callid_t iid, ipc_call_t *icall)
    444439{
    445440        driver_connection_gen(iid, icall, true);
    446441}
    447442
    448 static void driver_connection_client(ipc_callid_t iid, ipc_call_t *icall,
    449     void *arg)
     443static void driver_connection_client(ipc_callid_t iid, ipc_call_t *icall)
    450444{
    451445        driver_connection_gen(iid, icall, false);
     446}
     447
     448/** Function for handling connections to device driver. */
     449static void driver_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     450{
     451        sysarg_t conn_type;
     452
     453        if (iid == 0) {
     454                /* Callback connection from devman */
     455                /* XXX Use separate handler for this type of connection */
     456                conn_type = DRIVER_DEVMAN;
     457        } else {
     458                conn_type = IPC_GET_ARG1(*icall);
     459        }
     460
     461        /* Select interface */
     462        switch (conn_type) {
     463        case DRIVER_DEVMAN:
     464                /* Handle request from device manager */
     465                driver_connection_devman(iid, icall);
     466                break;
     467        case DRIVER_DRIVER:
     468                /* Handle request from drivers of child devices */
     469                driver_connection_driver(iid, icall);
     470                break;
     471        case DRIVER_CLIENT:
     472                /* Handle request from client applications */
     473                driver_connection_client(iid, icall);
     474                break;
     475        default:
     476                /* No such interface */
     477                async_answer_0(iid, ENOENT);
     478        }
    452479}
    453480
     
    593620 * The session will be automatically closed when @a dev is destroyed.
    594621 *
    595  * @param dev Device
    596  *
    597  * @return New session or NULL if session could not be created
    598  *
    599  */
    600 async_sess_t *ddf_dev_parent_sess_create(ddf_dev_t *dev)
     622 * @param dev   Device
     623 * @param mgmt  Exchange management style
     624 * @return      New session or NULL if session could not be created
     625 */
     626async_sess_t *ddf_dev_parent_sess_create(ddf_dev_t *dev, exch_mgmt_t mgmt)
    601627{
    602628        assert(dev->parent_sess == NULL);
    603         dev->parent_sess = devman_parent_device_connect(dev->handle,
     629        dev->parent_sess = devman_parent_device_connect(mgmt, dev->handle,
    604630            IPC_FLAG_BLOCKING);
    605631
     
    890916 * This allows handling connections the non-devman way.
    891917 */
    892 void ddf_fun_set_conn_handler(ddf_fun_t *fun, async_port_handler_t conn)
     918void ddf_fun_set_conn_handler(ddf_fun_t *fun, async_client_conn_t conn)
    893919{
    894920        assert(fun->ops == NULL);
     
    929955         * incoming connections.
    930956         */
    931         port_id_t port;
    932         int rc = async_create_port(INTERFACE_DDF_DRIVER, driver_connection_driver,
    933             NULL, &port);
    934         if (rc != EOK)
    935                 return rc;
    936        
    937         rc = async_create_port(INTERFACE_DDF_DEVMAN, driver_connection_devman,
    938             NULL, &port);
    939         if (rc != EOK)
    940                 return rc;
    941        
    942         async_set_fallback_port_handler(driver_connection_client, NULL);
    943        
    944         rc = devman_driver_register(driver->name);
     957        async_set_client_connection(driver_connection);
     958        int rc = devman_driver_register(driver->name);
    945959        if (rc != EOK) {
    946960                printf("Error: Failed to register driver with device manager "
    947                     "(%s).\n", (rc == EEXIST) ? "driver already started" :
     961                    "(%s).\n", (rc == EEXISTS) ? "driver already started" :
    948962                    str_error(rc));
    949963               
Note: See TracChangeset for help on using the changeset viewer.