diff --git a/drivers/net/wireless/b43legacy/rfkill.c b/drivers/net/wireless/b43legacy/rfkill.c index b32bf6a..257cbd2 100644 --- a/drivers/net/wireless/b43legacy/rfkill.c +++ b/drivers/net/wireless/b43legacy/rfkill.c @@ -28,7 +28,6 @@ #include - /* Returns TRUE, if the radio is enabled in hardware. */ static bool b43legacy_is_hw_radio_enabled(struct b43legacy_wldev *dev) { @@ -45,33 +44,43 @@ static bool b43legacy_is_hw_radio_enabled(struct b43legacy_wldev *dev) } /* The poll callback for the hardware button. */ -static void b43legacy_rfkill_poll(struct input_polled_dev *poll_dev) +static void b43legacy_rfkill_poll(struct work_struct *work) { - struct b43legacy_wldev *dev = poll_dev->private; + struct b43legacy_rfkill *rfk = container_of(work, + struct b43legacy_rfkill, + work.work); + struct b43legacy_wldev *dev = rfk->rfkill->data; struct b43legacy_wl *wl = dev->wl; bool enabled; - bool report_change = 0; mutex_lock(&wl->mutex); - if (unlikely(b43legacy_status(dev) < B43legacy_STAT_INITIALIZED)) { - mutex_unlock(&wl->mutex); - return; - } + if (unlikely(b43legacy_status(dev) < B43legacy_STAT_INITIALIZED)) + goto out_unlock; + enabled = b43legacy_is_hw_radio_enabled(dev); if (unlikely(enabled != dev->radio_hw_enable)) { + /* + * If the hardware is enabled and the state isn't hard + * blocked then we're soft blocked and shouldn't + * change the state + */ + if (enabled && rfk->rfkill->state != RFKILL_STATE_HARD_BLOCKED) + goto out_unlock; + dev->radio_hw_enable = enabled; - report_change = 1; + + if (enabled) + rfkill_force_state(rfk->rfkill, RFKILL_STATE_UNBLOCKED); + else + rfkill_force_state(rfk->rfkill, + RFKILL_STATE_HARD_BLOCKED); + b43legacyinfo(wl, "Radio hardware status changed to %s\n", enabled ? "ENABLED" : "DISABLED"); } +out_unlock: mutex_unlock(&wl->mutex); - - /* send the radio switch event to the system - note both a key press - * and a release are required */ - if (unlikely(report_change)) { - input_report_key(poll_dev->input, KEY_WLAN, 1); - input_report_key(poll_dev->input, KEY_WLAN, 0); - } + schedule_delayed_work(&rfk->work, msecs_to_jiffies(1000)); } /* Called when the RFKILL toggled in software. @@ -91,12 +100,6 @@ static int b43legacy_rfkill_soft_toggle(void *data, enum rfkill_state state) err = 0; switch (state) { case RFKILL_STATE_UNBLOCKED: - if (!dev->radio_hw_enable) { - /* No luck. We can't toggle the hardware RF-kill - * button from software. */ - err = -EBUSY; - goto out_unlock; - } if (!dev->phy.radio_on) b43legacy_radio_turn_on(dev); break; @@ -144,47 +147,16 @@ void b43legacy_rfkill_init(struct b43legacy_wldev *dev) rfk->rfkill->toggle_radio = b43legacy_rfkill_soft_toggle; rfk->rfkill->user_claim_unsupported = 1; - rfk->poll_dev = input_allocate_polled_device(); - if (!rfk->poll_dev) { - rfkill_free(rfk->rfkill); - goto err_freed_rfk; - } - - rfk->poll_dev->private = dev; - rfk->poll_dev->poll = b43legacy_rfkill_poll; - rfk->poll_dev->poll_interval = 1000; /* msecs */ - - rfk->poll_dev->input->name = rfk->name; - rfk->poll_dev->input->id.bustype = BUS_HOST; - rfk->poll_dev->input->id.vendor = dev->dev->bus->boardinfo.vendor; - rfk->poll_dev->input->evbit[0] = BIT(EV_KEY); - set_bit(KEY_WLAN, rfk->poll_dev->input->keybit); - err = rfkill_register(rfk->rfkill); if (err) - goto err_free_polldev; - -#ifdef CONFIG_RFKILL_INPUT_MODULE - /* B43legacy RF-kill isn't useful without the rfkill-input subsystem. - * Try to load the module. */ - err = request_module("rfkill-input"); - if (err) - b43legacywarn(wl, "Failed to load the rfkill-input module." - "The built-in radio LED will not work.\n"); -#endif /* CONFIG_RFKILL_INPUT */ - - err = input_register_polled_device(rfk->poll_dev); - if (err) - goto err_unreg_rfk; + goto err_freed_rfk; rfk->registered = 1; + INIT_DELAYED_WORK(&rfk->work, b43legacy_rfkill_poll); + schedule_delayed_work(&rfk->work, msecs_to_jiffies(1000)); + return; -err_unreg_rfk: - rfkill_unregister(rfk->rfkill); -err_free_polldev: - input_free_polled_device(rfk->poll_dev); - rfk->poll_dev = NULL; err_freed_rfk: rfk->rfkill = NULL; out_error: @@ -200,10 +172,9 @@ void b43legacy_rfkill_exit(struct b43legacy_wldev *dev) return; rfk->registered = 0; - input_unregister_polled_device(rfk->poll_dev); + cancel_delayed_work_sync(&rfk->work); + rfkill_unregister(rfk->rfkill); - input_free_polled_device(rfk->poll_dev); - rfk->poll_dev = NULL; rfk->rfkill = NULL; } diff --git a/drivers/net/wireless/b43legacy/rfkill.h b/drivers/net/wireless/b43legacy/rfkill.h index 11150a8..2399d7a 100644 --- a/drivers/net/wireless/b43legacy/rfkill.h +++ b/drivers/net/wireless/b43legacy/rfkill.h @@ -14,8 +14,8 @@ struct b43legacy_wldev; struct b43legacy_rfkill { /* The RFKILL subsystem data structure */ struct rfkill *rfkill; - /* The poll device for the RFKILL input button */ - struct input_polled_dev *poll_dev; + /* The work queue for the RFKILL input button */ + struct delayed_work work; /* Did initialization succeed? Used for freeing. */ bool registered; /* The unique name of this rfkill switch */