Changeset ef40434 in mainline


Ignore:
Timestamp:
2013-01-15T21:50:52Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0f4bff8
Parents:
ef4e8eb
Message:

usb: Drop deprecated usb hc interface functions.

Location:
uspace/lib
Files:
3 edited

Legend:

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

    ref4e8eb ref40434  
    8484 */
    8585typedef enum {
    86         /** Asks for address assignment by host controller.
    87          * Answer:
    88          * - ELIMIT - host controller run out of address
    89          * - EOK - address assigned
    90          * Answer arguments:
    91          * - assigned address
    92          *
    93          * The address must be released by via IPC_M_USBHC_RELEASE_ADDRESS.
    94          */
    95         IPC_M_USBHC_REQUEST_ADDRESS,
    96 
    97         /** Bind USB address with devman handle.
    98          * Parameters:
    99          * - USB address
    100          * - devman handle
    101          * Answer:
    102          * - EOK - address binded
    103          * - ENOENT - address is not in use
    104          */
    105         IPC_M_USBHC_BIND_ADDRESS,
    106 
    10786        /** Get handle binded with given USB address.
    10887         * Parameters
     
    11392         */
    11493        IPC_M_USBHC_GET_HANDLE_BY_ADDRESS,
    115 
    116         /** Release address in use.
    117          * Arguments:
    118          * - address to be released
    119          * Answer:
    120          * - ENOENT - address not in use
    121          * - EPERM - trying to release default USB address
    122          */
    123         IPC_M_USBHC_RELEASE_ADDRESS,
    12494
    12595        /** Register endpoint attributes at host controller.
     
    161131} usbhc_iface_funcs_t;
    162132
    163 int usbhc_request_address(async_exch_t *exch, usb_address_t *address,
    164     bool strict, usb_speed_t speed)
    165 {
    166         if (!exch || !address)
    167                 return EBADMEM;
    168         sysarg_t new_address;
    169         const int ret = async_req_4_1(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    170             IPC_M_USBHC_REQUEST_ADDRESS, *address, strict, speed, &new_address);
    171         if (ret == EOK)
    172                 *address = (usb_address_t)new_address;
    173         return ret;
    174 }
    175 
    176 int usbhc_bind_address(async_exch_t *exch, usb_address_t address,
    177     devman_handle_t handle)
    178 {
    179         if (!exch)
    180                 return EBADMEM;
    181         return async_req_3_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    182             IPC_M_USBHC_BIND_ADDRESS, address, handle);
    183 }
     133
    184134
    185135int usbhc_get_handle(async_exch_t *exch, usb_address_t address,
     
    196146}
    197147
    198 int usbhc_release_address(async_exch_t *exch, usb_address_t address)
    199 {
    200         if (!exch)
    201                 return EBADMEM;
    202         return async_req_2_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    203             IPC_M_USBHC_RELEASE_ADDRESS, address);
    204 }
    205 
    206148int usbhc_register_endpoint(async_exch_t *exch, usb_address_t address,
    207149    usb_endpoint_t endpoint, usb_transfer_type_t type,
     
    323265
    324266
    325 static void remote_usbhc_request_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    326 static void remote_usbhc_bind_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    327267static void remote_usbhc_get_handle(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    328 static void remote_usbhc_release_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    329268static void remote_usbhc_register_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    330269static void remote_usbhc_unregister_endpoint(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     
    335274/** Remote USB host controller interface operations. */
    336275static remote_iface_func_ptr_t remote_usbhc_iface_ops[] = {
    337         [IPC_M_USBHC_REQUEST_ADDRESS] = remote_usbhc_request_address,
    338         [IPC_M_USBHC_RELEASE_ADDRESS] = remote_usbhc_release_address,
    339         [IPC_M_USBHC_BIND_ADDRESS] = remote_usbhc_bind_address,
    340276        [IPC_M_USBHC_GET_HANDLE_BY_ADDRESS] = remote_usbhc_get_handle,
    341277
     
    387323}
    388324
    389 void remote_usbhc_request_address(ddf_fun_t *fun, void *iface,
    390     ipc_callid_t callid, ipc_call_t *call)
    391 {
    392         const usbhc_iface_t *usb_iface = iface;
    393 
    394         if (!usb_iface->request_address) {
    395                 async_answer_0(callid, ENOTSUP);
    396                 return;
    397         }
    398 
    399         usb_address_t address = DEV_IPC_GET_ARG1(*call);
    400         const bool strict = DEV_IPC_GET_ARG2(*call);
    401         const usb_speed_t speed = DEV_IPC_GET_ARG3(*call);
    402 
    403         const int rc = usb_iface->request_address(fun, &address, strict, speed);
    404         if (rc != EOK) {
    405                 async_answer_0(callid, rc);
    406         } else {
    407                 async_answer_1(callid, EOK, (sysarg_t) address);
    408         }
    409 }
    410 
    411 void remote_usbhc_bind_address(ddf_fun_t *fun, void *iface,
    412     ipc_callid_t callid, ipc_call_t *call)
    413 {
    414         const usbhc_iface_t *usb_iface = iface;
    415 
    416         if (!usb_iface->bind_address) {
    417                 async_answer_0(callid, ENOTSUP);
    418                 return;
    419         }
    420 
    421         const usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call);
    422         const devman_handle_t handle = (devman_handle_t) DEV_IPC_GET_ARG2(*call);
    423 
    424         const int ret = usb_iface->bind_address(fun, address, handle);
    425         async_answer_0(callid, ret);
    426 }
    427325
    428326void remote_usbhc_get_handle(ddf_fun_t *fun, void *iface,
     
    447345}
    448346
    449 void remote_usbhc_release_address(ddf_fun_t *fun, void *iface,
    450     ipc_callid_t callid, ipc_call_t *call)
    451 {
    452         const usbhc_iface_t *usb_iface = iface;
    453 
    454         if (!usb_iface->release_address) {
    455                 async_answer_0(callid, ENOTSUP);
    456                 return;
    457         }
    458 
    459         const usb_address_t address = (usb_address_t) DEV_IPC_GET_ARG1(*call);
    460 
    461         const int ret = usb_iface->release_address(fun, address);
    462         async_answer_0(callid, ret);
    463 }
    464347
    465348static void callback_out(int outcome, void *arg)
  • uspace/lib/drv/include/usbhc_iface.h

    ref4e8eb ref40434  
    4444#include <stdbool.h>
    4545
    46 int usbhc_request_address(async_exch_t *, usb_address_t *, bool, usb_speed_t);
    47 int usbhc_bind_address(async_exch_t *, usb_address_t, devman_handle_t);
    4846int usbhc_get_handle(async_exch_t *, usb_address_t, devman_handle_t *);
    49 int usbhc_release_address(async_exch_t *, usb_address_t);
    5047int usbhc_register_endpoint(async_exch_t *, usb_address_t, usb_endpoint_t,
    5148    usb_transfer_type_t, usb_direction_t, size_t, unsigned int);
     
    6562/** USB host controller communication interface. */
    6663typedef struct {
    67         int (*request_address)(ddf_fun_t *, usb_address_t *, bool, usb_speed_t);
    68         int (*bind_address)(ddf_fun_t *, usb_address_t, devman_handle_t);
    69         int (*get_handle)(ddf_fun_t *, usb_address_t,
    70             devman_handle_t *);
    71         int (*release_address)(ddf_fun_t *, usb_address_t);
     64        int (*get_handle)(ddf_fun_t *, usb_address_t, devman_handle_t *);
    7265
    73         int (*register_endpoint)(ddf_fun_t *,
    74             usb_address_t, usb_endpoint_t,
     66        int (*register_endpoint)(ddf_fun_t *, usb_address_t, usb_endpoint_t,
    7567            usb_transfer_type_t, usb_direction_t, size_t, unsigned int);
    7668        int (*unregister_endpoint)(ddf_fun_t *, usb_address_t, usb_endpoint_t,
  • uspace/lib/usbhost/src/iface.c

    ref4e8eb ref40434  
    4242#include "ddf_helpers.h"
    4343
    44 /** Request address interface function.
    45  *
    46  * @param[in] fun DDF function that was called.
    47  * @param[in] address Pointer to preferred USB address.
    48  * @param[out] address Place to write a new address.
    49  * @param[in] strict Fail if the preferred address is not available.
    50  * @param[in] speed Speed to associate with the new default address.
    51  * @return Error code.
    52  */
    53 static int request_address(
    54     ddf_fun_t *fun, usb_address_t *address, bool strict, usb_speed_t speed)
    55 {
    56         assert(fun);
    57         hcd_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun));
    58         assert(hcd);
    59         assert(address);
    60         usb_log_debug("Address request: speed: %s, address: %d, strict: %s.\n",
    61             usb_str_speed(speed), *address, strict ? "YES" : "NO");
    62         return usb_device_manager_request_address(
    63             &hcd->dev_manager, address, strict, speed);
    64 }
    65 
    66 /** Bind address interface function.
    67  *
    68  * @param[in] fun DDF function that was called.
    69  * @param[in] address Address of the device
    70  * @param[in] handle Devman handle of the device driver.
    71  * @return Error code.
    72  */
    73 static int bind_address(
    74     ddf_fun_t *fun, usb_address_t address, devman_handle_t handle)
    75 {
    76         assert(fun);
    77         hcd_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun));
    78         assert(hcd);
    79 
    80         usb_log_debug("Address bind %d-%" PRIun ".\n", address, handle);
    81         return usb_device_manager_bind_address(
    82             &hcd->dev_manager, address, handle);
    83 }
    84 
    8544/** Find device handle by address interface function.
    8645 *
     
    9857        return usb_device_manager_get_info_by_address(
    9958            &hcd->dev_manager, address, handle, NULL);
    100 }
    101 
    102 /** Release address interface function.
    103  *
    104  * @param[in] fun DDF function that was called.
    105  * @param[in] address USB address to be released.
    106  * @return Error code.
    107  */
    108 static int release_address(ddf_fun_t *fun, usb_address_t address)
    109 {
    110         assert(fun);
    111         hcd_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun));
    112         usb_log_debug("Address release %d.\n", address);
    113         return hcd_release_address(hcd, address);
    11459}
    11560
     
    13479        const size_t size = max_packet_size;
    13580        const usb_target_t target = {{.address = address, .endpoint = endpoint}};
    136        
     81
    13782        usb_log_debug("Register endpoint %d:%d %s-%s %zuB %ums.\n",
    13883            address, endpoint, usb_str_transfer_type(transfer_type),
     
    203148/** usbhc Interface implementation using hcd_t from libusbhost library. */
    204149usbhc_iface_t hcd_iface = {
    205         .request_address = request_address,
    206         .bind_address = bind_address,
    207150        .get_handle = find_by_address,
    208         .release_address = release_address,
    209151
    210152        .register_endpoint = register_endpoint,
Note: See TracChangeset for help on using the changeset viewer.