Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/iface.c

    r357a302 r1ae51ae  
    3232 * @brief UHCI driver
    3333 */
    34 #include <driver.h>
     34#include <ddf/driver.h>
    3535#include <remote_usbhc.h>
    3636
     
    4141#include "iface.h"
    4242#include "uhci.h"
    43 
    44 /*----------------------------------------------------------------------------*/
    45 static int reserve_default_address(device_t *dev, usb_speed_t speed)
    46 {
    47         assert(dev);
    48         uhci_t *hc = dev_to_uhci(dev);
    49         assert(hc);
    50         usb_address_keeping_reserve_default(&hc->address_manager);
    51         return EOK;
    52 }
    53 /*----------------------------------------------------------------------------*/
    54 static int release_default_address(device_t *dev)
    55 {
    56         assert(dev);
    57         uhci_t *hc = dev_to_uhci(dev);
    58         assert(hc);
    59         usb_address_keeping_release_default(&hc->address_manager);
    60         return EOK;
    61 }
    62 /*----------------------------------------------------------------------------*/
    63 static int request_address(device_t *dev, usb_speed_t speed,
     43#include "utils/device_keeper.h"
     44
     45/*----------------------------------------------------------------------------*/
     46static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed)
     47{
     48        assert(fun);
     49        uhci_t *hc = fun_to_uhci(fun);
     50        assert(hc);
     51        usb_log_debug("Default address request with speed %d.\n", speed);
     52        device_keeper_reserve_default(&hc->device_manager, speed);
     53        return EOK;
     54}
     55/*----------------------------------------------------------------------------*/
     56static int release_default_address(ddf_fun_t *fun)
     57{
     58        assert(fun);
     59        uhci_t *hc = fun_to_uhci(fun);
     60        assert(hc);
     61        usb_log_debug("Default address release.\n");
     62        device_keeper_release_default(&hc->device_manager);
     63        return EOK;
     64}
     65/*----------------------------------------------------------------------------*/
     66static int request_address(ddf_fun_t *fun, usb_speed_t speed,
    6467    usb_address_t *address)
    6568{
    66         assert(dev);
    67         uhci_t *hc = dev_to_uhci(dev);
    68         assert(hc);
    69         *address = usb_address_keeping_request(&hc->address_manager);
     69        assert(fun);
     70        uhci_t *hc = fun_to_uhci(fun);
     71        assert(hc);
     72        assert(address);
     73
     74        usb_log_debug("Address request with speed %d.\n", speed);
     75        *address = device_keeper_request(&hc->device_manager, speed);
     76        usb_log_debug("Address request with result: %d.\n", *address);
    7077        if (*address <= 0)
    7178          return *address;
     
    7481/*----------------------------------------------------------------------------*/
    7582static int bind_address(
    76   device_t *dev, usb_address_t address, devman_handle_t handle)
    77 {
    78         assert(dev);
    79         uhci_t *hc = dev_to_uhci(dev);
    80         assert(hc);
    81         usb_address_keeping_devman_bind(&hc->address_manager, address, handle);
    82         return EOK;
    83 }
    84 /*----------------------------------------------------------------------------*/
    85 static int release_address(device_t *dev, usb_address_t address)
    86 {
    87         assert(dev);
    88         uhci_t *hc = dev_to_uhci(dev);
    89         assert(hc);
    90         usb_address_keeping_release_default(&hc->address_manager);
    91         return EOK;
    92 }
    93 /*----------------------------------------------------------------------------*/
    94 static int interrupt_out(device_t *dev, usb_target_t target,
    95     size_t max_packet_size,
    96     void *data, size_t size,
     83  ddf_fun_t *fun, usb_address_t address, devman_handle_t handle)
     84{
     85        assert(fun);
     86        uhci_t *hc = fun_to_uhci(fun);
     87        assert(hc);
     88        usb_log_debug("Address bind %d-%d.\n", address, handle);
     89        device_keeper_bind(&hc->device_manager, address, handle);
     90        return EOK;
     91}
     92/*----------------------------------------------------------------------------*/
     93static int release_address(ddf_fun_t *fun, usb_address_t address)
     94{
     95        assert(fun);
     96        uhci_t *hc = fun_to_uhci(fun);
     97        assert(hc);
     98        usb_log_debug("Address release %d.\n", address);
     99        device_keeper_release(&hc->device_manager, address);
     100        return EOK;
     101}
     102/*----------------------------------------------------------------------------*/
     103static int interrupt_out(ddf_fun_t *fun, usb_target_t target,
     104    size_t max_packet_size, void *data, size_t size,
    97105    usbhc_iface_transfer_out_callback_t callback, void *arg)
    98106{
    99         dev_speed_t speed = FULL_SPEED;
    100 
    101         batch_t *batch = batch_get(dev, target, USB_TRANSFER_INTERRUPT,
     107        assert(fun);
     108        uhci_t *hc = fun_to_uhci(fun);
     109        assert(hc);
     110        usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);
     111
     112        usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n",
     113            target.address, target.endpoint, size, max_packet_size);
     114
     115        batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,
    102116            max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg);
    103117        if (!batch)
     
    107121}
    108122/*----------------------------------------------------------------------------*/
    109 static int interrupt_in(device_t *dev, usb_target_t target,
    110     size_t max_packet_size,
    111     void *data, size_t size,
     123static int interrupt_in(ddf_fun_t *fun, usb_target_t target,
     124    size_t max_packet_size, void *data, size_t size,
    112125    usbhc_iface_transfer_in_callback_t callback, void *arg)
    113126{
    114         dev_speed_t speed = FULL_SPEED;
    115 
    116         batch_t *batch = batch_get(dev, target, USB_TRANSFER_INTERRUPT,
     127        assert(fun);
     128        uhci_t *hc = fun_to_uhci(fun);
     129        assert(hc);
     130        usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);
     131        usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n",
     132            target.address, target.endpoint, size, max_packet_size);
     133
     134        batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,
    117135            max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg);
    118136        if (!batch)
     
    122140}
    123141/*----------------------------------------------------------------------------*/
    124 static int control_write(device_t *dev, usb_target_t target,
     142static int control_write(ddf_fun_t *fun, usb_target_t target,
    125143    size_t max_packet_size,
    126144    void *setup_data, size_t setup_size, void *data, size_t size,
    127145    usbhc_iface_transfer_out_callback_t callback, void *arg)
    128146{
    129         dev_speed_t speed = FULL_SPEED;
    130 
    131         batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
     147        assert(fun);
     148        uhci_t *hc = fun_to_uhci(fun);
     149        assert(hc);
     150        usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);
     151        usb_log_debug("Control WRITE %d:%d %zu(%zu).\n",
     152            target.address, target.endpoint, size, max_packet_size);
     153
     154        batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,
    132155            max_packet_size, speed, data, size, setup_data, setup_size,
    133156            NULL, callback, arg);
     
    138161}
    139162/*----------------------------------------------------------------------------*/
    140 static int control_read(device_t *dev, usb_target_t target,
     163static int control_read(ddf_fun_t *fun, usb_target_t target,
    141164    size_t max_packet_size,
    142165    void *setup_data, size_t setup_size, void *data, size_t size,
    143166    usbhc_iface_transfer_in_callback_t callback, void *arg)
    144167{
    145         dev_speed_t speed = FULL_SPEED;
    146 
    147         batch_t *batch = batch_get(dev, target, USB_TRANSFER_CONTROL,
     168        assert(fun);
     169        uhci_t *hc = fun_to_uhci(fun);
     170        assert(hc);
     171        usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);
     172
     173        usb_log_debug("Control READ %d:%d %zu(%zu).\n",
     174            target.address, target.endpoint, size, max_packet_size);
     175        batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,
    148176            max_packet_size, speed, data, size, setup_data, setup_size, callback,
    149177            NULL, arg);
Note: See TracChangeset for help on using the changeset viewer.