[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bluetooth-dev] Updated BNEP patch



Here is the patch for compiling PAN profile (bnep.c) when the stack is 
built as a module. Currently PAN profile only works when the stack is 
built into the kernel, if it is built as a module a link-error occurs:

bnep.o(.text+0x0): multiple definition of `init_module'
bluetooth.o(.text+0x25a0): first defined here

The patch has been updated following the recent change of bluetooth.c

Fabrizio Gennari
Philips Research Monza
via G.Casati 23, 20052 Monza (MI), Italy
tel. +39 039 2037816, fax +39 039 2037800

diff -ruN /mnt/wip/code/linux/bluetooth/axis-bt/linux/drivers/char/bluetooth/bluetooth.c linux/drivers/char/bluetooth/bluetooth.c
--- /mnt/wip/code/linux/bluetooth/axis-bt/linux/drivers/char/bluetooth/bluetooth.c	Thu Feb  7 08:09:24 2002
+++ linux/drivers/char/bluetooth/bluetooth.c	Thu Feb  7 08:37:40 2002
@@ -2556,6 +2556,9 @@
 
 	hci_module_init();
 	rfcomm_module_init();
+#ifdef CONFIG_BLUETOOTH_PAN
+	bnep_init_module();
+#endif
         
 	return 0; /* success */
 }
@@ -3270,6 +3273,10 @@
 #endif
 #endif /* CONFIG_BLUETOOTH_PROC */
 
+#ifdef CONFIG_BLUETOOTH_PAN
+        bnep_exit_module();
+#endif
+
 	DSYS("Bluetooth Driver unregistered\n");
 }
 
diff -ruN /mnt/wip/code/linux/bluetooth/axis-bt/linux/drivers/char/bluetooth/bnep.c linux/drivers/char/bluetooth/bnep.c
--- /mnt/wip/code/linux/bluetooth/axis-bt/linux/drivers/char/bluetooth/bnep.c	Tue Jan 29 16:57:26 2002
+++ linux/drivers/char/bluetooth/bnep.c	Thu Feb  7 07:57:16 2002
@@ -128,8 +128,6 @@
 
 /****************** LOCAL FUNCTION DECLARATION SECTION **********************/
 
-static int bnep_init_module(void);
-
 /* Ethernet interface */
 static int __init bnep_init_interface(struct net_device *dev);
 static int bnep_close(struct net_device *dev);
@@ -153,13 +151,10 @@
 
 /****************** FUNCTION DEFINITION SECTION *****************************/
 
-/* Tell the kernel to call my init routine. */
-module_init(bnep_init_module);
-
 /* 
  * Init routine for the BNEP driver. 
  */
-static int
+int
 bnep_init_module(void)
 {
 	int i, err;
@@ -247,6 +242,20 @@
 	}
 }
 
+void
+bnep_exit_module(void)
+{
+	int i;
+	struct net_device *d;
+	
+	for (i = 0; i < BNEP_INTERFACES; i++) {
+		d = &dev_bnep[i];
+
+		D_MISC("Unregister netdev %s\n", d->name);
+		unregister_netdev(d);
+	}
+}
+
 /* 
  * Init routine for BNEP interfaces.
  */
@@ -450,8 +459,8 @@
 		/* Step through filter range by filter range */
 		for (i = 0; (i < BNEP_MAX_MCAST_FILTER_RANGES) && (!send_packet); i++) {
 			D_MISC(__FUNCTION__": Trying multicast filter range %d\n", i);
-			if (memcmp(local->filter_multi_addr_list[i*2].addr, eth->h_dest, 6) >= 0 &&
-			    memcmp(local->filter_multi_addr_list[i*2+1].addr, eth->h_dest, 6) <= 0) {
+			if (memcmp(local->filter_multi_addr_list[i*2].addr, eth->h_dest, 6) <= 0 &&
+			    memcmp(local->filter_multi_addr_list[i*2+1].addr, eth->h_dest, 6) >= 0) {
 				D_MISC(__FUNCTION__": Multicast filter range %d OK\n",i);
 				send_packet = 1;
 			}
@@ -612,14 +621,14 @@
 		D_ERR(__FUNCTION__": not enough room for a %d byte bt_tx_buf\n", skb->len);
 		/* don't necessarily need to discard the buffer; could set dev->tbusy = 1
 		   and then start a timer to check for free buffer space */
-		local->stats.tx_dropped++;
+		return -1;
 	} else {
 		/* subscribe to a bt_tx_buf */
 		D_XMIT("New bt buf length %i \n", buflen );
 		if ((tx_buf = subscribe_bt_buf(buflen)) == NULL) {
 			D_ERR(__FUNCTION__": failed to subscribe to a %d byte bt_tx_buf buflen %d\n", 
 			      skb->len, buflen);
-			local->stats.tx_dropped++;
+			return -1;
 		} else {
 			/* copy the frame into the bt_tx_buf */
 			memcpy(tx_buf->data + sizeof(bnep_tx_buf),bhdr,bhdrlen);
diff -ruN /mnt/wip/code/linux/bluetooth/axis-bt/linux/include/linux/bluetooth/bnep.h linux/include/linux/bluetooth/bnep.h
--- /mnt/wip/code/linux/bluetooth/axis-bt/linux/include/linux/bluetooth/bnep.h	Thu Feb  7 08:09:24 2002
+++ linux/include/linux/bluetooth/bnep.h	Thu Feb  7 08:38:26 2002
@@ -191,6 +191,8 @@
 
 /****************** EXPORTED FUNCTION DECLARATION SECTION *******************/
 
+int  bnep_init_module(void);
+void bnep_exit_module(void);
 void bnep_init(void);
 u32  bnep_connect_req(u8* bd_addr);
 void bnep_disconnect_req(u8 line);