Changeset 1c6a45f in mainline


Ignore:
Timestamp:
2011-03-21T23:12:15Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b9fa0a9
Parents:
62ed5bc
Message:

Whitespace fixes (no functionality changed)

iface.c should be more or less identical

Location:
uspace/drv
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/ohci/iface.c

    r62ed5bc r1c6a45f  
    3333 */
    3434#include <ddf/driver.h>
    35 #include <ddf/interrupt.h>
    36 #include <device/hw_res.h>
    3735#include <errno.h>
    38 #include <str_error.h>
    39 
    40 #include <usb_iface.h>
    41 #include <usb/ddfiface.h>
     36
    4237#include <usb/debug.h>
    4338
     
    6055static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed)
    6156{
    62   assert(fun);
    63   hc_t *hc = fun_to_hc(fun);
    64   assert(hc);
    65   usb_log_debug("Default address request with speed %d.\n", speed);
    66   usb_device_keeper_reserve_default_address(&hc->manager, speed);
    67   return EOK;
     57        assert(fun);
     58        hc_t *hc = fun_to_hc(fun);
     59        assert(hc);
     60        usb_log_debug("Default address request with speed %d.\n", speed);
     61        usb_device_keeper_reserve_default_address(&hc->manager, speed);
     62        return EOK;
    6863}
    6964/*----------------------------------------------------------------------------*/
     
    7570static int release_default_address(ddf_fun_t *fun)
    7671{
    77   assert(fun);
    78   hc_t *hc = fun_to_hc(fun);
    79   assert(hc);
    80   usb_log_debug("Default address release.\n");
    81   usb_device_keeper_release_default_address(&hc->manager);
    82   return EOK;
     72        assert(fun);
     73        hc_t *hc = fun_to_hc(fun);
     74        assert(hc);
     75        usb_log_debug("Default address release.\n");
     76        usb_device_keeper_release_default_address(&hc->manager);
     77        return EOK;
    8378}
    8479/*----------------------------------------------------------------------------*/
     
    9388    usb_address_t *address)
    9489{
    95   assert(fun);
    96   hc_t *hc = fun_to_hc(fun);
    97   assert(hc);
    98   assert(address);
    99 
    100   usb_log_debug("Address request with speed %d.\n", speed);
    101   *address = device_keeper_get_free_address(&hc->manager, speed);
    102   usb_log_debug("Address request with result: %d.\n", *address);
    103   if (*address <= 0)
    104     return *address;
    105   return EOK;
     90        assert(fun);
     91        hc_t *hc = fun_to_hc(fun);
     92        assert(hc);
     93        assert(address);
     94
     95        usb_log_debug("Address request with speed %d.\n", speed);
     96        *address = device_keeper_get_free_address(&hc->manager, speed);
     97        usb_log_debug("Address request with result: %d.\n", *address);
     98        if (*address <= 0)
     99                return *address;
     100        return EOK;
    106101}
    107102/*----------------------------------------------------------------------------*/
     
    116111    usb_address_t address, devman_handle_t handle)
    117112{
    118   assert(fun);
    119   hc_t *hc = fun_to_hc(fun);
    120   assert(hc);
    121   usb_log_debug("Address bind %d-%d.\n", address, handle);
    122   usb_device_keeper_bind(&hc->manager, address, handle);
    123   return EOK;
     113        assert(fun);
     114        hc_t *hc = fun_to_hc(fun);
     115        assert(hc);
     116        usb_log_debug("Address bind %d-%d.\n", address, handle);
     117        usb_device_keeper_bind(&hc->manager, address, handle);
     118        return EOK;
    124119}
    125120/*----------------------------------------------------------------------------*/
     
    132127static int release_address(ddf_fun_t *fun, usb_address_t address)
    133128{
    134   assert(fun);
    135   hc_t *hc = fun_to_hc(fun);
    136   assert(hc);
    137   usb_log_debug("Address release %d.\n", address);
    138   usb_device_keeper_release(&hc->manager, address);
    139   return EOK;
    140 }
    141 
     129        assert(fun);
     130        hc_t *hc = fun_to_hc(fun);
     131        assert(hc);
     132        usb_log_debug("Address release %d.\n", address);
     133        usb_device_keeper_release(&hc->manager, address);
     134        return EOK;
     135}
     136/*----------------------------------------------------------------------------*/
    142137/** Register endpoint for bandwidth reservation.
    143138 *
     
    160155        return ENOTSUP;
    161156}
    162 
     157/*----------------------------------------------------------------------------*/
    163158/** Unregister endpoint (free some bandwidth reservation).
    164159 *
     
    198193    usbhc_iface_transfer_out_callback_t callback, void *arg)
    199194{
    200   hc_t *hc = fun_to_hc(fun);
    201   assert(hc);
    202   usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address);
    203 
    204   usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n",
    205       target.address, target.endpoint, size, max_packet_size);
    206 
    207   usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,
    208       max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg,
    209       &hc->manager);
    210   if (!batch)
    211     return ENOMEM;
    212   batch_interrupt_out(batch);
    213   const int ret = hc_schedule(hc, batch);
    214   if (ret != EOK) {
    215     batch_dispose(batch);
    216     return ret;
    217   }
    218   return EOK;
     195        assert(fun);
     196        hc_t *hc = fun_to_hc(fun);
     197        assert(hc);
     198        usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address);
     199
     200        usb_log_debug("Interrupt OUT %d:%d %zu(%zu).\n",
     201            target.address, target.endpoint, size, max_packet_size);
     202
     203        usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,
     204            max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg,
     205            &hc->manager);
     206        if (!batch)
     207                return ENOMEM;
     208        batch_interrupt_out(batch);
     209        const int ret = hc_schedule(hc, batch);
     210        if (ret != EOK) {
     211                batch_dispose(batch);
     212                return ret;
     213        }
     214        return EOK;
    219215}
    220216/*----------------------------------------------------------------------------*/
     
    240236    usbhc_iface_transfer_in_callback_t callback, void *arg)
    241237{
    242   assert(fun);
    243   hc_t *hc = fun_to_hc(fun);
    244   assert(hc);
    245   usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address);
    246   usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n",
    247       target.address, target.endpoint, size, max_packet_size);
    248 
    249   usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,
    250       max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg,
    251       &hc->manager);
    252   if (!batch)
    253     return ENOMEM;
    254   batch_interrupt_in(batch);
    255   const int ret = hc_schedule(hc, batch);
    256   if (ret != EOK) {
    257     batch_dispose(batch);
    258     return ret;
    259   }
    260   return EOK;
     238        assert(fun);
     239        hc_t *hc = fun_to_hc(fun);
     240        assert(hc);
     241        usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address);
     242        usb_log_debug("Interrupt IN %d:%d %zu(%zu).\n",
     243            target.address, target.endpoint, size, max_packet_size);
     244
     245        usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,
     246            max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg,
     247            &hc->manager);
     248        if (!batch)
     249                return ENOMEM;
     250        batch_interrupt_in(batch);
     251        const int ret = hc_schedule(hc, batch);
     252        if (ret != EOK) {
     253                batch_dispose(batch);
     254                return ret;
     255        }
     256        return EOK;
    261257}
    262258/*----------------------------------------------------------------------------*/
     
    282278    usbhc_iface_transfer_out_callback_t callback, void *arg)
    283279{
    284   assert(fun);
    285   hc_t *hc = fun_to_hc(fun);
    286   assert(hc);
    287   usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address);
    288 
    289   usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n",
    290       target.address, target.endpoint, size, max_packet_size);
    291 
    292   usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,
    293       max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg,
    294       &hc->manager);
    295   if (!batch)
    296     return ENOMEM;
    297   batch_bulk_out(batch);
    298   const int ret = hc_schedule(hc, batch);
    299   if (ret != EOK) {
    300     batch_dispose(batch);
    301     return ret;
    302   }
    303   return EOK;
    304 
     280        assert(fun);
     281        hc_t *hc = fun_to_hc(fun);
     282        assert(hc);
     283        usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address);
     284
     285        usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n",
     286            target.address, target.endpoint, size, max_packet_size);
     287
     288        usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,
     289            max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg,
     290            &hc->manager);
     291        if (!batch)
     292                return ENOMEM;
     293        batch_bulk_out(batch);
     294        const int ret = hc_schedule(hc, batch);
     295        if (ret != EOK) {
     296                batch_dispose(batch);
     297                return ret;
     298        }
     299        return EOK;
    305300}
    306301/*----------------------------------------------------------------------------*/
     
    326321    usbhc_iface_transfer_in_callback_t callback, void *arg)
    327322{
    328   assert(fun);
    329   hc_t *hc = fun_to_hc(fun);
    330   assert(hc);
    331   usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address);
    332   usb_log_debug("Bulk IN %d:%d %zu(%zu).\n",
    333       target.address, target.endpoint, size, max_packet_size);
    334 
    335   usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,
    336       max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg,
    337       &hc->manager);
    338   if (!batch)
    339     return ENOMEM;
    340   batch_bulk_in(batch);
    341   const int ret = hc_schedule(hc, batch);
    342   if (ret != EOK) {
    343     batch_dispose(batch);
    344     return ret;
    345   }
    346   return EOK;
     323        assert(fun);
     324        hc_t *hc = fun_to_hc(fun);
     325        assert(hc);
     326        usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address);
     327        usb_log_debug("Bulk IN %d:%d %zu(%zu).\n",
     328            target.address, target.endpoint, size, max_packet_size);
     329
     330        usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,
     331            max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg,
     332            &hc->manager);
     333        if (!batch)
     334                return ENOMEM;
     335        batch_bulk_in(batch);
     336        const int ret = hc_schedule(hc, batch);
     337        if (ret != EOK) {
     338                batch_dispose(batch);
     339                return ret;
     340        }
     341        return EOK;
    347342}
    348343/*----------------------------------------------------------------------------*/
     
    369364static int control_write(ddf_fun_t *fun, usb_target_t target,
    370365    size_t max_packet_size,
    371     void *setup_data, size_t setup_size,
    372     void *data, size_t size,
     366    void *setup_data, size_t setup_size, void *data, size_t size,
    373367    usbhc_iface_transfer_out_callback_t callback, void *arg)
    374368{
    375   assert(fun);
    376   hc_t *hc = fun_to_hc(fun);
    377   assert(hc);
    378   usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address);
    379   usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n",
    380       speed, target.address, target.endpoint, size, max_packet_size);
    381 
    382   if (setup_size != 8)
    383     return EINVAL;
    384 
    385   usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,
    386       max_packet_size, speed, data, size, setup_data, setup_size,
    387       NULL, callback, arg, &hc->manager);
    388   if (!batch)
    389     return ENOMEM;
    390   usb_device_keeper_reset_if_need(&hc->manager, target, setup_data);
    391   batch_control_write(batch);
    392   const int ret = hc_schedule(hc, batch);
    393   if (ret != EOK) {
    394     batch_dispose(batch);
    395     return ret;
    396   }
    397   return EOK;
     369        assert(fun);
     370        hc_t *hc = fun_to_hc(fun);
     371        assert(hc);
     372        usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address);
     373        usb_log_debug("Control WRITE (%d) %d:%d %zu(%zu).\n",
     374            speed, target.address, target.endpoint, size, max_packet_size);
     375
     376        if (setup_size != 8)
     377                return EINVAL;
     378
     379        usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,
     380            max_packet_size, speed, data, size, setup_data, setup_size,
     381            NULL, callback, arg, &hc->manager);
     382        if (!batch)
     383                return ENOMEM;
     384        usb_device_keeper_reset_if_need(&hc->manager, target, setup_data);
     385        batch_control_write(batch);
     386        const int ret = hc_schedule(hc, batch);
     387        if (ret != EOK) {
     388                batch_dispose(batch);
     389                return ret;
     390        }
     391        return EOK;
    398392}
    399393/*----------------------------------------------------------------------------*/
     
    420414static int control_read(ddf_fun_t *fun, usb_target_t target,
    421415    size_t max_packet_size,
    422     void *setup_data, size_t setup_size,
    423     void *data, size_t size,
     416    void *setup_data, size_t setup_size, void *data, size_t size,
    424417    usbhc_iface_transfer_in_callback_t callback, void *arg)
    425418{
    426   assert(fun);
    427   hc_t *hc = fun_to_hc(fun);
    428   assert(hc);
    429   usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address);
    430 
    431   usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n",
    432       speed, target.address, target.endpoint, size, max_packet_size);
    433   usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,
    434       max_packet_size, speed, data, size, setup_data, setup_size, callback,
    435       NULL, arg, &hc->manager);
    436   if (!batch)
    437     return ENOMEM;
    438   batch_control_read(batch);
    439   const int ret = hc_schedule(hc, batch);
    440   if (ret != EOK) {
    441     batch_dispose(batch);
    442     return ret;
    443   }
    444   return EOK;
     419        assert(fun);
     420        hc_t *hc = fun_to_hc(fun);
     421        assert(hc);
     422        usb_speed_t speed = usb_device_keeper_get_speed(&hc->manager, target.address);
     423
     424        usb_log_debug("Control READ(%d) %d:%d %zu(%zu).\n",
     425            speed, target.address, target.endpoint, size, max_packet_size);
     426        usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_CONTROL,
     427            max_packet_size, speed, data, size, setup_data, setup_size, callback,
     428            NULL, arg, &hc->manager);
     429        if (!batch)
     430                return ENOMEM;
     431        batch_control_read(batch);
     432        const int ret = hc_schedule(hc, batch);
     433        if (ret != EOK) {
     434                batch_dispose(batch);
     435                return ret;
     436        }
     437        return EOK;
    445438}
    446439/*----------------------------------------------------------------------------*/
     
    463456
    464457        .control_write = control_write,
    465         .control_read = control_read
     458        .control_read = control_read,
    466459};
    467460
  • uspace/drv/uhci-hcd/iface.c

    r62ed5bc r1c6a45f  
    3333 */
    3434#include <ddf/driver.h>
    35 #include <remote_usbhc.h>
     35#include <errno.h>
    3636
    3737#include <usb/debug.h>
    38 
    39 #include <errno.h>
    4038
    4139#include "iface.h"
     
    4846 * @return Error code.
    4947 */
    50 /*----------------------------------------------------------------------------*/
    5148static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed)
    5249{
     
    9390        usb_log_debug("Address request with result: %d.\n", *address);
    9491        if (*address <= 0)
    95           return *address;
     92                return *address;
    9693        return EOK;
    9794}
     
    192189        usb_transfer_batch_t *batch = batch_get(fun, target, USB_TRANSFER_INTERRUPT,
    193190            max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg,
    194                         &hc->manager);
     191            &hc->manager);
    195192        if (!batch)
    196193                return ENOMEM;
     
    369366        .interrupt_in = interrupt_in,
    370367
     368        .bulk_out = bulk_out,
    371369        .bulk_in = bulk_in,
    372         .bulk_out = bulk_out,
    373 
     370
     371        .control_write = control_write,
    374372        .control_read = control_read,
    375         .control_write = control_write,
    376373};
    377374/**
Note: See TracChangeset for help on using the changeset viewer.