Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/vhc/conndev.c

    r8869f7b r00b6c73  
    3838#include <ddf/driver.h>
    3939#include <usbvirt/ipc.h>
    40 #include <async.h>
    4140#include "conn.h"
    4241
     
    4948 * @warning Errors are silently ignored.
    5049 *
    51  * @param sess Session to the virtual device.
    52  *
     50 * @param phone Phone to the virtual device.
    5351 */
    54 static void receive_device_name(async_sess_t *sess)
     52static void receive_device_name(int phone)
    5553{
    56         async_exch_t *exch = async_exchange_begin(sess);
    57        
    58         aid_t opening_request = async_send_0(exch, IPC_M_USBVIRT_GET_NAME, NULL);
     54        aid_t opening_request = async_send_0(phone, IPC_M_USBVIRT_GET_NAME, NULL);
    5955        if (opening_request == 0) {
    60                 async_exchange_end(exch);
    6156                return;
    6257        }
    63        
     58
     59
    6460        ipc_call_t data_request_call;
    65         aid_t data_request = async_data_read(exch, plugged_device_name,
    66              PLUGGED_DEVICE_NAME_MAXLEN, &data_request_call);
    67        
    68         async_exchange_end(exch);
    69        
     61        aid_t data_request = async_data_read(phone,
     62             plugged_device_name, PLUGGED_DEVICE_NAME_MAXLEN,
     63             &data_request_call);
     64
    7065        if (data_request == 0) {
    7166                async_wait_for(opening_request, NULL);
    7267                return;
    7368        }
    74        
     69
    7570        sysarg_t data_request_rc;
    7671        sysarg_t opening_request_rc;
    7772        async_wait_for(data_request, &data_request_rc);
    7873        async_wait_for(opening_request, &opening_request_rc);
    79        
    80         if ((data_request_rc != EOK) || (opening_request_rc != EOK))
     74
     75        if ((data_request_rc != EOK) || (opening_request_rc != EOK)) {
    8176                return;
    82        
     77        }
     78
    8379        size_t len = IPC_GET_ARG2(data_request_call);
    8480        plugged_device_name[len] = 0;
     
    9187 * @param icall Call data.
    9288 */
    93 void default_connection_handler(ddf_fun_t *fun, ipc_callid_t icallid,
    94     ipc_call_t *icall)
     89void default_connection_handler(ddf_fun_t *fun,
     90    ipc_callid_t icallid, ipc_call_t *icall)
    9591{
    9692        vhc_data_t *vhc = fun->dev->driver_data;
    97        
    98         async_sess_t *callback =
    99             async_callback_receive_start(EXCHANGE_SERIALIZE, icall);
    100        
    101         if (callback) {
    102                 int rc = vhc_virtdev_plug(vhc, callback, &plugged_device_handle);
     93        sysarg_t method = IPC_GET_IMETHOD(*icall);
     94
     95        if (method == IPC_M_CONNECT_TO_ME) {
     96                int callback = IPC_GET_ARG5(*icall);
     97                int rc = vhc_virtdev_plug(vhc, callback,
     98                    &plugged_device_handle);
    10399                if (rc != EOK) {
    104100                        async_answer_0(icallid, rc);
     
    106102                        return;
    107103                }
    108                
     104
    109105                async_answer_0(icallid, EOK);
    110                
     106
    111107                receive_device_name(callback);
    112                
     108
    113109                usb_log_info("New virtual device `%s' (id: %" PRIxn ").\n",
    114110                    plugged_device_name, plugged_device_handle);
    115         } else
    116                 async_answer_0(icallid, EINVAL);
     111
     112                return;
     113        }
     114
     115        async_answer_0(icallid, EINVAL);
    117116}
    118117
Note: See TracChangeset for help on using the changeset viewer.