Skip to content

Commit

Permalink
[PATCH] rt2x00: Reorganize rt2x00dev->flags
Browse files Browse the repository at this point in the history
The rt2x00dev->flags has become a chaos over time,
this will reorganize the flags by renaming, deleting, adding
and properly implement the flags.

Signed-off-by: Ivo van Doorn <[email protected]>
Signed-off-by: John W. Linville <[email protected]>
  • Loading branch information
IvDoorn authored and David S. Miller committed Oct 10, 2007
1 parent 12dadb9 commit 066cb63
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 84 deletions.
4 changes: 2 additions & 2 deletions drivers/net/wireless/rt2x00/rt2400pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@ static int rt2400pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
* Detect if this device has an hardware controlled radio.
*/
if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO))
__set_bit(DEVICE_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
__set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags);

/*
* Check if the BBP tuning should be enabled.
Expand Down Expand Up @@ -1469,7 +1469,7 @@ static int rt2400pci_probe_hw(struct rt2x00_dev *rt2x00dev)
/*
* This device requires the beacon ring
*/
__set_bit(REQUIRE_BEACON_RING, &rt2x00dev->flags);
__set_bit(DRIVER_REQUIRE_BEACON_RING, &rt2x00dev->flags);

/*
* Set the rssi offset.
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/rt2x00/rt2500pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,7 @@ static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
* Detect if this device has an hardware controlled radio.
*/
if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO))
__set_bit(DEVICE_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
__set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags);

/*
* Check if the BBP tuning should be enabled.
Expand Down Expand Up @@ -1801,7 +1801,7 @@ static int rt2500pci_probe_hw(struct rt2x00_dev *rt2x00dev)
/*
* This device requires the beacon ring
*/
__set_bit(REQUIRE_BEACON_RING, &rt2x00dev->flags);
__set_bit(DRIVER_REQUIRE_BEACON_RING, &rt2x00dev->flags);

/*
* Set the rssi offset.
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/rt2x00/rt2500usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,7 @@ static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev)
/*
* This device requires the beacon ring
*/
__set_bit(REQUIRE_BEACON_RING, &rt2x00dev->flags);
__set_bit(DRIVER_REQUIRE_BEACON_RING, &rt2x00dev->flags);

/*
* Set the rssi offset.
Expand Down
31 changes: 14 additions & 17 deletions drivers/net/wireless/rt2x00/rt2x00.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,24 +493,21 @@ struct rt2x00_dev {
* of the device capabilities are stored.
*/
unsigned long flags;
#define DEVICE_ENABLED_RADIO 1
#define DEVICE_ENABLED_RADIO_HW 2
#define DEVICE_PRESENT 1
#define DEVICE_REGISTERED_HW 2
#define DEVICE_INITIALIZED 3
#define DEVICE_INITIALIZED_HW 4
#define REQUIRE_FIRMWARE 5
/* Hole: Add new Flag here */
#define INTERFACE_RESUME 8
#define INTERFACE_ENABLED 9
/* Hole: Add new Flag here */
#define REQUIRE_BEACON_RING 11
#define DEVICE_SUPPORT_HW_BUTTON 12
#define CONFIG_FRAME_TYPE 13
#define CONFIG_RF_SEQUENCE 14
/* Hole: Add new Flag here */
#define CONFIG_EXTERNAL_LNA_A 16
#define CONFIG_EXTERNAL_LNA_BG 17
#define CONFIG_DOUBLE_ANTENNA 18
#define CONFIG_DISABLE_LINK_TUNING 19
#define DEVICE_STARTED 4
#define DEVICE_ENABLED_RADIO 5
#define DEVICE_ENABLED_RADIO_HW 6
#define DRIVER_REQUIRE_FIRMWARE 7
#define DRIVER_REQUIRE_BEACON_RING 8
#define CONFIG_SUPPORT_HW_BUTTON 9
#define CONFIG_FRAME_TYPE 10
#define CONFIG_RF_SEQUENCE 11
#define CONFIG_EXTERNAL_LNA_A 12
#define CONFIG_EXTERNAL_LNA_BG 13
#define CONFIG_DOUBLE_ANTENNA 14
#define CONFIG_DISABLE_LINK_TUNING 15

/*
* Chipset identification.
Expand Down
27 changes: 7 additions & 20 deletions drivers/net/wireless/rt2x00/rt2x00config.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,33 +48,20 @@ void rt2x00lib_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid)

void rt2x00lib_config_type(struct rt2x00_dev *rt2x00dev, int type)
{
struct interface *intf = &rt2x00dev->interface;

if (!test_bit(INTERFACE_RESUME, &rt2x00dev->flags) &&
(!!test_bit(INTERFACE_ENABLED, &rt2x00dev->flags) ==
!!is_interface_present(intf)))
return;

rt2x00dev->ops->lib->config_type(rt2x00dev, type);

/*
* Update the configuration flags.
*/
if (is_interface_present(intf))
__set_bit(INTERFACE_ENABLED, &rt2x00dev->flags);
else
__clear_bit(INTERFACE_ENABLED, &rt2x00dev->flags);
if (type != INVALID_INTERFACE)
rt2x00dev->ops->lib->config_type(rt2x00dev, type);
}

void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, struct ieee80211_conf *conf)
void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
struct ieee80211_conf *conf, const int force_config)
{
int flags = 0;

/*
* If we are in RESUME state we should
* force all configuration options.
* In some situations we want to force all configurations
* to be reloaded (When resuming for instance).
*/
if (test_bit(INTERFACE_RESUME, &rt2x00dev->flags)) {
if (force_config) {
flags = CONFIG_UPDATE_ALL;
goto config;
}
Expand Down
55 changes: 40 additions & 15 deletions drivers/net/wireless/rt2x00/rt2x00dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
struct data_ring *rt2x00lib_get_ring(struct rt2x00_dev *rt2x00dev,
const unsigned int queue)
{
int beacon = test_bit(REQUIRE_BEACON_RING, &rt2x00dev->flags);
int beacon = test_bit(DRIVER_REQUIRE_BEACON_RING, &rt2x00dev->flags);

/*
* Check if we are requesting a reqular TX ring,
Expand Down Expand Up @@ -102,7 +102,7 @@ int rt2x00lib_enable_radio(struct rt2x00_dev *rt2x00dev)
* And check if the hardware button has been disabled.
*/
if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags) ||
(test_bit(DEVICE_SUPPORT_HW_BUTTON, &rt2x00dev->flags) &&
(test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags) &&
!test_bit(DEVICE_ENABLED_RADIO_HW, &rt2x00dev->flags)))
return 0;

Expand Down Expand Up @@ -162,6 +162,9 @@ void rt2x00lib_toggle_rx(struct rt2x00_dev *rt2x00dev, int enable)
{
enum dev_state state = enable ? STATE_RADIO_RX_ON : STATE_RADIO_RX_OFF;

if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags))
return;

/*
* When we are disabling the RX, we should also stop the link tuner.
*/
Expand Down Expand Up @@ -721,7 +724,7 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,

static void rt2x00lib_remove_hw(struct rt2x00_dev *rt2x00dev)
{
if (test_bit(DEVICE_INITIALIZED_HW, &rt2x00dev->flags))
if (test_bit(DEVICE_REGISTERED_HW, &rt2x00dev->flags))
ieee80211_unregister_hw(rt2x00dev->hw);

if (likely(rt2x00dev->hwmodes)) {
Expand Down Expand Up @@ -753,7 +756,7 @@ static int rt2x00lib_probe_hw(struct rt2x00_dev *rt2x00dev)
return status;
}

__set_bit(DEVICE_INITIALIZED_HW, &rt2x00dev->flags);
__set_bit(DEVICE_REGISTERED_HW, &rt2x00dev->flags);

return 0;
}
Expand Down Expand Up @@ -810,7 +813,7 @@ static int rt2x00lib_alloc_ring_entries(struct rt2x00_dev *rt2x00dev)
return -ENOMEM;
}

if (!test_bit(REQUIRE_BEACON_RING, &rt2x00dev->flags))
if (!test_bit(DRIVER_REQUIRE_BEACON_RING, &rt2x00dev->flags))
return 0;

/*
Expand Down Expand Up @@ -919,7 +922,7 @@ static int rt2x00lib_alloc_rings(struct rt2x00_dev *rt2x00dev)
* Atim: 1 (if required)
*/
rt2x00dev->data_rings = 1 + rt2x00dev->hw->queues +
(2 * test_bit(REQUIRE_BEACON_RING, &rt2x00dev->flags));
(2 * test_bit(DRIVER_REQUIRE_BEACON_RING, &rt2x00dev->flags));

ring = kzalloc(rt2x00dev->data_rings * sizeof(*ring), GFP_KERNEL);
if (!ring) {
Expand All @@ -932,7 +935,7 @@ static int rt2x00lib_alloc_rings(struct rt2x00_dev *rt2x00dev)
*/
rt2x00dev->rx = ring;
rt2x00dev->tx = &rt2x00dev->rx[1];
if (test_bit(REQUIRE_BEACON_RING, &rt2x00dev->flags))
if (test_bit(DRIVER_REQUIRE_BEACON_RING, &rt2x00dev->flags))
rt2x00dev->bcn = &rt2x00dev->tx[rt2x00dev->hw->queues];

/*
Expand Down Expand Up @@ -1011,6 +1014,8 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
*/
rt2x00debug_register(rt2x00dev);

__set_bit(DEVICE_PRESENT, &rt2x00dev->flags);

return 0;

exit:
Expand All @@ -1022,6 +1027,8 @@ EXPORT_SYMBOL_GPL(rt2x00lib_probe_dev);

void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)
{
__clear_bit(DEVICE_PRESENT, &rt2x00dev->flags);

/*
* Disable radio.
*/
Expand Down Expand Up @@ -1068,6 +1075,13 @@ int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state)
int retval;

NOTICE(rt2x00dev, "Going to sleep.\n");
__clear_bit(DEVICE_PRESENT, &rt2x00dev->flags);

/*
* Only continue if mac80211 has open interfaces.
*/
if (!test_bit(DEVICE_STARTED, &rt2x00dev->flags))
goto exit;

/*
* Disable radio and unitialize all items
Expand All @@ -1077,6 +1091,7 @@ int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state)
rt2x00lib_uninitialize(rt2x00dev);
rt2x00debug_deregister(rt2x00dev);

exit:
/*
* Set device mode to sleep for power management.
*/
Expand All @@ -1094,13 +1109,19 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
int retval;

NOTICE(rt2x00dev, "Waking up.\n");
__set_bit(INTERFACE_RESUME, &rt2x00dev->flags);
__set_bit(DEVICE_PRESENT, &rt2x00dev->flags);

/*
* Open the debugfs entry.
*/
rt2x00debug_register(rt2x00dev);

/*
* Only continue if mac80211 has open interfaces.
*/
if (!test_bit(DEVICE_STARTED, &rt2x00dev->flags))
return 0;

/*
* Reinitialize device and all active interfaces.
*/
Expand All @@ -1111,14 +1132,22 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
/*
* Reconfigure device.
*/
retval = rt2x00mac_config(rt2x00dev->hw, &rt2x00dev->hw->conf);
if (retval)
goto exit;
rt2x00lib_config(rt2x00dev, &rt2x00dev->hw->conf, 1);
if (!rt2x00dev->hw->conf.radio_enabled)
rt2x00lib_disable_radio(rt2x00dev);

rt2x00lib_config_mac_addr(rt2x00dev, intf->mac);
rt2x00lib_config_bssid(rt2x00dev, intf->bssid);
rt2x00lib_config_type(rt2x00dev, intf->type);

/*
* It is possible that during that mac80211 has attempted
* to send frames while we were suspending or resuming.
* In that case we have disabled the TX queue and should
* now enable it again
*/
ieee80211_start_queues(rt2x00dev->hw);

/*
* When in Master or Ad-hoc mode,
* restart Beacon transmitting by faking a beacondone event.
Expand All @@ -1127,17 +1156,13 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
intf->type == IEEE80211_IF_TYPE_IBSS)
rt2x00lib_beacondone(rt2x00dev);

__clear_bit(INTERFACE_RESUME, &rt2x00dev->flags);

return 0;

exit:
rt2x00lib_disable_radio(rt2x00dev);
rt2x00lib_uninitialize(rt2x00dev);
rt2x00debug_deregister(rt2x00dev);

__clear_bit(INTERFACE_RESUME, &rt2x00dev->flags);

return retval;
}
EXPORT_SYMBOL_GPL(rt2x00lib_resume);
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/wireless/rt2x00/rt2x00lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ void rt2x00lib_uninitialize(struct rt2x00_dev *rt2x00dev);
void rt2x00lib_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *mac);
void rt2x00lib_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid);
void rt2x00lib_config_type(struct rt2x00_dev *rt2x00dev, int type);
void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, struct ieee80211_conf *conf);
void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
struct ieee80211_conf *conf, const int force_config);

/*
* Firmware handlers.
Expand Down
Loading

0 comments on commit 066cb63

Please sign in to comment.