Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 111206
b: refs/heads/master
c: 8c5e7a5
h: refs/heads/master
v: v3
  • Loading branch information
Ivo van Doorn authored and John W. Linville committed Aug 22, 2008
1 parent 3e70f0b commit 05e7cb4
Show file tree
Hide file tree
Showing 14 changed files with 177 additions and 163 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 906c110fcc24bdd5bf0fa22d89ac75d99c747e53
refs/heads/master: 8c5e7a5f59f9d11597bd47de28334da318ea0e80
40 changes: 24 additions & 16 deletions trunk/drivers/net/wireless/rt2x00/rt2400pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,7 @@ static int rt2400pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
* RF value list for RF2420 & RF2421
* Supports: 2.4 GHz
*/
static const struct rf_channel rf_vals_bg[] = {
static const struct rf_channel rf_vals_b[] = {
{ 1, 0x00022058, 0x000c1fda, 0x00000101, 0 },
{ 2, 0x00022058, 0x000c1fee, 0x00000101, 0 },
{ 3, 0x00022058, 0x000c2002, 0x00000101, 0 },
Expand All @@ -1421,10 +1421,11 @@ static const struct rf_channel rf_vals_bg[] = {
{ 14, 0x00022058, 0x000c20fa, 0x00000101, 0 },
};

static void rt2400pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
static int rt2400pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
{
struct hw_mode_spec *spec = &rt2x00dev->spec;
u8 *txpower;
struct channel_info *info;
char *tx_power;
unsigned int i;

/*
Expand All @@ -1439,24 +1440,29 @@ static void rt2400pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
rt2x00_eeprom_addr(rt2x00dev,
EEPROM_MAC_ADDR_0));

/*
* Convert tx_power array in eeprom.
*/
txpower = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_START);
for (i = 0; i < 14; i++)
txpower[i] = TXPOWER_FROM_DEV(txpower[i]);

/*
* Initialize hw_mode information.
*/
spec->supported_bands = SUPPORT_BAND_2GHZ;
spec->supported_rates = SUPPORT_RATE_CCK;
spec->tx_power_a = NULL;
spec->tx_power_bg = txpower;
spec->tx_power_default = DEFAULT_TXPOWER;

spec->num_channels = ARRAY_SIZE(rf_vals_bg);
spec->channels = rf_vals_bg;
spec->num_channels = ARRAY_SIZE(rf_vals_b);
spec->channels = rf_vals_b;

/*
* Create channel information array
*/
info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
if (!info)
return -ENOMEM;

spec->channels_info = info;

tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_START);
for (i = 0; i < 14; i++)
info[i].tx_power1 = TXPOWER_FROM_DEV(tx_power[i]);

return 0;
}

static int rt2400pci_probe_hw(struct rt2x00_dev *rt2x00dev)
Expand All @@ -1477,7 +1483,9 @@ static int rt2400pci_probe_hw(struct rt2x00_dev *rt2x00dev)
/*
* Initialize hw specifications.
*/
rt2400pci_probe_hw_mode(rt2x00dev);
retval = rt2400pci_probe_hw_mode(rt2x00dev);
if (retval)
return retval;

/*
* This device requires the atim queue and DMA-mapped skbs.
Expand Down
22 changes: 8 additions & 14 deletions trunk/drivers/net/wireless/rt2x00/rt2400pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -938,19 +938,13 @@
#define MAX_TXPOWER 62
#define DEFAULT_TXPOWER 39

#define TXPOWER_FROM_DEV(__txpower) \
({ \
((__txpower) > MAX_TXPOWER) ? DEFAULT_TXPOWER - MIN_TXPOWER : \
((__txpower) < MIN_TXPOWER) ? DEFAULT_TXPOWER - MIN_TXPOWER : \
(((__txpower) - MAX_TXPOWER) + MIN_TXPOWER); \
})

#define TXPOWER_TO_DEV(__txpower) \
({ \
(__txpower) += MIN_TXPOWER; \
((__txpower) <= MIN_TXPOWER) ? MAX_TXPOWER : \
(((__txpower) >= MAX_TXPOWER) ? MIN_TXPOWER : \
(MAX_TXPOWER - ((__txpower) - MIN_TXPOWER))); \
})
#define __CLAMP_TX(__txpower) \
clamp_t(char, (__txpower), MIN_TXPOWER, MAX_TXPOWER)

#define TXPOWER_FROM_DEV(__txpower) \
((__CLAMP_TX(__txpower) - MAX_TXPOWER) + MIN_TXPOWER)

#define TXPOWER_TO_DEV(__txpower) \
MAX_TXPOWER - (__CLAMP_TX(__txpower) - MIN_TXPOWER)

#endif /* RT2400PCI_H */
39 changes: 26 additions & 13 deletions trunk/drivers/net/wireless/rt2x00/rt2500pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1721,10 +1721,11 @@ static const struct rf_channel rf_vals_5222[] = {
{ 161, 0x00022020, 0x000090be, 0x00000101, 0x00000a07 },
};

static void rt2500pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
static int rt2500pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
{
struct hw_mode_spec *spec = &rt2x00dev->spec;
u8 *txpower;
struct channel_info *info;
char *tx_power;
unsigned int i;

/*
Expand All @@ -1740,21 +1741,11 @@ static void rt2500pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
rt2x00_eeprom_addr(rt2x00dev,
EEPROM_MAC_ADDR_0));

/*
* Convert tx_power array in eeprom.
*/
txpower = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_START);
for (i = 0; i < 14; i++)
txpower[i] = TXPOWER_FROM_DEV(txpower[i]);

/*
* Initialize hw_mode information.
*/
spec->supported_bands = SUPPORT_BAND_2GHZ;
spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
spec->tx_power_a = NULL;
spec->tx_power_bg = txpower;
spec->tx_power_default = DEFAULT_TXPOWER;

if (rt2x00_rf(&rt2x00dev->chip, RF2522)) {
spec->num_channels = ARRAY_SIZE(rf_vals_bg_2522);
Expand All @@ -1776,6 +1767,26 @@ static void rt2500pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
spec->num_channels = ARRAY_SIZE(rf_vals_5222);
spec->channels = rf_vals_5222;
}

/*
* Create channel information array
*/
info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
if (!info)
return -ENOMEM;

spec->channels_info = info;

tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_START);
for (i = 0; i < 14; i++)
info[i].tx_power1 = TXPOWER_FROM_DEV(tx_power[i]);

if (spec->num_channels > 14) {
for (i = 14; i < spec->num_channels; i++)
info[i].tx_power1 = DEFAULT_TXPOWER;
}

return 0;
}

static int rt2500pci_probe_hw(struct rt2x00_dev *rt2x00dev)
Expand All @@ -1796,7 +1807,9 @@ static int rt2500pci_probe_hw(struct rt2x00_dev *rt2x00dev)
/*
* Initialize hw specifications.
*/
rt2500pci_probe_hw_mode(rt2x00dev);
retval = rt2500pci_probe_hw_mode(rt2x00dev);
if (retval)
return retval;

/*
* This device requires the atim queue and DMA-mapped skbs.
Expand Down
17 changes: 5 additions & 12 deletions trunk/drivers/net/wireless/rt2x00/rt2500pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -1223,17 +1223,10 @@
#define MAX_TXPOWER 31
#define DEFAULT_TXPOWER 24

#define TXPOWER_FROM_DEV(__txpower) \
({ \
((__txpower) > MAX_TXPOWER) ? \
DEFAULT_TXPOWER : (__txpower); \
})

#define TXPOWER_TO_DEV(__txpower) \
({ \
((__txpower) <= MIN_TXPOWER) ? MIN_TXPOWER : \
(((__txpower) >= MAX_TXPOWER) ? MAX_TXPOWER : \
(__txpower)); \
})
#define TXPOWER_FROM_DEV(__txpower) \
(((u8)(__txpower)) > MAX_TXPOWER) ? DEFAULT_TXPOWER : (__txpower)

#define TXPOWER_TO_DEV(__txpower) \
clamp_t(char, __txpower, MIN_TXPOWER, MAX_TXPOWER)

#endif /* RT2500PCI_H */
39 changes: 26 additions & 13 deletions trunk/drivers/net/wireless/rt2x00/rt2500usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1665,10 +1665,11 @@ static const struct rf_channel rf_vals_5222[] = {
{ 161, 0x00022020, 0x000090be, 0x00000101, 0x00000a07 },
};

static void rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
static int rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
{
struct hw_mode_spec *spec = &rt2x00dev->spec;
u8 *txpower;
struct channel_info *info;
char *tx_power;
unsigned int i;

/*
Expand All @@ -1686,21 +1687,11 @@ static void rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
rt2x00_eeprom_addr(rt2x00dev,
EEPROM_MAC_ADDR_0));

/*
* Convert tx_power array in eeprom.
*/
txpower = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_START);
for (i = 0; i < 14; i++)
txpower[i] = TXPOWER_FROM_DEV(txpower[i]);

/*
* Initialize hw_mode information.
*/
spec->supported_bands = SUPPORT_BAND_2GHZ;
spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
spec->tx_power_a = NULL;
spec->tx_power_bg = txpower;
spec->tx_power_default = DEFAULT_TXPOWER;

if (rt2x00_rf(&rt2x00dev->chip, RF2522)) {
spec->num_channels = ARRAY_SIZE(rf_vals_bg_2522);
Expand All @@ -1722,6 +1713,26 @@ static void rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
spec->num_channels = ARRAY_SIZE(rf_vals_5222);
spec->channels = rf_vals_5222;
}

/*
* Create channel information array
*/
info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
if (!info)
return -ENOMEM;

spec->channels_info = info;

tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_START);
for (i = 0; i < 14; i++)
info[i].tx_power1 = TXPOWER_FROM_DEV(tx_power[i]);

if (spec->num_channels > 14) {
for (i = 14; i < spec->num_channels; i++)
info[i].tx_power1 = DEFAULT_TXPOWER;
}

return 0;
}

static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev)
Expand All @@ -1742,7 +1753,9 @@ static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev)
/*
* Initialize hw specifications.
*/
rt2500usb_probe_hw_mode(rt2x00dev);
retval = rt2500usb_probe_hw_mode(rt2x00dev);
if (retval)
return retval;

/*
* This device requires the atim queue
Expand Down
17 changes: 5 additions & 12 deletions trunk/drivers/net/wireless/rt2x00/rt2500usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -825,17 +825,10 @@
#define MAX_TXPOWER 31
#define DEFAULT_TXPOWER 24

#define TXPOWER_FROM_DEV(__txpower) \
({ \
((__txpower) > MAX_TXPOWER) ? \
DEFAULT_TXPOWER : (__txpower); \
})

#define TXPOWER_TO_DEV(__txpower) \
({ \
((__txpower) <= MIN_TXPOWER) ? MIN_TXPOWER : \
(((__txpower) >= MAX_TXPOWER) ? MAX_TXPOWER : \
(__txpower)); \
})
#define TXPOWER_FROM_DEV(__txpower) \
(((u8)(__txpower)) > MAX_TXPOWER) ? DEFAULT_TXPOWER : (__txpower)

#define TXPOWER_TO_DEV(__txpower) \
clamp_t(char, __txpower, MIN_TXPOWER, MAX_TXPOWER)

#endif /* RT2500USB_H */
23 changes: 15 additions & 8 deletions trunk/drivers/net/wireless/rt2x00/rt2x00.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ struct rf_channel {
u32 rf4;
};

/*
* Channel information structure
*/
struct channel_info {
unsigned int flags;
#define GEOGRAPHY_ALLOWED 0x00000001

short tx_power1;
short tx_power2;
};

/*
* Antenna setup values.
*/
Expand Down Expand Up @@ -394,10 +405,7 @@ static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
* @num_channels: Number of supported channels. This is used as array size
* for @tx_power_a, @tx_power_bg and @channels.
* @channels: Device/chipset specific channel values (See &struct rf_channel).
* @tx_power_a: TX power values for all 5.2GHz channels (may be NULL).
* @tx_power_bg: TX power values for all 2.4GHz channels (may be NULL).
* @tx_power_default: Default TX power value to use when either
* @tx_power_a or @tx_power_bg is missing.
* @channels_info: Additional information for channels (See &struct channel_info).
*/
struct hw_mode_spec {
unsigned int supported_bands;
Expand All @@ -410,10 +418,7 @@ struct hw_mode_spec {

unsigned int num_channels;
const struct rf_channel *channels;

const u8 *tx_power_a;
const u8 *tx_power_bg;
u8 tx_power_default;
const struct channel_info *channels_info;
};

/*
Expand All @@ -425,7 +430,9 @@ struct hw_mode_spec {
*/
struct rt2x00lib_conf {
struct ieee80211_conf *conf;

struct rf_channel rf;
struct channel_info channel;

struct antenna_setup ant;

Expand Down
4 changes: 4 additions & 0 deletions trunk/drivers/net/wireless/rt2x00/rt2x00config.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
memcpy(&libconf.rf,
&rt2x00dev->spec.channels[conf->channel->hw_value],
sizeof(libconf.rf));

memcpy(&libconf.channel,
&rt2x00dev->spec.channels_info[conf->channel->hw_value],
sizeof(libconf.channel));
}

if (flags & CONFIG_UPDATE_ANTENNA) {
Expand Down
Loading

0 comments on commit 05e7cb4

Please sign in to comment.