Skip to content

Commit

Permalink
mt76: move mt76 rate definitions in mt76x02-lib module
Browse files Browse the repository at this point in the history
Move mt76x2_rate definition in mt76x02-lib module and rename it in
mt76x02_rates in order to be reused in mt76x0 driver.
Moreover remove unused mt76_rate definition

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
Lorenzo Bianconi authored and Felix Fietkau committed Sep 19, 2018
1 parent 7c7b139 commit 58b5eb8
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 65 deletions.
32 changes: 2 additions & 30 deletions drivers/net/wireless/mediatek/mt76/mt76x0/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,34 +559,6 @@ static const struct ieee80211_channel mt76_channels_5ghz[] = {
CHAN5G(140, 5700),
};

#define CCK_RATE(_idx, _rate) { \
.bitrate = _rate, \
.flags = IEEE80211_RATE_SHORT_PREAMBLE, \
.hw_value = (MT_PHY_TYPE_CCK << 8) | _idx, \
.hw_value_short = (MT_PHY_TYPE_CCK << 8) | (8 + _idx), \
}

#define OFDM_RATE(_idx, _rate) { \
.bitrate = _rate, \
.hw_value = (MT_PHY_TYPE_OFDM << 8) | _idx, \
.hw_value_short = (MT_PHY_TYPE_OFDM << 8) | _idx, \
}

static struct ieee80211_rate mt76_rates[] = {
CCK_RATE(0, 10),
CCK_RATE(1, 20),
CCK_RATE(2, 55),
CCK_RATE(3, 110),
OFDM_RATE(0, 60),
OFDM_RATE(1, 90),
OFDM_RATE(2, 120),
OFDM_RATE(3, 180),
OFDM_RATE(4, 240),
OFDM_RATE(5, 360),
OFDM_RATE(6, 480),
OFDM_RATE(7, 540),
};

static int
mt76_init_sband(struct mt76x0_dev *dev, struct ieee80211_supported_band *sband,
const struct ieee80211_channel *chan, int n_chan,
Expand Down Expand Up @@ -634,7 +606,7 @@ mt76_init_sband_2g(struct mt76x0_dev *dev)

return mt76_init_sband(dev, &dev->mt76.sband_2g.sband,
mt76_channels_2ghz, ARRAY_SIZE(mt76_channels_2ghz),
mt76_rates, ARRAY_SIZE(mt76_rates));
mt76x02_rates, ARRAY_SIZE(mt76x02_rates));
}

static int
Expand All @@ -644,7 +616,7 @@ mt76_init_sband_5g(struct mt76x0_dev *dev)

return mt76_init_sband(dev, &dev->mt76.sband_5g.sband,
mt76_channels_5ghz, ARRAY_SIZE(mt76_channels_5ghz),
mt76_rates + 4, ARRAY_SIZE(mt76_rates) - 4);
mt76x02_rates + 4, ARRAY_SIZE(mt76x02_rates) - 4);
}


Expand Down
29 changes: 29 additions & 0 deletions drivers/net/wireless/mediatek/mt76/mt76x02_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,35 @@
#include "mt76x02_regs.h"
#include "mt76x02_mac.h"

#define CCK_RATE(_idx, _rate) { \
.bitrate = _rate, \
.flags = IEEE80211_RATE_SHORT_PREAMBLE, \
.hw_value = (MT_PHY_TYPE_CCK << 8) | _idx, \
.hw_value_short = (MT_PHY_TYPE_CCK << 8) | (8 + _idx), \
}

#define OFDM_RATE(_idx, _rate) { \
.bitrate = _rate, \
.hw_value = (MT_PHY_TYPE_OFDM << 8) | _idx, \
.hw_value_short = (MT_PHY_TYPE_OFDM << 8) | _idx, \
}

struct ieee80211_rate mt76x02_rates[] = {
CCK_RATE(0, 10),
CCK_RATE(1, 20),
CCK_RATE(2, 55),
CCK_RATE(3, 110),
OFDM_RATE(0, 60),
OFDM_RATE(1, 90),
OFDM_RATE(2, 120),
OFDM_RATE(3, 180),
OFDM_RATE(4, 240),
OFDM_RATE(5, 360),
OFDM_RATE(6, 480),
OFDM_RATE(7, 540),
};
EXPORT_SYMBOL_GPL(mt76x02_rates);

void mt76x02_configure_filter(struct ieee80211_hw *hw,
unsigned int changed_flags,
unsigned int *total_flags, u64 multicast)
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/wireless/mediatek/mt76/mt76x02_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#ifndef __MT76X02_UTIL_H
#define __MT76X02_UTIL_H

extern struct ieee80211_rate mt76x02_rates[12];

void mt76x02_configure_filter(struct ieee80211_hw *hw,
unsigned int changed_flags,
unsigned int *total_flags, u64 multicast);
Expand Down
2 changes: 0 additions & 2 deletions drivers/net/wireless/mediatek/mt76/mt76x2.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@ static inline bool wait_for_wpdma(struct mt76x2_dev *dev)

extern const struct ieee80211_ops mt76x2_ops;

extern struct ieee80211_rate mt76x2_rates[12];

struct mt76x2_dev *mt76x2_alloc_device(struct device *pdev);
int mt76x2_register_device(struct mt76x2_dev *dev);
void mt76x2_init_debugfs(struct mt76x2_dev *dev);
Expand Down
5 changes: 3 additions & 2 deletions drivers/net/wireless/mediatek/mt76/mt76x2_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "mt76x2.h"
#include "mt76x2_eeprom.h"
#include "mt76x2_mcu.h"
#include "mt76x02_util.h"

static void
mt76x2_mac_pbf_init(struct mt76x2_dev *dev)
Expand Down Expand Up @@ -584,8 +585,8 @@ int mt76x2_register_device(struct mt76x2_dev *dev)
dev->mt76.led_cdev.brightness_set = mt76x2_led_set_brightness;
dev->mt76.led_cdev.blink_set = mt76x2_led_set_blink;

ret = mt76_register_device(&dev->mt76, true, mt76x2_rates,
ARRAY_SIZE(mt76x2_rates));
ret = mt76_register_device(&dev->mt76, true, mt76x02_rates,
ARRAY_SIZE(mt76x02_rates));
if (ret)
goto fail;

Expand Down
29 changes: 0 additions & 29 deletions drivers/net/wireless/mediatek/mt76/mt76x2_init_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,6 @@
#include "mt76x2.h"
#include "mt76x2_eeprom.h"

#define CCK_RATE(_idx, _rate) { \
.bitrate = _rate, \
.flags = IEEE80211_RATE_SHORT_PREAMBLE, \
.hw_value = (MT_PHY_TYPE_CCK << 8) | _idx, \
.hw_value_short = (MT_PHY_TYPE_CCK << 8) | (8 + _idx), \
}

#define OFDM_RATE(_idx, _rate) { \
.bitrate = _rate, \
.hw_value = (MT_PHY_TYPE_OFDM << 8) | _idx, \
.hw_value_short = (MT_PHY_TYPE_OFDM << 8) | _idx, \
}

struct ieee80211_rate mt76x2_rates[] = {
CCK_RATE(0, 10),
CCK_RATE(1, 20),
CCK_RATE(2, 55),
CCK_RATE(3, 110),
OFDM_RATE(0, 60),
OFDM_RATE(1, 90),
OFDM_RATE(2, 120),
OFDM_RATE(3, 180),
OFDM_RATE(4, 240),
OFDM_RATE(5, 360),
OFDM_RATE(6, 480),
OFDM_RATE(7, 540),
};
EXPORT_SYMBOL_GPL(mt76x2_rates);

static void
mt76x2_set_wlan_state(struct mt76x2_dev *dev, bool enable)
{
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/mediatek/mt76/mt76x2u_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ int mt76x2u_register_device(struct mt76x2_dev *dev)

wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);

err = mt76_register_device(&dev->mt76, true, mt76x2_rates,
ARRAY_SIZE(mt76x2_rates));
err = mt76_register_device(&dev->mt76, true, mt76x02_rates,
ARRAY_SIZE(mt76x02_rates));
if (err)
goto fail;

Expand Down

0 comments on commit 58b5eb8

Please sign in to comment.