#include <helper/align.h>
#include <helper/bits.h>
+#include <helper/list.h>
#include <helper/log.h>
#include <helper/replacements.h>
#include <transport/transport.h>
};
/** List of transports registered in OpenOCD. */
-static struct transport *transport_list;
+static OOCD_LIST_HEAD(transport_list);
/**
* Bitmask of transport IDs which the currently selected debug adapter supports.
{
/* name may only identify a known transport;
* caller guarantees session's transport isn't yet set.*/
- for (struct transport *t = transport_list; t; t = t->next) {
+ struct transport *t;
+ list_for_each_entry(t, &transport_list, lh) {
if (!strcmp(transport_name(t->id), name)) {
int retval = t->select(ctx);
/* select() registers commands specific to this
return ERROR_FAIL;
}
- for (t = transport_list; t; t = t->next) {
+ list_for_each_entry(t, &transport_list, lh) {
if (t->id == new_transport->id) {
LOG_ERROR("transport '%s' already registered",
transport_name(t->id));
transport_name(new_transport->id));
/* splice this into the list */
- new_transport->next = transport_list;
- transport_list = new_transport;
+ list_add(&new_transport->lh, &transport_list);
LOG_DEBUG("register '%s' (ID %d)",
transport_name(new_transport->id), new_transport->id);
command_print(CMD, "The following transports are available:");
- for (struct transport *t = transport_list; t; t = t->next)
+ struct transport *t;
+ list_for_each_entry(t, &transport_list, lh)
command_print(CMD, "\t%s", transport_name(t->id));
return ERROR_OK;
#include "helper/bits.h"
#include "helper/command.h"
+#include "helper/list.h"
#define TRANSPORT_JTAG BIT(0)
#define TRANSPORT_SWD BIT(1)
int (*override_target)(const char **targetname);
/**
- * Transports are stored in a singly linked list.
+ * Transports are stored in a linked list.
*/
- struct transport *next;
+ struct list_head lh;
};
int transport_register(struct transport *new_transport);