Changeset 7aaed09 in mainline for uspace/lib/usbdev/src/pipes.c


Ignore:
Timestamp:
2011-12-18T14:02:30Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c868e2d
Parents:
3b71e84d (diff), 1761268 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

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

    r3b71e84d r7aaed09  
    5454static usb_address_t get_my_address(async_sess_t *sess, const ddf_dev_t *dev)
    5555{
     56        assert(sess);
    5657        async_exch_t *exch = async_exchange_begin(sess);
    57        
    58         /*
    59          * We are sending special value as a handle - zero - to get
    60          * handle of the parent function (that handle was used
    61          * when registering our device @p dev.
    62          */
    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        
     58        if (!exch)
     59                return ENOMEM;
     60
     61        usb_address_t address;
     62        const int ret = usb_get_my_address(exch, &address);
     63
    6764        async_exchange_end(exch);
    68        
    69         if (rc != EOK)
    70                 return rc;
    71        
    72         return (usb_address_t) address;
     65
     66        return (ret == EOK) ? address : ret;
    7367}
    7468
     
    7670 *
    7771 * @param device Device in question.
    78  * @return Interface number (negative code means any).
     72 * @return Error code (ENOTSUP means any).
    7973 */
    8074int usb_device_get_assigned_interface(const ddf_dev_t *device)
    8175{
     76        assert(device);
    8277        async_sess_t *parent_sess =
    8378            devman_parent_device_connect(EXCHANGE_ATOMIC, device->handle,
    8479            IPC_FLAG_BLOCKING);
    8580        if (!parent_sess)
    86                 return -1;
    87        
     81                return ENOMEM;
     82
    8883        async_exch_t *exch = async_exchange_begin(parent_sess);
    89        
    90         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)
    98                 return -1;
    99        
    100         return (int) iface_no;
     84        if (!exch) {
     85                async_hangup(parent_sess);
     86                return ENOMEM;
     87        }
     88
     89        int iface_no;
     90        const int ret = usb_get_my_interface(exch, &iface_no);
     91
     92        return ret == EOK ? iface_no : ret;
    10193}
    10294
Note: See TracChangeset for help on using the changeset viewer.