Search Linux Wireless

[RFC 1/5] mt76: introduce is_mt76x2 routine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add is_mt76x2 utility routine to check if device chip id is mt76x2.
Moreover move is_mt7612 in mt76.h. This is a preliminary patch to
share write_txwi routine between mt76x2 and mt76x0 drivers

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@xxxxxxxxxx>
---
 drivers/net/wireless/mediatek/mt76/mt76.h           | 13 +++++++++++++
 drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h  |  5 -----
 .../net/wireless/mediatek/mt76/mt76x2/pci_init.c    |  2 +-
 drivers/net/wireless/mediatek/mt76/mt76x2/pci_mcu.c |  2 +-
 drivers/net/wireless/mediatek/mt76/mt76x2/usb_mac.c |  2 +-
 drivers/net/wireless/mediatek/mt76/mt76x2/usb_mcu.c |  2 +-
 6 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index f2dd4d87e355..e9595ea9b0fb 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -516,6 +516,19 @@ static inline u16 mt76_rev(struct mt76_dev *dev)
 	return dev->rev & 0xffff;
 }
 
+static inline bool is_mt7612(struct mt76_dev *dev)
+{
+	return mt76_chip(dev) == 0x7612;
+}
+
+static inline bool is_mt76x2(struct mt76_dev *dev)
+{
+	return mt76_chip(dev) == 0x7612 ||
+	       mt76_chip(dev) == 0x7602 ||
+	       mt76_chip(dev) == 0x7662 ||
+	       mt76_chip(dev) == 0x7632;
+}
+
 #define mt76xx_chip(dev) mt76_chip(&((dev)->mt76))
 #define mt76xx_rev(dev) mt76_rev(&((dev)->mt76))
 
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h b/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h
index ecbb9e4ab888..c58aa251f0b6 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h
@@ -109,11 +109,6 @@ struct mt76x2_dev {
 	struct mt76x2_dfs_pattern_detector dfs_pd;
 };
 
-static inline bool is_mt7612(struct mt76x2_dev *dev)
-{
-	return mt76_chip(&dev->mt76) == 0x7612;
-}
-
 static inline bool mt76x2_channel_silent(struct mt76x2_dev *dev)
 {
 	struct ieee80211_channel *chan = dev->mt76.chandef.chan;
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
index 7036f4cbc836..56c6259cbf79 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
@@ -108,7 +108,7 @@ static int mt76x2_mac_reset(struct mt76x2_dev *dev, bool hard)
 		   MT_MAC_SYS_CTRL_RESET_CSR |
 		   MT_MAC_SYS_CTRL_RESET_BBP);
 
-	if (is_mt7612(dev))
+	if (is_mt7612(&dev->mt76))
 		mt76_clear(dev, MT_COEXCFG0, MT_COEXCFG0_COEX_EN);
 
 	mt76_set(dev, MT_EXT_CCA_CFG, 0x0000f000);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_mcu.c
index 38fa84bddf7b..ffb1301bd77d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_mcu.c
@@ -28,7 +28,7 @@ mt76pci_load_rom_patch(struct mt76x2_dev *dev)
 {
 	const struct firmware *fw = NULL;
 	struct mt76x02_patch_header *hdr;
-	bool rom_protect = !is_mt7612(dev);
+	bool rom_protect = !is_mt7612(&dev->mt76);
 	int len, ret = 0;
 	__le32 *cur;
 	u32 patch_mask, patch_reg;
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mac.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mac.c
index ae89461f803c..0045ff50eb35 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mac.c
@@ -103,7 +103,7 @@ int mt76x2u_mac_reset(struct mt76x2_dev *dev)
 		   MT_MAC_SYS_CTRL_RESET_CSR |
 		   MT_MAC_SYS_CTRL_RESET_BBP);
 
-	if (is_mt7612(dev))
+	if (is_mt7612(&dev->mt76))
 		mt76_clear(dev, MT_COEXCFG0, MT_COEXCFG0_COEX_EN);
 
 	mt76_set(dev, MT_EXT_CCA_CFG, 0xf000);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mcu.c
index 35e157be456c..06c03e9f627d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_mcu.c
@@ -91,7 +91,7 @@ static void mt76x2u_mcu_reset_wmt(struct mt76x2_dev *dev)
 
 static int mt76x2u_mcu_load_rom_patch(struct mt76x2_dev *dev)
 {
-	bool rom_protect = !is_mt7612(dev);
+	bool rom_protect = !is_mt7612(&dev->mt76);
 	struct mt76x02_patch_header *hdr;
 	u32 val, patch_mask, patch_reg;
 	const struct firmware *fw;
-- 
2.19.0




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux