Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003 
0004   Broadcom B43 wireless driver
0005   RFKILL support
0006 
0007   Copyright (c) 2007 Michael Buesch <m@bues.ch>
0008 
0009 
0010 */
0011 
0012 #include "b43.h"
0013 
0014 
0015 /* Returns TRUE, if the radio is enabled in hardware. */
0016 bool b43_is_hw_radio_enabled(struct b43_wldev *dev)
0017 {
0018     return !(b43_read32(dev, B43_MMIO_RADIO_HWENABLED_HI)
0019         & B43_MMIO_RADIO_HWENABLED_HI_MASK);
0020 }
0021 
0022 /* The poll callback for the hardware button. */
0023 void b43_rfkill_poll(struct ieee80211_hw *hw)
0024 {
0025     struct b43_wl *wl = hw_to_b43_wl(hw);
0026     struct b43_wldev *dev = wl->current_dev;
0027     bool enabled;
0028     bool brought_up = false;
0029 
0030     mutex_lock(&wl->mutex);
0031     if (unlikely(b43_status(dev) < B43_STAT_INITIALIZED)) {
0032         if (b43_bus_powerup(dev, 0)) {
0033             mutex_unlock(&wl->mutex);
0034             return;
0035         }
0036         b43_device_enable(dev, 0);
0037         brought_up = true;
0038     }
0039 
0040     enabled = b43_is_hw_radio_enabled(dev);
0041 
0042     if (unlikely(enabled != dev->radio_hw_enable)) {
0043         dev->radio_hw_enable = enabled;
0044         b43info(wl, "Radio hardware status changed to %s\n",
0045             enabled ? "ENABLED" : "DISABLED");
0046         wiphy_rfkill_set_hw_state(hw->wiphy, !enabled);
0047         if (enabled != dev->phy.radio_on)
0048             b43_software_rfkill(dev, !enabled);
0049     }
0050 
0051     if (brought_up) {
0052         b43_device_disable(dev, 0);
0053         b43_bus_may_powerdown(dev);
0054     }
0055 
0056     mutex_unlock(&wl->mutex);
0057 }