Changeset b0fc92c in mainline


Ignore:
Timestamp:
2013-07-26T13:29:05Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
059d507
Parents:
f3922c2
Message:

libusb, libdrv, libusbhost: Remove searching for dev handle by usb address

Location:
uspace/lib
Files:
5 edited

Legend:

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

    rf3922c2 rb0fc92c  
    8484 */
    8585typedef enum {
    86         /** Get handle binded with given USB address.
    87          * Parameters
    88          * - USB address
    89          * Answer:
    90          * - EOK - address binded, first parameter is the devman handle
    91          * - ENOENT - address is not in use at the moment
    92          */
    93         IPC_M_USBHC_GET_HANDLE_BY_ADDRESS,
    94 
    9586        /** Register endpoint attributes at host controller.
    9687         * This is used to reserve portion of USB bandwidth.
     
    131122} usbhc_iface_funcs_t;
    132123
    133 
    134 
    135 int usbhc_get_handle(async_exch_t *exch, usb_address_t address,
    136     devman_handle_t *handle)
    137 {
    138         if (!exch)
    139                 return EBADMEM;
    140         sysarg_t h;
    141         const int ret = async_req_2_1(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    142             IPC_M_USBHC_GET_HANDLE_BY_ADDRESS, address, &h);
    143         if (ret == EOK && handle)
    144                 *handle = (devman_handle_t)h;
    145         return ret;
    146 }
    147 
    148124int usbhc_register_endpoint(async_exch_t *exch, usb_address_t address,
    149125    usb_endpoint_t endpoint, usb_transfer_type_t type,
     
    265241
    266242
    267 static void remote_usbhc_get_handle(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    268243static void remote_usbhc_register_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    269244static void remote_usbhc_unregister_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     
    274249/** Remote USB host controller interface operations. */
    275250static remote_iface_func_ptr_t remote_usbhc_iface_ops[] = {
    276         [IPC_M_USBHC_GET_HANDLE_BY_ADDRESS] = remote_usbhc_get_handle,
    277 
    278251        [IPC_M_USBHC_REGISTER_ENDPOINT] = remote_usbhc_register_endpoint,
    279252        [IPC_M_USBHC_UNREGISTER_ENDPOINT] = remote_usbhc_unregister_endpoint,
     
    322295        return trans;
    323296}
    324 
    325 
    326 void remote_usbhc_get_handle(ddf_fun_t *fun, void *iface,
    327     ipc_callid_t callid, ipc_call_t *call)
    328 {
    329         const usbhc_iface_t *usb_iface = iface;
    330 
    331         if (!usb_iface->get_handle) {
    332                 async_answer_0(callid, ENOTSUP);
    333                 return;
    334         }
    335 
    336         const usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call);
    337         devman_handle_t handle;
    338         const int ret = usb_iface->get_handle(fun, address, &handle);
    339 
    340         if (ret == EOK) {
    341                 async_answer_1(callid, ret, handle);
    342         } else {
    343                 async_answer_0(callid, ret);
    344         }
    345 }
    346 
    347297
    348298static void callback_out(int outcome, void *arg)
  • uspace/lib/drv/include/usbhc_iface.h

    rf3922c2 rb0fc92c  
    4444#include <stdbool.h>
    4545
    46 int usbhc_get_handle(async_exch_t *, usb_address_t, devman_handle_t *);
    4746int usbhc_register_endpoint(async_exch_t *, usb_address_t, usb_endpoint_t,
    4847    usb_transfer_type_t, usb_direction_t, size_t, unsigned int);
     
    6261/** USB host controller communication interface. */
    6362typedef struct {
    64         int (*get_handle)(ddf_fun_t *, usb_address_t, devman_handle_t *);
    65 
    6663        int (*register_endpoint)(ddf_fun_t *, usb_address_t, usb_endpoint_t,
    6764            usb_transfer_type_t, usb_direction_t, size_t, unsigned int);
     
    7168        int (*read)(ddf_fun_t *, usb_target_t, uint64_t, uint8_t *, size_t,
    7269            usbhc_iface_transfer_in_callback_t, void *);
    73 
    7470        int (*write)(ddf_fun_t *, usb_target_t, uint64_t, const uint8_t *,
    7571            size_t, usbhc_iface_transfer_out_callback_t, void *);
  • uspace/lib/usb/include/usb/hc.h

    rf3922c2 rb0fc92c  
    8484int usb_hc_connection_close(usb_hc_connection_t *);
    8585
    86 int usb_hc_get_handle_by_address(usb_hc_connection_t *, usb_address_t,
    87     devman_handle_t *);
    88 
    8986int usb_hc_read(usb_hc_connection_t *, usb_address_t, usb_endpoint_t,
    9087    uint64_t, void *, size_t, size_t *);
  • uspace/lib/usb/src/hc.c

    rf3922c2 rb0fc92c  
    144144}
    145145
    146 
    147 /** Get handle of USB device with given address.
    148  *
    149  * @param[in] connection Opened connection to host controller.
    150  * @param[in] address Address of device in question.
    151  * @param[out] handle Where to write the device handle.
    152  * @return Error code.
    153  */
    154 int usb_hc_get_handle_by_address(usb_hc_connection_t *connection,
    155     usb_address_t address, devman_handle_t *handle)
    156 {
    157         async_exch_t *exch;
    158         EXCH_INIT(connection, exch);
    159 
    160         const int ret = usbhc_get_handle(exch, address, handle);
    161 
    162         EXCH_FINI(connection, exch);
    163         return ret;
    164 }
    165 
    166146int usb_hc_read(usb_hc_connection_t *connection, usb_address_t address,
    167147    usb_endpoint_t endpoint, uint64_t setup, void *data, size_t size,
  • uspace/lib/usbhost/src/iface.c

    rf3922c2 rb0fc92c  
    4141#include <usb/host/hcd.h>
    4242#include "ddf_helpers.h"
    43 
    44 /** Find device handle by address interface function.
    45  *
    46  * @param[in] fun DDF function that was called.
    47  * @param[in] address Address in question.
    48  * @param[out] handle Where to store device handle if found.
    49  * @return Error code.
    50  */
    51 static int find_by_address(ddf_fun_t *fun, usb_address_t address,
    52     devman_handle_t *handle)
    53 {
    54         assert(fun);
    55         hcd_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun));
    56         assert(hcd);
    57         return usb_device_manager_get_info_by_address(
    58             &hcd->dev_manager, address, handle, NULL);
    59 }
    6043
    6144/** Register endpoint interface function.
     
    148131/** usbhc Interface implementation using hcd_t from libusbhost library. */
    149132usbhc_iface_t hcd_iface = {
    150         .get_handle = find_by_address,
    151 
    152133        .register_endpoint = register_endpoint,
    153134        .unregister_endpoint = unregister_endpoint,
Note: See TracChangeset for help on using the changeset viewer.