Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset aae339e9 in mainline


Ignore:
Timestamp:
2010-11-26T12:47:34Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
172c1682
Parents:
0b749a3
Message:

Add method for getting device address to USBHC interface

Location:
uspace/lib
Files:
3 edited

Legend:

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

    r0b749a3 raae339e9  
    4242#define USB_MAX_PAYLOAD_SIZE 1020
    4343
     44static void remote_usbhc_get_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
    4445static void remote_usbhc_get_buffer(device_t *, void *, ipc_callid_t, ipc_call_t *);
    4546static void remote_usbhc_interrupt_out(device_t *, void *, ipc_callid_t, ipc_call_t *);
     
    4950/** Remote USB interface operations. */
    5051static remote_iface_func_ptr_t remote_usbhc_iface_ops [] = {
    51         &remote_usbhc_get_buffer,
    52         &remote_usbhc_interrupt_out,
    53         &remote_usbhc_interrupt_in
     52        remote_usbhc_get_address,
     53        remote_usbhc_get_buffer,
     54        remote_usbhc_interrupt_out,
     55        remote_usbhc_interrupt_in
    5456};
    5557
     
    6870} async_transaction_t;
    6971
     72void remote_usbhc_get_address(device_t *device, void *iface,
     73    ipc_callid_t callid, ipc_call_t *call)
     74{
     75        usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
     76
     77        if (!usb_iface->tell_address) {
     78                ipc_answer_0(callid, ENOTSUP);
     79                return;
     80        }
     81
     82        devman_handle_t handle = IPC_GET_ARG1(*call);
     83
     84        usb_address_t address;
     85        int rc = usb_iface->tell_address(device, handle, &address);
     86        if (rc != EOK) {
     87                ipc_answer_0(callid, rc);
     88        } else {
     89                ipc_answer_1(callid, EOK, address);
     90        }
     91}
    7092
    7193void remote_usbhc_get_buffer(device_t *device, void *iface,
  • uspace/lib/drv/include/usbhc_iface.h

    r0b749a3 raae339e9  
    9292 */
    9393typedef enum {
     94        /** Tell USB address assigned to device.
     95         * Parameters:
     96         * - devman handle id
     97         * Answer:
     98         * - EINVAL - unknown handle or handle not managed by this driver
     99         * - ENOTSUP - operation not supported by HC (shall not happen)
     100         * - arbitrary error code if returned by remote implementation
     101         * - EOK - handle found, first parameter contains the USB address
     102         */
     103        IPC_M_USBHC_GET_ADDRESS,
     104
    94105        /** Asks for data buffer.
    95106         * See explanation at usb_iface_funcs_t.
     
    157168/** USB devices communication interface. */
    158169typedef struct {
     170        int (*tell_address)(device_t *, devman_handle_t, usb_address_t *);
    159171        int (*interrupt_out)(device_t *, usb_target_t,
    160172            void *, size_t,
  • uspace/lib/usb/src/usbdrv.c

    r0b749a3 raae339e9  
    7575usb_address_t usb_drv_get_my_address(int phone, device_t *dev)
    7676{
    77         return ENOTSUP;
     77        ipcarg_t address;
     78        int rc = async_req_1_1(phone, IPC_M_USBHC_GET_ADDRESS,
     79            dev->handle, &address);
     80
     81        if (rc != EOK) {
     82                return rc;
     83        }
     84
     85        return (usb_address_t) address;
    7886}
    7987
Note: See TracChangeset for help on using the changeset viewer.