summaryrefslogtreecommitdiff
path: root/sys/netbt/hci_misc.c
diff options
context:
space:
mode:
authorUwe Stuehler <uwe@cvs.openbsd.org>2008-02-24 21:34:49 +0000
committerUwe Stuehler <uwe@cvs.openbsd.org>2008-02-24 21:34:49 +0000
commit0f57bfa559ae850def03153006105883b91d362e (patch)
treea7fb0a4d79aacf2db2bdf4eef6f744e5a9ecbf61 /sys/netbt/hci_misc.c
parent98450358fa8b17b64cdf2ba62762e40965362f3c (diff)
Sync sys/netbt with NetBSD
ok deraadt@
Diffstat (limited to 'sys/netbt/hci_misc.c')
-rw-r--r--sys/netbt/hci_misc.c43
1 files changed, 38 insertions, 5 deletions
diff --git a/sys/netbt/hci_misc.c b/sys/netbt/hci_misc.c
index dd5f3b10149..5cb144036a5 100644
--- a/sys/netbt/hci_misc.c
+++ b/sys/netbt/hci_misc.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: hci_misc.c,v 1.1 2007/05/30 03:42:53 uwe Exp $ */
-/* $NetBSD: hci_misc.c,v 1.1 2006/06/19 15:44:45 gdamore Exp $ */
+/* $OpenBSD: hci_misc.c,v 1.2 2008/02/24 21:34:48 uwe Exp $ */
+/* $NetBSD: hci_misc.c,v 1.3 2007/09/16 19:59:30 plunky Exp $ */
/*-
* Copyright (c) 2005 Iain Hibbert.
@@ -31,8 +31,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
@@ -129,7 +127,7 @@ hci_memo_find(struct hci_unit *unit, bdaddr_t *bdaddr)
continue;
}
- if (bdaddr_same(bdaddr, &memo->response.bdaddr)) {
+ if (bdaddr_same(bdaddr, &memo->bdaddr)) {
DPRINTF("memo %p found\n", memo);
return memo;
}
@@ -139,6 +137,41 @@ hci_memo_find(struct hci_unit *unit, bdaddr_t *bdaddr)
return NULL;
}
+/*
+ * Make a new memo on unit for bdaddr. If a memo exists, just
+ * update the timestamp.
+ */
+struct hci_memo *
+hci_memo_new(struct hci_unit *unit, bdaddr_t *bdaddr)
+{
+ struct hci_memo *memo;
+
+ memo = hci_memo_find(unit, bdaddr);
+ if (memo == NULL) {
+ memo = malloc(sizeof(struct hci_memo),
+ M_BLUETOOTH, M_NOWAIT | M_ZERO);
+
+ if (memo == NULL) {
+ DPRINTFN(0, "no memory for memo!\n");
+ return NULL;
+ }
+
+ DPRINTF("memo created for %02x:%02x:%02x:%02x:%02x:%02x\n",
+ bdaddr->b[5], bdaddr->b[4], bdaddr->b[3],
+ bdaddr->b[2], bdaddr->b[1], bdaddr->b[0]);
+
+ bdaddr_copy(&memo->bdaddr, bdaddr);
+ LIST_INSERT_HEAD(&unit->hci_memos, memo, next);
+ }
+ else
+ DPRINTF("memo updated for %02x:%02x:%02x:%02x:%02x:%02x\n",
+ bdaddr->b[5], bdaddr->b[4], bdaddr->b[3],
+ bdaddr->b[2], bdaddr->b[1], bdaddr->b[0]);
+
+ microtime(&memo->time);
+ return memo;
+}
+
void
hci_memo_free(struct hci_memo *memo)
{