summaryrefslogtreecommitdiffstats
path: root/net/irda/discovery.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1999-06-17 13:25:08 +0000
committerRalf Baechle <ralf@linux-mips.org>1999-06-17 13:25:08 +0000
commit59223edaa18759982db0a8aced0e77457d10c68e (patch)
tree89354903b01fa0a447bffeefe00df3044495db2e /net/irda/discovery.c
parentdb7d4daea91e105e3859cf461d7e53b9b77454b2 (diff)
Merge with Linux 2.3.6. Sorry, this isn't tested on silicon, I don't
have a MIPS box at hand.
Diffstat (limited to 'net/irda/discovery.c')
-rw-r--r--net/irda/discovery.c62
1 files changed, 45 insertions, 17 deletions
diff --git a/net/irda/discovery.c b/net/irda/discovery.c
index 22def3a1e..380f1f6a8 100644
--- a/net/irda/discovery.c
+++ b/net/irda/discovery.c
@@ -6,8 +6,10 @@
* Status: Experimental.
* Author: Dag Brattli <dagb@cs.uit.no>
* Created at: Tue Apr 6 15:33:50 1999
- * Modified at: Sun Apr 11 00:41:58 1999
+ * Modified at: Fri May 28 20:46:38 1999
* Modified by: Dag Brattli <dagb@cs.uit.no>
+ * Modified at: Fri May 28 3:11 CST 1999
+ * Modified by: Horst von Brand <vonbrand@sleipnir.valparaiso.cl>
*
* Copyright (c) 1999 Dag Brattli, All Rights Reserved.
*
@@ -28,6 +30,7 @@
*
********************************************************************/
+#include <linux/string.h>
#include <linux/socket.h>
#include <linux/irda.h>
@@ -39,28 +42,51 @@
/*
* Function irlmp_add_discovery (cachelog, discovery)
*
- *
- *
+ * Add a new discovery to the cachelog, and remove any old discoveries
+ * from the same device
*/
-void irlmp_add_discovery(hashbin_t *cachelog, discovery_t *discovery)
+void irlmp_add_discovery(hashbin_t *cachelog, discovery_t *new)
{
- discovery_t *old;
+ discovery_t *discovery, *node;
+ unsigned long flags;
- DEBUG(4, __FUNCTION__ "()\n");
+ spin_lock_irqsave(&irlmp->lock, flags);
+
+ /*
+ * Remove all discoveries of devices that has previously been
+ * discovered on the same link with the same name (info), or the
+ * same daddr. We do this since some devices (mostly PDAs) change
+ * their device address between every discovery.
+ */
+ discovery = (discovery_t *) hashbin_get_first(cachelog);
+ while (discovery != NULL ) {
+ node = discovery;
+
+ /* Be sure to stay one item ahead */
+ discovery = (discovery_t *) hashbin_get_next(cachelog);
+
+ if ((node->daddr == new->daddr) ||
+ (strcmp(node->info, new->info) == 0))
+ {
+ /* This discovery is a previous discovery
+ * from the same device, so just remove it
+ */
+ hashbin_remove(cachelog, node->daddr, NULL);
+ kfree(node);
+ }
+ }
- /* Check if we have discovered this device before */
- old = hashbin_remove(cachelog, discovery->daddr, NULL);
- if (old)
- kfree(old);
/* Insert the new and updated version */
- hashbin_insert(cachelog, (QUEUE *) discovery, discovery->daddr, NULL);
+ hashbin_insert(cachelog, (QUEUE *) new, new->daddr, NULL);
+
+ spin_unlock_irqrestore(&irlmp->lock, flags);
}
/*
* Function irlmp_add_discovery_log (cachelog, log)
*
- *
+ * Merge a disovery log into the cachlog.
*
*/
void irlmp_add_discovery_log(hashbin_t *cachelog, hashbin_t *log)
@@ -201,10 +227,12 @@ int discovery_proc_read(char *buf, char **start, off_t offset, int len,
discovery = (discovery_t *) hashbin_get_first(cachelog);
while ( discovery != NULL) {
- len += sprintf( buf+len, " name: %s,",
- discovery->info);
+ len += sprintf(buf+len, "name: %s,", discovery->info);
- len += sprintf( buf+len, " hint: ");
+ len += sprintf(buf+len, " hint: 0x%02x%02x",
+ discovery->hints.byte[0],
+ discovery->hints.byte[1]);
+#if 0
if ( discovery->hints.byte[0] & HINT_PNP)
len += sprintf( buf+len, "PnP Compatible ");
if ( discovery->hints.byte[0] & HINT_PDA)
@@ -228,14 +256,14 @@ int discovery_proc_read(char *buf, char **start, off_t offset, int len,
len += sprintf( buf+len, "IrCOMM ");
if ( discovery->hints.byte[1] & HINT_OBEX)
len += sprintf( buf+len, "IrOBEX ");
-
+#endif
len += sprintf(buf+len, ", saddr: 0x%08x",
discovery->saddr);
len += sprintf(buf+len, ", daddr: 0x%08x\n",
discovery->daddr);
- len += sprintf( buf+len, "\n");
+ len += sprintf(buf+len, "\n");
discovery = (discovery_t *) hashbin_get_next(cachelog);
}