Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/src/pipes.c

    r79ae36dd re8f826b  
    4848/** Tell USB address assigned to given device.
    4949 *
    50  * @param sess Session to parent device.
     50 * @param phone Phone to parent device.
    5151 * @param dev Device in question.
    5252 * @return USB address or error code.
    5353 */
    54 static usb_address_t get_my_address(async_sess_t *sess, ddf_dev_t *dev)
    55 {
    56         async_exch_t *exch = async_exchange_begin(sess);
    57        
     54static usb_address_t get_my_address(int phone, ddf_dev_t *dev)
     55{
     56        sysarg_t address;
     57
    5858        /*
    5959         * We are sending special value as a handle - zero - to get
     
    6161         * when registering our device @p dev.
    6262         */
    63         sysarg_t address;
    64         int rc = async_req_2_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
    65             IPC_M_USB_GET_ADDRESS, 0, &address);
    66        
    67         async_exchange_end(exch);
    68        
    69         if (rc != EOK)
     63        int rc = async_req_2_1(phone, DEV_IFACE_ID(USB_DEV_IFACE),
     64            IPC_M_USB_GET_ADDRESS,
     65            0, &address);
     66
     67        if (rc != EOK) {
    7068                return rc;
    71        
     69        }
     70
    7271        return (usb_address_t) address;
    7372}
     
    8079int usb_device_get_assigned_interface(ddf_dev_t *device)
    8180{
    82         async_sess_t *parent_sess =
    83             devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle,
     81        int parent_phone = devman_parent_device_connect(device->handle,
    8482            IPC_FLAG_BLOCKING);
    85         if (!parent_sess)
     83        if (parent_phone < 0) {
    8684                return -1;
    87        
    88         async_exch_t *exch = async_exchange_begin(parent_sess);
    89        
     85        }
     86
    9087        sysarg_t iface_no;
    91         int rc = async_req_2_1(exch, DEV_IFACE_ID(USB_DEV_IFACE),
    92             IPC_M_USB_GET_INTERFACE, device->handle, &iface_no);
    93        
    94         async_exchange_end(exch);
    95         async_hangup(parent_sess);
    96        
    97         if (rc != EOK)
     88        int rc = async_req_2_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
     89            IPC_M_USB_GET_INTERFACE,
     90            device->handle, &iface_no);
     91
     92        async_hangup(parent_phone);
     93
     94        if (rc != EOK) {
    9895                return -1;
    99        
     96        }
     97
    10098        return (int) iface_no;
    10199}
     
    112110        assert(connection);
    113111        assert(dev);
    114        
     112
    115113        int rc;
    116114        devman_handle_t hc_handle;
    117115        usb_address_t my_address;
    118        
     116
    119117        rc = usb_hc_find(dev->handle, &hc_handle);
    120         if (rc != EOK)
     118        if (rc != EOK) {
    121119                return rc;
    122        
    123         async_sess_t *parent_sess =
    124             devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle,
     120        }
     121
     122        int parent_phone = devman_parent_device_connect(dev->handle,
    125123            IPC_FLAG_BLOCKING);
    126         if (!parent_sess)
    127                 return ENOMEM;
    128        
     124        if (parent_phone < 0) {
     125                return parent_phone;
     126        }
     127
    129128        /*
    130129         * Asking for "my" address may require several attempts.
     
    138137         *  So, we need to wait for the HC to learn the binding.
    139138         */
    140        
    141139        do {
    142                 my_address = get_my_address(parent_sess, dev);
    143                
     140                my_address = get_my_address(parent_phone, dev);
     141
    144142                if (my_address == ENOENT) {
    145143                        /* Be nice, let other fibrils run and try again. */
     
    150148                        goto leave;
    151149                }
    152        
     150
    153151        } while (my_address < 0);
    154        
     152
    155153        rc = usb_device_connection_initialize(connection,
    156154            hc_handle, my_address);
    157        
     155
    158156leave:
    159         async_hangup(parent_sess);
     157        async_hangup(parent_phone);
    160158        return rc;
    161159}
Note: See TracChangeset for help on using the changeset viewer.