Changeset b72efe8 in mainline for uspace/drv


Ignore:
Timestamp:
2011-06-19T14:38:59Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
74464e8
Parents:
1d1bb0f
Message:

Separate list_t typedef from link_t (user-space part).

  • list_t represents lists
  • Use list_first(), list_last(), list_empty() where appropriate
  • Use list_foreach() where possible
  • assert_link_not_used()
  • usb_hid_report_path_free() shall not unlink the path, caller must do it
Location:
uspace/drv
Files:
10 edited

Legend:

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

    r1d1bb0f rb72efe8  
    103103                /* There are active EDs, get the last one */
    104104                hcd_endpoint_t *last = list_get_instance(
    105                     instance->endpoint_list.prev, hcd_endpoint_t, link);
    106                 assert(last);
     105                    list_last(&instance->endpoint_list), hcd_endpoint_t, link);
    107106                last_ed = last->ed;
    108107        }
     
    121120
    122121        hcd_endpoint_t *first = list_get_instance(
    123             instance->endpoint_list.next, hcd_endpoint_t, link);
     122            list_first(&instance->endpoint_list), hcd_endpoint_t, link);
    124123        usb_log_debug("HCD EP(%p) added to list %s, first is %p(%p).\n",
    125124                hcd_ep, instance->name, first, first->ed);
     
    153152        ed_t *prev_ed;
    154153        /* Remove from the hardware queue */
    155         if (instance->endpoint_list.next == &hcd_ep->link) {
     154        if (list_first(&instance->endpoint_list) == &hcd_ep->link) {
    156155                /* I'm the first one here */
    157156                prev_ed = instance->list_head;
  • uspace/drv/ohci/endpoint_list.h

    r1d1bb0f rb72efe8  
    5252        const char *name;
    5353        /** Sw list of all active EDs */
    54         link_t endpoint_list;
     54        list_t endpoint_list;
    5555} endpoint_list_t;
    5656
  • uspace/drv/ohci/hc.c

    r1d1bb0f rb72efe8  
    357357                    instance->registers->periodic_current);
    358358
    359                 link_t *current = instance->pending_batches.next;
    360                 while (current != &instance->pending_batches) {
     359                link_t *current = instance->pending_batches.head.next;
     360                while (current != &instance->pending_batches.head) {
    361361                        link_t *next = current->next;
    362362                        usb_transfer_batch_t *batch =
     
    367367                                usb_transfer_batch_finish(batch);
    368368                        }
     369
    369370                        current = next;
    370371                }
  • uspace/drv/ohci/hc.h

    r1d1bb0f rb72efe8  
    6868        endpoint_list_t lists[4];
    6969        /** List of active transfers */
    70         link_t pending_batches;
     70        list_t pending_batches;
    7171
    7272        /** Fibril for periodic checks if interrupts can't be used */
  • uspace/drv/uhci/hc.c

    r1d1bb0f rb72efe8  
    345345
    346346                while (!list_empty(&done)) {
    347                         link_t *item = done.next;
     347                        link_t *item = list_first(&done);
    348348                        list_remove(item);
    349349                        usb_transfer_batch_t *batch =
  • uspace/drv/uhci/transfer_list.c

    r1d1bb0f rb72efe8  
    121121        } else {
    122122                /* There is something scheduled */
    123                 usb_transfer_batch_t *last =
    124                     usb_transfer_batch_from_link(instance->batch_list.prev);
     123                usb_transfer_batch_t *last = usb_transfer_batch_from_link(
     124                    list_last(&instance->batch_list));
    125125                last_qh = batch_qh(last);
    126126        }
     
    146146}
    147147/*----------------------------------------------------------------------------*/
    148 /** Add completed bantches to the provided list.
     148/** Add completed batches to the provided list.
    149149 *
    150150 * @param[in] instance List to use.
    151151 * @param[in] done list to fill
    152152 */
    153 void transfer_list_remove_finished(transfer_list_t *instance, link_t *done)
     153void transfer_list_remove_finished(transfer_list_t *instance, list_t *done)
    154154{
    155155        assert(instance);
     
    157157
    158158        fibril_mutex_lock(&instance->guard);
    159         link_t *current = instance->batch_list.next;
    160         while (current != &instance->batch_list) {
     159        link_t *current = instance->batch_list.head.next;
     160        while (current != &instance->batch_list.head) {
    161161                link_t * const next = current->next;
    162162                usb_transfer_batch_t *batch =
     
    181181        fibril_mutex_lock(&instance->guard);
    182182        while (!list_empty(&instance->batch_list)) {
    183                 link_t * const current = instance->batch_list.next;
     183                link_t * const current = list_first(&instance->batch_list);
    184184                usb_transfer_batch_t *batch =
    185185                    usb_transfer_batch_from_link(current);
     
    212212        qh_t *prev_qh = NULL;
    213213        /* Remove from the hardware queue */
    214         if (instance->batch_list.next == &batch->link) {
     214        if (list_first(&instance->batch_list) == &batch->link) {
    215215                /* I'm the first one here */
    216216                prev_qh = instance->queue_head;
  • uspace/drv/uhci/transfer_list.h

    r1d1bb0f rb72efe8  
    5151        const char *name;
    5252        /** List of all batches in this list */
    53         link_t batch_list;
     53        list_t batch_list;
    5454} transfer_list_t;
    5555
     
    5959void transfer_list_add_batch(
    6060    transfer_list_t *instance, usb_transfer_batch_t *batch);
    61 void transfer_list_remove_finished(transfer_list_t *instance, link_t *done);
     61void transfer_list_remove_finished(transfer_list_t *instance, list_t *done);
    6262void transfer_list_abort_all(transfer_list_t *instance);
    6363#endif
  • uspace/drv/usbmid/explore.c

    r1d1bb0f rb72efe8  
    5454 * @return Interface @p interface_no is already present in the list.
    5555 */
    56 static bool interface_in_list(link_t *list, int interface_no)
     56static bool interface_in_list(list_t *list, int interface_no)
    5757{
    58         link_t *l;
    59         for (l = list->next; l != list; l = l->next) {
     58        list_foreach(*list, l) {
    6059                usbmid_interface_t *iface
    6160                    = list_get_instance(l, usbmid_interface_t, link);
     
    7574 */
    7675static void create_interfaces(uint8_t *config_descriptor,
    77     size_t config_descriptor_size, link_t *list)
     76    size_t config_descriptor_size, list_t *list)
    7877{
    7978        usb_dp_parser_data_t data = {
     
    181180
    182181        /* Create interface children. */
    183         link_t interface_list;
     182        list_t interface_list;
    184183        list_initialize(&interface_list);
    185184        create_interfaces(config_descriptor_raw, config_descriptor_size,
    186185            &interface_list);
    187186
    188         link_t *link;
    189         for (link = interface_list.next; link != &interface_list;
    190             link = link->next) {
     187        list_foreach(interface_list, link) {
    191188                usbmid_interface_t *iface = list_get_instance(link,
    192189                    usbmid_interface_t, link);
  • uspace/drv/vhc/transfer.c

    r1d1bb0f rb72efe8  
    189189        assert(!list_empty(&dev->transfer_queue));
    190190
    191         vhc_transfer_t *transfer = list_get_instance(dev->transfer_queue.next,
    192             vhc_transfer_t, link);
     191        vhc_transfer_t *transfer = list_get_instance(
     192            list_first(&dev->transfer_queue), vhc_transfer_t, link);
    193193        list_remove(&transfer->link);
    194194
  • uspace/drv/vhc/vhcd.h

    r1d1bb0f rb72efe8  
    5252        usb_address_t address;
    5353        fibril_mutex_t guard;
    54         link_t transfer_queue;
     54        list_t transfer_queue;
    5555} vhc_virtdev_t;
    5656
    5757typedef struct {
    5858        uint32_t magic;
    59         link_t devices;
     59        list_t devices;
    6060        fibril_mutex_t guard;
    6161        usb_endpoint_manager_t ep_manager;
Note: See TracChangeset for help on using the changeset viewer.