Ignore:
File:
1 edited

Legend:

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

    r00b6c73 r8869f7b  
    3838#include <ddf/driver.h>
    3939#include <usbvirt/ipc.h>
     40#include <async.h>
    4041#include "conn.h"
    4142
     
    4849 * @warning Errors are silently ignored.
    4950 *
    50  * @param phone Phone to the virtual device.
     51 * @param sess Session to the virtual device.
     52 *
    5153 */
    52 static void receive_device_name(int phone)
     54static void receive_device_name(async_sess_t *sess)
    5355{
    54         aid_t opening_request = async_send_0(phone, IPC_M_USBVIRT_GET_NAME, NULL);
     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);
    5559        if (opening_request == 0) {
     60                async_exchange_end(exch);
    5661                return;
    5762        }
    58 
    59 
     63       
    6064        ipc_call_t data_request_call;
    61         aid_t data_request = async_data_read(phone,
    62              plugged_device_name, PLUGGED_DEVICE_NAME_MAXLEN,
    63              &data_request_call);
    64 
     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       
    6570        if (data_request == 0) {
    6671                async_wait_for(opening_request, NULL);
    6772                return;
    6873        }
    69 
     74       
    7075        sysarg_t data_request_rc;
    7176        sysarg_t opening_request_rc;
    7277        async_wait_for(data_request, &data_request_rc);
    7378        async_wait_for(opening_request, &opening_request_rc);
    74 
    75         if ((data_request_rc != EOK) || (opening_request_rc != EOK)) {
     79       
     80        if ((data_request_rc != EOK) || (opening_request_rc != EOK))
    7681                return;
    77         }
    78 
     82       
    7983        size_t len = IPC_GET_ARG2(data_request_call);
    8084        plugged_device_name[len] = 0;
     
    8791 * @param icall Call data.
    8892 */
    89 void default_connection_handler(ddf_fun_t *fun,
    90     ipc_callid_t icallid, ipc_call_t *icall)
     93void default_connection_handler(ddf_fun_t *fun, ipc_callid_t icallid,
     94    ipc_call_t *icall)
    9195{
    9296        vhc_data_t *vhc = fun->dev->driver_data;
    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);
     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);
    99103                if (rc != EOK) {
    100104                        async_answer_0(icallid, rc);
     
    102106                        return;
    103107                }
    104 
     108               
    105109                async_answer_0(icallid, EOK);
    106 
     110               
    107111                receive_device_name(callback);
    108 
     112               
    109113                usb_log_info("New virtual device `%s' (id: %" PRIxn ").\n",
    110114                    plugged_device_name, plugged_device_handle);
    111 
    112                 return;
    113         }
    114 
    115         async_answer_0(icallid, EINVAL);
     115        } else
     116                async_answer_0(icallid, EINVAL);
    116117}
    117118
Note: See TracChangeset for help on using the changeset viewer.