Changeset 508a0ca in mainline


Ignore:
Timestamp:
2011-04-12T10:23:03Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f324635
Parents:
d017cea
Message:

Rename transfer ⇒ td

File:
1 edited

Legend:

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

    rd017cea r508a0ca  
    4848        qh_t *qh;
    4949        td_t *tds;
    50         size_t transfers;
     50        size_t td_count;
    5151} uhci_batch_t;
    5252
     
    6363 * @param[in] target Device and endpoint target of the transaction.
    6464 * @param[in] transfer_type Interrupt, Control or Bulk.
    65  * @param[in] max_packet_size maximum allowed size of data transfers.
     65 * @param[in] max_packet_size maximum allowed size of data transactions.
    6666 * @param[in] speed Speed of the transaction.
    6767 * @param[in] buffer Data source/destination.
     
    7676 * NULL otherwise.
    7777 *
    78  * Determines the number of needed transfers (TDs). Prepares a transport buffer
    79  * (that is accessible by the hardware). Initializes parameters needed for the
    80  * transaction and callback.
     78 * Determines the number of needed transfer descriptors (TDs).
     79 * Prepares a transport buffer (that is accessible by the hardware).
     80 * Initializes parameters needed for the transaction and callback.
    8181 */
    8282usb_transfer_batch_t * batch_get(ddf_fun_t *fun, endpoint_t *ep,
     
    113113        instance->private_data = data;
    114114
    115         data->transfers =
     115        data->td_count =
    116116            (buffer_size + ep->max_packet_size - 1) / ep->max_packet_size;
    117117        if (ep->transfer_type == USB_TRANSFER_CONTROL) {
    118                 data->transfers += 2;
    119         }
    120 
    121         data->tds = malloc32(sizeof(td_t) * data->transfers);
     118                data->td_count += 2;
     119        }
     120
     121        data->tds = malloc32(sizeof(td_t) * data->td_count);
    122122        CHECK_NULL_DISPOSE_RETURN(
    123123            data->tds, "Failed to allocate transfer descriptors.\n");
    124         bzero(data->tds, sizeof(td_t) * data->transfers);
     124        bzero(data->tds, sizeof(td_t) * data->td_count);
    125125
    126126        data->qh = malloc32(sizeof(qh_t));
     
    164164
    165165        usb_log_debug2("Batch(%p) checking %d transfer(s) for completion.\n",
    166             instance, data->transfers);
     166            instance, data->td_count);
    167167        instance->transfered_size = 0;
    168168        size_t i = 0;
    169         for (;i < data->transfers; ++i) {
     169        for (;i < data->td_count; ++i) {
    170170                if (td_is_active(&data->tds[i])) {
    171171                        return false;
     
    290290 *
    291291 * @param[in] instance Batch structure to use.
    292  * @param[in] pid Pid to use for data transfers.
     292 * @param[in] pid Pid to use for data transactions.
    293293 *
    294294 * Packets with alternating toggle bit and supplied pid value.
     
    305305        assert(toggle == 0 || toggle == 1);
    306306
    307         size_t transfer = 0;
     307        size_t td = 0;
    308308        size_t remain_size = instance->buffer_size;
    309309        while (remain_size > 0) {
     
    316316                    remain_size : instance->ep->max_packet_size;
    317317
    318                 td_t *next_transfer = (transfer + 1 < data->transfers)
    319                     ? &data->tds[transfer + 1] : NULL;
    320 
    321                 assert(transfer < data->transfers);
     318                td_t *next_td = (td + 1 < data->td_count)
     319                    ? &data->tds[td + 1] : NULL;
     320
     321                assert(td < data->td_count);
    322322                assert(packet_size <= remain_size);
    323323                usb_target_t target =
     
    325325
    326326                td_init(
    327                     &data->tds[transfer], DEFAULT_ERROR_COUNT, packet_size,
    328                     toggle, false, low_speed, target, pid, trans_data,
    329                     next_transfer);
     327                    &data->tds[td], DEFAULT_ERROR_COUNT, packet_size,
     328                    toggle, false, low_speed, target, pid, trans_data, next_td);
    330329
    331330
    332331                toggle = 1 - toggle;
    333332                remain_size -= packet_size;
    334                 ++transfer;
    335         }
    336         td_set_ioc(&data->tds[transfer - 1]);
     333                ++td;
     334        }
     335        td_set_ioc(&data->tds[td - 1]);
    337336        endpoint_toggle_set(instance->ep, toggle);
    338337}
     
    341340 *
    342341 * @param[in] instance Batch structure to use.
    343  * @param[in] data_stage Pid to use for data transfers.
    344  * @param[in] status_stage Pid to use for data transfers.
     342 * @param[in] data_stage Pid to use for data tds.
     343 * @param[in] status_stage Pid to use for data tds.
    345344 *
    346345 * Setup stage with toggle 0 and USB_PID_SETUP.
     
    355354        uhci_batch_t *data = instance->private_data;
    356355        assert(data);
    357         assert(data->transfers >= 2);
     356        assert(data->td_count >= 2);
    358357
    359358        const bool low_speed = instance->ep->speed == USB_SPEED_LOW;
     
    369368
    370369        /* data stage */
    371         size_t transfer = 1;
     370        size_t td = 1;
    372371        size_t remain_size = instance->buffer_size;
    373372        while (remain_size > 0) {
     
    383382
    384383                td_init(
    385                     &data->tds[transfer], DEFAULT_ERROR_COUNT, packet_size,
     384                    &data->tds[td], DEFAULT_ERROR_COUNT, packet_size,
    386385                    toggle, false, low_speed, target, data_stage,
    387                     control_data, &data->tds[transfer + 1]);
    388 
    389                 ++transfer;
    390                 assert(transfer < data->transfers);
     386                    control_data, &data->tds[td + 1]);
     387
     388                ++td;
     389                assert(td < data->td_count);
    391390                assert(packet_size <= remain_size);
    392391                remain_size -= packet_size;
     
    394393
    395394        /* status stage */
    396         assert(transfer == data->transfers - 1);
     395        assert(td == data->td_count - 1);
    397396
    398397        td_init(
    399             &data->tds[transfer], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed,
     398            &data->tds[td], DEFAULT_ERROR_COUNT, 0, 1, false, low_speed,
    400399            target, status_stage, NULL, NULL);
    401         td_set_ioc(&data->tds[transfer]);
     400        td_set_ioc(&data->tds[td]);
    402401
    403402        usb_log_debug2("Control last TD status: %x.\n",
    404             data->tds[transfer].status);
     403            data->tds[td].status);
    405404}
    406405/*----------------------------------------------------------------------------*/
Note: See TracChangeset for help on using the changeset viewer.