Changeset 4603b35 in mainline


Ignore:
Timestamp:
2018-01-16T20:23:54Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
51a51be
Parents:
eeca8a6
Message:

libdrv: merged usbhc default address reservation operations

Location:
uspace/lib
Files:
4 edited

Legend:

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

    reeca8a6 r4603b35  
    4545
    4646typedef enum {
    47         IPC_M_USB_RESERVE_DEFAULT_ADDRESS,
    48         IPC_M_USB_RELEASE_DEFAULT_ADDRESS,
     47        IPC_M_USB_DEFAULT_ADDRESS_RESERVATION,
    4948        IPC_M_USB_DEVICE_ENUMERATE,
    5049        IPC_M_USB_DEVICE_REMOVE,
     
    6362        if (!exch)
    6463                return EBADMEM;
    65         return async_req_1_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USB_RESERVE_DEFAULT_ADDRESS);
     64        return async_req_2_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USB_DEFAULT_ADDRESS_RESERVATION, true);
    6665}
    6766
     
    7675        if (!exch)
    7776                return EBADMEM;
    78         return async_req_1_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USB_RELEASE_DEFAULT_ADDRESS);
     77        return async_req_2_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USB_DEFAULT_ADDRESS_RESERVATION, false);
    7978}
    8079
     
    263262}
    264263
    265 static void remote_usbhc_reserve_default_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    266 static void remote_usbhc_release_default_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     264static void remote_usbhc_default_address_reservation(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    267265static void remote_usbhc_device_enumerate(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    268266static void remote_usbhc_device_remove(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     
    274272/** Remote USB interface operations. */
    275273static const remote_iface_func_ptr_t remote_usbhc_iface_ops [] = {
    276         [IPC_M_USB_RESERVE_DEFAULT_ADDRESS] = remote_usbhc_reserve_default_address,
    277         [IPC_M_USB_RELEASE_DEFAULT_ADDRESS] = remote_usbhc_release_default_address,
     274        [IPC_M_USB_DEFAULT_ADDRESS_RESERVATION] = remote_usbhc_default_address_reservation,
    278275        [IPC_M_USB_DEVICE_ENUMERATE] = remote_usbhc_device_enumerate,
    279276        [IPC_M_USB_DEVICE_REMOVE] = remote_usbhc_device_remove,
     
    297294} async_transaction_t;
    298295
    299 void remote_usbhc_reserve_default_address(ddf_fun_t *fun, void *iface,
     296void remote_usbhc_default_address_reservation(ddf_fun_t *fun, void *iface,
    300297    ipc_callid_t callid, ipc_call_t *call)
    301298{
    302299        const usbhc_iface_t *usbhc_iface = (usbhc_iface_t *) iface;
    303300
    304         if (usbhc_iface->reserve_default_address == NULL) {
    305                 async_answer_0(callid, ENOTSUP);
    306                 return;
    307         }
    308 
    309         const int ret = usbhc_iface->reserve_default_address(fun);
     301        if (usbhc_iface->default_address_reservation == NULL) {
     302                async_answer_0(callid, ENOTSUP);
     303                return;
     304        }
     305
     306        const bool reserve = IPC_GET_ARG2(*call);
     307        const int ret = usbhc_iface->default_address_reservation(fun, reserve);
    310308        async_answer_0(callid, ret);
    311309}
    312310
    313 void remote_usbhc_release_default_address(ddf_fun_t *fun, void *iface,
    314     ipc_callid_t callid, ipc_call_t *call)
    315 {
    316         const usbhc_iface_t *usbhc_iface = (usbhc_iface_t *) iface;
    317 
    318         if (usbhc_iface->release_default_address == NULL) {
    319                 async_answer_0(callid, ENOTSUP);
    320                 return;
    321         }
    322 
    323         const int ret = usbhc_iface->release_default_address(fun);
    324         async_answer_0(callid, ret);
    325 }
    326311
    327312static void remote_usbhc_device_enumerate(ddf_fun_t *fun, void *iface,
  • uspace/lib/drv/include/usbhc_iface.h

    reeca8a6 r4603b35  
    9999/** USB device communication interface. */
    100100typedef struct {
    101         int (*reserve_default_address)(ddf_fun_t *);
    102         int (*release_default_address)(ddf_fun_t *);
     101        int (*default_address_reservation)(ddf_fun_t *, bool);
    103102
    104103        int (*device_enumerate)(ddf_fun_t *, unsigned, usb_speed_t);
  • uspace/lib/usbhost/src/bus.c

    reeca8a6 r4603b35  
    519519        fibril_mutex_lock(&bus->guard);
    520520        if (bus->default_address_owner != dev) {
    521                 usb_log_error("Device %d tried to release address, which is not reserved for it.", dev->address);
     521                usb_log_error("Device %d tried to release default address, "
     522                    "which is not reserved for it.", dev->address);
    522523        } else {
    523524                bus->default_address_owner = NULL;
  • uspace/lib/usbhost/src/ddf_helpers.c

    reeca8a6 r4603b35  
    114114
    115115/**
    116  * DDF usbhc_iface callback. Calls the bus operation directly.
     116 * DDF usbhc_iface callback. Calls the respective bus operation directly.
    117117 *
    118118 * @param fun DDF function of the device (hub) requesting the address.
    119119 */
    120 static int reserve_default_address(ddf_fun_t *fun)
     120static int default_address_reservation(ddf_fun_t *fun, bool reserve)
    121121{
    122122        assert(fun);
     
    127127        assert(dev);
    128128
    129         usb_log_debug("Device %d requested default address", dev->address);
    130         return bus_reserve_default_address(hcd->bus, dev);
    131 }
    132 
    133 /**
    134  * DDF usbhc_iface callback. Calls the bus operation directly.
    135  *
    136  * @param fun DDF function of the device (hub) releasing the address.
    137  */
    138 static int release_default_address(ddf_fun_t *fun)
    139 {
    140         assert(fun);
    141         hc_device_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun));
    142         device_t *dev = ddf_fun_data_get(fun);
    143         assert(hcd);
    144         assert(hcd->bus);
    145         assert(dev);
    146 
    147         usb_log_debug("Device %d released default address", dev->address);
    148         bus_release_default_address(hcd->bus, dev);
    149 
    150         return EOK;
     129        usb_log_debug("Device %d %s default address", dev->address, reserve ? "requested" : "releasing");
     130        if (reserve) {
     131                return bus_reserve_default_address(hcd->bus, dev);
     132        } else {
     133                bus_release_default_address(hcd->bus, dev);
     134                return EOK;
     135        }
    151136}
    152137
     
    169154        int err;
    170155
    171         usb_log_debug("Hub %d reported a new %s device on port: %u",
     156        usb_log_debug("Hub %d reported a new %s speed device on port: %u",
    172157            hub->address, usb_str_speed(speed), port);
    173158
     
    310295/** USB host controller interface */
    311296static usbhc_iface_t usbhc_iface = {
    312         .reserve_default_address = reserve_default_address,
    313         .release_default_address = release_default_address,
     297        .default_address_reservation = default_address_reservation,
    314298
    315299        .device_enumerate = device_enumerate,
Note: See TracChangeset for help on using the changeset viewer.