From e6e6f69066c7d222a4c7928b9c1305762f2121af Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 23 Feb 2011 22:10:08 +0000 Subject: [PATCH] [brcm-2.4] fix wlcompat so that the wl module can be unloaded 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 git-svn-id: svn://svn.openwrt.org/openwrt/branches/backfire@25671 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/broadcom-wl/Makefile | 4 ++-- package/broadcom-wl/src/wlcompat/wlcompat.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/package/broadcom-wl/Makefile b/package/broadcom-wl/Makefile index aaf6083ee..6b68b84c2 100644 --- a/package/broadcom-wl/Makefile +++ b/package/broadcom-wl/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2006-2011 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=broadcom-wl PKG_VERSION:=4.150.10.5.3 -PKG_RELEASE:=7 +PKG_RELEASE:=8 WLC_VERSION:=0.2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 diff --git a/package/broadcom-wl/src/wlcompat/wlcompat.c b/package/broadcom-wl/src/wlcompat/wlcompat.c index 1b5dd78e1..95e700d4e 100644 --- a/package/broadcom-wl/src/wlcompat/wlcompat.c +++ b/package/broadcom-wl/src/wlcompat/wlcompat.c @@ -38,7 +38,7 @@ #include char buf[WLC_IOCTL_MAXLEN]; -static struct net_device *dev; +static struct net_device *dev = NULL; #ifndef DEBUG static int random = 1; #endif @@ -981,10 +981,15 @@ static int __init wlcompat_init() int found = 0, i; char devname[4] = "wl0"; + /* 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 { + dev_put(dev); + devname[2]++; + } } @@ -1026,6 +1031,9 @@ static void __exit wlcompat_exit() dev->wireless_handlers = NULL; #endif dev->do_ioctl = old_ioctl; + + dev_put(dev); + return; } -- 2.35.1