Changes in / [7b6f116:60b3bea] in mainline


Ignore:
Location:
uspace
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/lsusb/main.c

    r7b6f116 r60b3bea  
    4444#include <devman.h>
    4545#include <devmap.h>
    46 #include <usb/hub.h>
    4746#include <usb/host.h>
    4847
    4948#define NAME "lsusb"
    5049
    51 #define MAX_FAILED_ATTEMPTS 10
     50#define MAX_FAILED_ATTEMPTS 4
    5251#define MAX_PATH_LENGTH 1024
    53 
    54 static void print_found_hc(size_t class_index, const char *path)
    55 {
    56         // printf(NAME ": host controller %zu is `%s'.\n", class_index, path);
    57         printf("Bus %02zu: %s\n", class_index, path);
    58 }
    59 static void print_found_dev(usb_address_t addr, const char *path)
    60 {
    61         // printf(NAME ":     device with address %d is `%s'.\n", addr, path);
    62         printf("  Device %02d: %s\n", addr, path);
    63 }
    64 
    65 static void print_hc_devices(devman_handle_t hc_handle)
    66 {
    67         int rc;
    68         usb_hc_connection_t conn;
    69 
    70         usb_hc_connection_initialize(&conn, hc_handle);
    71         rc = usb_hc_connection_open(&conn);
    72         if (rc != EOK) {
    73                 printf(NAME ": failed to connect to HC: %s.\n",
    74                     str_error(rc));
    75                 return;
    76         }
    77         usb_address_t addr;
    78         for (addr = 1; addr < 5; addr++) {
    79                 devman_handle_t dev_handle;
    80                 rc = usb_hc_get_handle_by_address(&conn, addr, &dev_handle);
    81                 if (rc != EOK) {
    82                         continue;
    83                 }
    84                 char path[MAX_PATH_LENGTH];
    85                 rc = devman_get_device_path(dev_handle, path, MAX_PATH_LENGTH);
    86                 if (rc != EOK) {
    87                         continue;
    88                 }
    89                 print_found_dev(addr, path);
    90         }
    91         usb_hc_connection_close(&conn);
    92 }
    9352
    9453int main(int argc, char *argv[])
     
    11069                        continue;
    11170                }
    112                 print_found_hc(class_index, path);
    113                 print_hc_devices(hc_handle);
     71                printf(NAME ": host controller %zu is `%s'.\n",
     72                    class_index, path);
    11473        }
    11574
  • uspace/drv/ehci-hcd/hc_iface.c

    r7b6f116 r60b3bea  
    106106}
    107107
    108 /** Find device handle by USB address.
    109  *
    110  * @param[in] fun DDF function that was called.
    111  * @param[in] address Address in question.
    112  * @param[out] handle Where to store device handle if found.
    113  * @return Error code.
    114  */
    115 static int find_by_address(ddf_fun_t *fun, usb_address_t address,
    116     devman_handle_t *handle)
    117 {
    118         UNSUPPORTED("find_by_address");
    119 
    120         return ENOTSUP;
    121 }
    122 
    123108/** Release previously requested address.
    124109 *
     
    336321        .request_address = request_address,
    337322        .bind_address = bind_address,
    338         .find_by_address = find_by_address,
    339323        .release_address = release_address,
    340324
  • uspace/drv/ohci/iface.c

    r7b6f116 r60b3bea  
    122122        return EOK;
    123123}
    124 
    125 
    126 /** Find device handle by address interface function.
    127  *
    128  * @param[in] fun DDF function that was called.
    129  * @param[in] address Address in question.
    130  * @param[out] handle Where to store device handle if found.
    131  * @return Error code.
    132  */
    133 static int find_by_address(ddf_fun_t *fun, usb_address_t address,
    134     devman_handle_t *handle)
    135 {
    136         assert(fun);
    137         hc_t *hc = fun_to_hc(fun);
    138         assert(hc);
    139         bool found =
    140             usb_device_keeper_find_by_address(&hc->manager, address, handle);
    141         return found ? EOK : ENOENT;
    142 }
    143 
    144124/*----------------------------------------------------------------------------*/
    145125/** Release address interface function
     
    422402        .request_address = request_address,
    423403        .bind_address = bind_address,
    424         .find_by_address = find_by_address,
    425404        .release_address = release_address,
    426405
  • uspace/drv/uhci-hcd/iface.c

    r7b6f116 r60b3bea  
    122122        return EOK;
    123123}
    124 
    125 /** Find device handle by address interface function.
    126  *
    127  * @param[in] fun DDF function that was called.
    128  * @param[in] address Address in question.
    129  * @param[out] handle Where to store device handle if found.
    130  * @return Error code.
    131  */
    132 static int find_by_address(ddf_fun_t *fun, usb_address_t address,
    133     devman_handle_t *handle)
    134 {
    135         assert(fun);
    136         hc_t *hc = fun_to_hc(fun);
    137         assert(hc);
    138         bool found =
    139             usb_device_keeper_find_by_address(&hc->manager, address, handle);
    140         return found ? EOK : ENOENT;
    141 }
    142 
    143124/*----------------------------------------------------------------------------*/
    144125/** Release address interface function
     
    371352        .request_address = request_address,
    372353        .bind_address = bind_address,
    373         .find_by_address = find_by_address,
    374354        .release_address = release_address,
    375355
  • uspace/drv/vhc/connhost.c

    r7b6f116 r60b3bea  
    9494}
    9595
    96 /** Find device handle by address interface function.
    97  *
    98  * @param[in] fun DDF function that was called.
    99  * @param[in] address Address in question.
    100  * @param[out] handle Where to store device handle if found.
    101  * @return Error code.
    102  */
    103 static int find_by_address(ddf_fun_t *fun, usb_address_t address,
    104     devman_handle_t *handle)
    105 {
    106         VHC_DATA(vhc, fun);
    107         bool found =
    108             usb_device_keeper_find_by_address(&vhc->dev_keeper, address, handle);
    109         return found ? EOK : ENOENT;
    110 }
    111 
    11296/** Release previously requested address.
    11397 *
     
    460444        .request_address = request_address,
    461445        .bind_address = bind_address,
    462         .find_by_address = find_by_address,
    463446        .release_address = release_address,
    464447
  • uspace/lib/drv/generic/remote_usbhc.c

    r7b6f116 r60b3bea  
    5252static void remote_usbhc_request_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    5353static void remote_usbhc_bind_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    54 static void remote_usbhc_find_by_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    5554static void remote_usbhc_release_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    5655static void remote_usbhc_register_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     
    6261        remote_usbhc_request_address,
    6362        remote_usbhc_bind_address,
    64         remote_usbhc_find_by_address,
    6563        remote_usbhc_release_address,
    6664
     
    163161
    164162        async_answer_0(callid, rc);
    165 }
    166 
    167 void remote_usbhc_find_by_address(ddf_fun_t *fun, void *iface,
    168     ipc_callid_t callid, ipc_call_t *call)
    169 {
    170         usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
    171 
    172         if (!usb_iface->find_by_address) {
    173                 async_answer_0(callid, ENOTSUP);
    174                 return;
    175         }
    176 
    177         usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call);
    178         devman_handle_t handle;
    179         int rc = usb_iface->find_by_address(fun, address, &handle);
    180 
    181         if (rc == EOK) {
    182                 async_answer_1(callid, EOK, handle);
    183         } else {
    184                 async_answer_0(callid, rc);
    185         }
    186163}
    187164
  • uspace/lib/drv/include/usb_iface.h

    r7b6f116 r60b3bea  
    4949         * - arbitrary error code if returned by remote implementation
    5050         * - EOK - handle found, first parameter contains the USB address
    51          *
    52          * The handle must be the one used for binding USB address with
    53          * it (IPC_M_USBHC_BIND_ADDRESS), otherwise the host controller
    54          * (that this request would eventually reach) would not be able
    55          * to find it.
    56          * The problem is that this handle is actually assigned to the
    57          * function inside driver of the parent device (usually hub driver).
    58          * To bypass this problem, the initial caller specify handle as
    59          * zero and the first parent assigns the actual value.
    60          * See usb_iface_get_address_hub_child_impl() implementation
    61          * that could be assigned to device ops of a child device of in a
    62          * hub driver.
    63          * For example, the USB multi interface device driver (MID)
    64          * passes this initial zero without any modification because the
    65          * handle must be resolved by its parent.
    6651         */
    6752        IPC_M_USB_GET_ADDRESS,
  • uspace/lib/drv/include/usbhc_iface.h

    r7b6f116 r60b3bea  
    105105        IPC_M_USBHC_BIND_ADDRESS,
    106106
    107         /** Get handle binded with given USB address.
    108          * Parameters
    109          * - USB address
    110          * Answer:
    111          * - EOK - address binded, first parameter is the devman handle
    112          * - ENOENT - address is not in use at the moment
    113          */
    114         IPC_M_USBHC_GET_HANDLE_BY_ADDRESS,
    115 
    116107        /** Release address in use.
    117108         * Arguments:
     
    216207        int (*request_address)(ddf_fun_t *, usb_speed_t, usb_address_t *);
    217208        int (*bind_address)(ddf_fun_t *, usb_address_t, devman_handle_t);
    218         int (*find_by_address)(ddf_fun_t *, usb_address_t, devman_handle_t *);
    219209        int (*release_address)(ddf_fun_t *, usb_address_t);
    220210
  • uspace/lib/usb/include/usb/host/device_keeper.h

    r7b6f116 r60b3bea  
    8080    devman_handle_t handle);
    8181
    82 bool usb_device_keeper_find_by_address(usb_device_keeper_t *instance,
    83     usb_address_t address, devman_handle_t *handle);
    84 
    8582usb_speed_t usb_device_keeper_get_speed(usb_device_keeper_t *instance,
    8683    usb_address_t address);
  • uspace/lib/usb/include/usb/hub.h

    r7b6f116 r60b3bea  
    6363    const usb_hc_attached_device_t *);
    6464int usb_hc_unregister_device(usb_hc_connection_t *, usb_address_t);
    65 int usb_hc_get_handle_by_address(usb_hc_connection_t *, usb_address_t,
    66     devman_handle_t *);
    6765
    6866#endif
  • uspace/lib/usb/src/host/device_keeper.c

    r7b6f116 r60b3bea  
    157157        return ENOENT;
    158158}
    159 
    160 /** Find devman handled assigned to USB address.
    161  *
    162  * @param[in] instance Device keeper structure to use.
    163  * @param[in] address Address the caller wants to find.
    164  * @param[out] handle Where to store found handle.
    165  * @return Whether such address is currently occupied.
    166  */
    167 bool usb_device_keeper_find_by_address(usb_device_keeper_t *instance,
    168     usb_address_t address, devman_handle_t *handle)
    169 {
    170         assert(instance);
    171         fibril_mutex_lock(&instance->guard);
    172         if ((address < 0) || (address >= USB_ADDRESS_COUNT)) {
    173                 fibril_mutex_unlock(&instance->guard);
    174                 return false;
    175         }
    176         if (!instance->devices[address].occupied) {
    177                 fibril_mutex_unlock(&instance->guard);
    178                 return false;
    179         }
    180 
    181         if (handle != NULL) {
    182                 *handle = instance->devices[address].handle;
    183         }
    184 
    185         fibril_mutex_unlock(&instance->guard);
    186         return true;
    187 }
    188 
    189159/*----------------------------------------------------------------------------*/
    190160/** Get speed associated with the address
  • uspace/lib/usb/src/hub.c

    r7b6f116 r60b3bea  
    117117            DEV_IFACE_ID(USBHC_DEV_IFACE),
    118118            IPC_M_USBHC_RELEASE_ADDRESS, address);
    119 }
    120 
    121 /** Get handle of USB device with given address.
    122  *
    123  * @param[in] connection Opened connection to host controller.
    124  * @param[in] address Address of device in question.
    125  * @param[out] handle Where to write the device handle.
    126  * @return Error code.
    127  */
    128 int usb_hc_get_handle_by_address(usb_hc_connection_t *connection,
    129     usb_address_t address, devman_handle_t *handle)
    130 {
    131         CHECK_CONNECTION(connection);
    132 
    133         sysarg_t tmp;
    134         int rc = async_req_2_1(connection->hc_phone,
    135             DEV_IFACE_ID(USBHC_DEV_IFACE),
    136             IPC_M_USBHC_GET_HANDLE_BY_ADDRESS,
    137             address, &tmp);
    138         if ((rc == EOK) && (handle != NULL)) {
    139                 *handle = tmp;
    140         }
    141 
    142         return rc;
    143119}
    144120
Note: See TracChangeset for help on using the changeset viewer.