adapter: Add routine to fetch the last found target
authorSamuel Ortiz <sameo@linux.intel.com>
Tue, 3 May 2011 17:11:34 +0000 (19:11 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 21 Oct 2011 06:54:03 +0000 (23:54 -0700)
src/adapter.c

index 643e508..4538bd0 100644 (file)
@@ -393,6 +393,24 @@ static struct near_target *find_target(struct near_adapter *adapter,
        return NULL;
 }
 
+struct near_target *near_adapter_last_target(uint32_t idx)
+{
+       struct near_adapter *adapter;
+       GList *list;
+
+       DBG("idx %d", idx);
+
+       adapter = g_hash_table_lookup(adapter_hash, GINT_TO_POINTER(idx));
+       if (adapter == NULL)
+               return NULL;
+
+       list = g_list_first(adapter->target_list);
+       if (list == NULL)
+               return NULL;
+
+       return list->data;
+}
+
 int near_adapter_connect(uint32_t idx, uint32_t target_idx)
 {
        struct near_adapter *adapter;