This patch was created on 8.09.2 but it also applies to Backfire
I found that I couldn't unload the broadcom wl driver, wlcompat didn't
correctly release/decrement  the device pointer,
This patch cleans that up

I wanted to be able to remove/install the wl driver so that I could get out
of monitor mode without rebooting

Signed-off-by: Chris Martin <[email protected]>


Index: wlcompat/wlcompat.c
===================================================================
--- wlcompat/wlcompat.c (revision 9980)
+++ wlcompat/wlcompat.c (working copy)
@@ -39,7 +39,7 @@
 #include <wlioctl.h>

 char buf[WLC_IOCTL_MAXLEN];
-static struct net_device *dev;
+static struct net_device *dev = NULL;
 #ifndef DEBUG
 static int random = 1;
 #endif
@@ -982,10 +982,19 @@
  int found = 0, i;
  char devname[4] = "wl0";

- while (!found && (dev = dev_get_by_name(devname))) {
+ // calling dev_get_by_name() will inc the open_counter in dev
+ // we must put it back with dev_put() when we are finished to dec the
counter
+ while (!found && (dev = dev_get_by_name(devname)))
+ {
  if ((wl_ioctl(dev, WLC_GET_MAGIC, &i, sizeof(i)) == 0) && (i ==
WLC_IOCTL_MAGIC))
  found = 1;
- devname[2]++;
+ else
+ {
+ // not using this one - put it back
+ dev_put(dev);
+ // try the next device
+ devname[2]++;
+ }
  }


@@ -1018,6 +1027,7 @@

 static void __exit wlcompat_exit()
 {
+
 #ifndef DEBUG
  if (random)
  del_timer(&rng_timer);
@@ -1027,6 +1037,10 @@
  dev->wireless_handlers = NULL;
 #endif
  dev->do_ioctl = old_ioctl;
+
+ // put back the device we kept - this will dec the open_counter
+ dev_put(dev);
+
  return;
 }


----------------------------------------------------------
Chris Martin
m: 0419812371
----------------------------------------------------------

Attachment: wlcompat.patch
Description: Binary data

_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to