From: Stefano Brivio <stefano.brivio@polimi.it>
To: John Linville <linville@tuxdriver.com>
Cc: bcm43xx-dev@lists.berlios.de, linux-wireless@vger.kernel.org,
Larry Finger <larry.finger@lwfinger.net>
Subject: [PATCH 4/7] b43legacy: rewrite and fix rfkill initialization
Date: Tue, 6 Nov 2007 22:48:45 +0100 [thread overview]
Message-ID: <20071106224845.7735a4f1@morte> (raw)
In-Reply-To: <20071106222313.31e9bcd9@morte>
The rfkill subsystem doesn't like code like that
rfkill_allocate();
rfkill_register();
rfkill_unregister();
rfkill_register(); /* <- This will crash */
This sequence happens with
modprobe b43
ifconfig wlanX up
ifconfig wlanX down
ifconfig wlanX up
Fix this by always re-allocating the rfkill stuff before register.
The patch to b43 by Michael Buesch <mb@bu3sch.de> has been ported to
b43legacy.
Signed-off-by: Stefano Brivio <stefano.brivio@polimi.it>
----
Index: wireless-2.6/drivers/net/wireless/b43legacy/rfkill.c
===================================================================
--- wireless-2.6.orig/drivers/net/wireless/b43legacy/rfkill.c
+++ wireless-2.6/drivers/net/wireless/b43legacy/rfkill.c
@@ -48,18 +48,21 @@ static void b43legacy_rfkill_poll(struct
struct b43legacy_wldev *dev = poll_dev->private;
struct b43legacy_wl *wl = dev->wl;
bool enabled;
+ bool report_change = 0;
mutex_lock(&wl->mutex);
B43legacy_WARN_ON(b43legacy_status(dev) < B43legacy_STAT_INITIALIZED);
enabled = b43legacy_is_hw_radio_enabled(dev);
if (unlikely(enabled != dev->radio_hw_enable)) {
dev->radio_hw_enable = enabled;
+ report_change = 1;
b43legacyinfo(wl, "Radio hardware status changed to %s\n",
enabled ? "ENABLED" : "DISABLED");
- mutex_unlock(&wl->mutex);
+ }
+ mutex_unlock(&wl->mutex);
+
+ if (unlikely(report_change))
input_report_key(poll_dev->input, KEY_WLAN, enabled);
- } else
- mutex_unlock(&wl->mutex);
}
/* Called when the RFKILL toggled in software. */
@@ -69,18 +72,11 @@ static int b43legacy_rfkill_soft_toggle(
struct b43legacy_wl *wl = dev->wl;
int err = 0;
- /* When RFKILL is registered, it will call back into this callback.
- * wl->mutex will already be locked when this happens.
- * So first trylock. On contention check if we are in initialization.
- * Silently return if that happens to avoid a deadlock. */
- if (mutex_trylock(&wl->mutex) == 0) {
- if (b43legacy_status(dev) < B43_STAT_INITIALIZED)
- return 0;
- mutex_lock(&wl->mutex);
- }
- if (b43legacy_status(dev) < B43legacy_STAT_INITIALIZED)
- goto out_unlock;
+ if (!wl->rfkill.registered)
+ return 0;
+ mutex_lock(&wl->mutex);
+ B43legacy_WARN_ON(b43legacy_status(dev) < B43legacy_STAT_INITIALIZED);
switch (state) {
case RFKILL_STATE_ON:
if (!dev->radio_hw_enable) {
Index: wireless-2.6/drivers/net/wireless/b43legacy/rfkill.h
===================================================================
--- wireless-2.6.orig/drivers/net/wireless/b43legacy/rfkill.h
+++ wireless-2.6/drivers/net/wireless/b43legacy/rfkill.h
@@ -16,14 +16,14 @@ struct b43legacy_rfkill {
struct rfkill *rfkill;
/* The poll device for the RFKILL input button */
struct input_polled_dev *poll_dev;
+ /* Did initialization succeed? Used for freeing. */
+ bool registered;
/* The unique name of this rfkill switch */
- char name[32];
+ char name[sizeof("b43legacy-phy4294967295")];
};
-/* All the init functions return void, because we are not interested
+/* The init function returns void, because we are not interested
* in failing the b43 init process when rfkill init failed. */
-void b43legacy_rfkill_alloc(struct b43legacy_wldev *dev);
-void b43legacy_rfkill_free(struct b43legacy_wldev *dev);
void b43legacy_rfkill_init(struct b43legacy_wldev *dev);
void b43legacy_rfkill_exit(struct b43legacy_wldev *dev);
Index: wireless-2.6/drivers/net/wireless/b43legacy/rfkill.h
===================================================================
--- wireless-2.6.orig/drivers/net/wireless/b43legacy/main.c
+++ wireless-2.6/drivers/net/wireless/b43legacy/main.c
@@ -3360,7 +3381,6 @@ static int b43legacy_setup_modes(struct b43legacy_wldev *dev,
static void b43legacy_wireless_core_detach(struct b43legacy_wldev *dev)
{
- b43legacy_rfkill_free(dev);
/* We release firmware that late to not be required to re-request
* is all the time when we reinit the core. */
b43legacy_release_firmware(dev);
@@ -3442,7 +3462,6 @@ static int b43legacy_wireless_core_attach(struct b43legacy_wldev *dev)
if (!wl->current_dev)
wl->current_dev = dev;
INIT_WORK(&dev->restart_work, b43legacy_chip_reset);
- b43legacy_rfkill_alloc(dev);
b43legacy_radio_turn_off(dev, 1);
b43legacy_switch_analog(dev, 0);
--
Ciao
Stefano
next prev parent reply other threads:[~2007-11-06 22:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20071106222313.31e9bcd9@morte>
2007-11-06 21:48 ` [PATCH 2/7] b43legacy: use a consistent naming scheme for the ops Stefano Brivio
2007-11-06 21:48 ` [PATCH 3/7] b43legacy: fix possible buffer overrun in debugfs Stefano Brivio
2007-11-06 21:48 ` Stefano Brivio [this message]
2007-11-06 21:48 ` [PATCH 5/7] b43legacy: add me as maintainer and fix URLs Stefano Brivio
2007-11-06 21:49 ` [PATCH 6/7] b43: rewrite A PHY initialization Stefano Brivio
2007-11-06 21:49 ` [PATCH 7/7] b43/b43legacy: fix my copyright notices Stefano Brivio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071106224845.7735a4f1@morte \
--to=stefano.brivio@polimi.it \
--cc=bcm43xx-dev@lists.berlios.de \
--cc=larry.finger@lwfinger.net \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).