mt76: move mt76x02_debugfs in mt76x02-lib module
authorLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Mon, 15 Oct 2018 09:33:13 +0000 (11:33 +0200)
committerFelix Fietkau <nbd@nbd.name>
Fri, 30 Nov 2018 11:21:39 +0000 (12:21 +0100)
Move mt76x02_debugfs in mt76x02-lib module in order to
be reused by mt76x0 driver and remove duplicated code

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/Makefile
drivers/net/wireless/mediatek/mt76/mt76x02.h
drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c [new file with mode: 0644]
drivers/net/wireless/mediatek/mt76/mt76x2/Makefile
drivers/net/wireless/mediatek/mt76/mt76x2/debugfs.c [deleted file]
drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h
drivers/net/wireless/mediatek/mt76/mt76x2/pci_init.c
drivers/net/wireless/mediatek/mt76/mt76x2/usb_init.c

index 9b8d7488c5454dfe1d17aea07db022b61400bcf1..a737a518802f301bc5d44be7e1a9c2aa8ba5753c 100644 (file)
@@ -14,7 +14,7 @@ CFLAGS_mt76x02_trace.o := -I$(src)
 
 mt76x02-lib-y := mt76x02_util.o mt76x02_mac.o mt76x02_mcu.o \
                 mt76x02_eeprom.o mt76x02_phy.o mt76x02_mmio.o \
-                mt76x02_txrx.o mt76x02_trace.o
+                mt76x02_txrx.o mt76x02_trace.o mt76x02_debugfs.o
 
 mt76x02-usb-y := mt76x02_usb_mcu.o mt76x02_usb_core.o
 
index 189c697973bdb2125149b96920936c93a1101554..58721307d9173ad1842a61a3a3272324d43b7bcf 100644 (file)
@@ -162,6 +162,8 @@ void mt76x02_set_beacon_offsets(struct mt76x02_dev *dev);
 void mt76x02_set_irq_mask(struct mt76x02_dev *dev, u32 clear, u32 set);
 void mt76x02_mac_start(struct mt76x02_dev *dev);
 
+void mt76x02_init_debugfs(struct mt76x02_dev *dev);
+
 static inline bool is_mt76x2(struct mt76x02_dev *dev)
 {
        return mt76_chip(&dev->mt76) == 0x7612 ||
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c b/drivers/net/wireless/mediatek/mt76/mt76x02_debugfs.c
new file mode 100644 (file)
index 0000000..a9d52ba
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <linux/debugfs.h>
+#include "mt76x02.h"
+
+static int
+mt76x02_ampdu_stat_read(struct seq_file *file, void *data)
+{
+       struct mt76x02_dev *dev = file->private;
+       int i, j;
+
+       for (i = 0; i < 4; i++) {
+               seq_puts(file, "Length: ");
+               for (j = 0; j < 8; j++)
+                       seq_printf(file, "%8d | ", i * 8 + j + 1);
+               seq_puts(file, "\n");
+               seq_puts(file, "Count:  ");
+               for (j = 0; j < 8; j++)
+                       seq_printf(file, "%8d | ", dev->aggr_stats[i * 8 + j]);
+               seq_puts(file, "\n");
+               seq_puts(file, "--------");
+               for (j = 0; j < 8; j++)
+                       seq_puts(file, "-----------");
+               seq_puts(file, "\n");
+       }
+
+       return 0;
+}
+
+static int
+mt76x02_ampdu_stat_open(struct inode *inode, struct file *f)
+{
+       return single_open(f, mt76x02_ampdu_stat_read, inode->i_private);
+}
+
+static int read_txpower(struct seq_file *file, void *data)
+{
+       struct mt76x02_dev *dev = dev_get_drvdata(file->private);
+
+       seq_printf(file, "Target power: %d\n", dev->target_power);
+
+       mt76_seq_puts_array(file, "Delta", dev->target_power_delta,
+                           ARRAY_SIZE(dev->target_power_delta));
+       return 0;
+}
+
+static const struct file_operations fops_ampdu_stat = {
+       .open = mt76x02_ampdu_stat_open,
+       .read = seq_read,
+       .llseek = seq_lseek,
+       .release = single_release,
+};
+
+static int
+mt76x02_dfs_stat_read(struct seq_file *file, void *data)
+{
+       struct mt76x02_dev *dev = file->private;
+       struct mt76x02_dfs_pattern_detector *dfs_pd = &dev->dfs_pd;
+       int i;
+
+       seq_printf(file, "allocated sequences:\t%d\n",
+                  dfs_pd->seq_stats.seq_pool_len);
+       seq_printf(file, "used sequences:\t\t%d\n",
+                  dfs_pd->seq_stats.seq_len);
+       seq_puts(file, "\n");
+
+       for (i = 0; i < MT_DFS_NUM_ENGINES; i++) {
+               seq_printf(file, "engine: %d\n", i);
+               seq_printf(file, "  hw pattern detected:\t%d\n",
+                          dfs_pd->stats[i].hw_pattern);
+               seq_printf(file, "  hw pulse discarded:\t%d\n",
+                          dfs_pd->stats[i].hw_pulse_discarded);
+               seq_printf(file, "  sw pattern detected:\t%d\n",
+                          dfs_pd->stats[i].sw_pattern);
+       }
+
+       return 0;
+}
+
+static int
+mt76x02_dfs_stat_open(struct inode *inode, struct file *f)
+{
+       return single_open(f, mt76x02_dfs_stat_read, inode->i_private);
+}
+
+static const struct file_operations fops_dfs_stat = {
+       .open = mt76x02_dfs_stat_open,
+       .read = seq_read,
+       .llseek = seq_lseek,
+       .release = single_release,
+};
+
+static int read_agc(struct seq_file *file, void *data)
+{
+       struct mt76x02_dev *dev = dev_get_drvdata(file->private);
+
+       seq_printf(file, "avg_rssi: %d\n", dev->cal.avg_rssi_all);
+       seq_printf(file, "low_gain: %d\n", dev->cal.low_gain);
+       seq_printf(file, "false_cca: %d\n", dev->cal.false_cca);
+       seq_printf(file, "agc_gain_adjust: %d\n", dev->cal.agc_gain_adjust);
+
+       return 0;
+}
+
+void mt76x02_init_debugfs(struct mt76x02_dev *dev)
+{
+       struct dentry *dir;
+
+       dir = mt76_register_debugfs(&dev->mt76);
+       if (!dir)
+               return;
+
+       debugfs_create_u8("temperature", 0400, dir, &dev->cal.temp);
+       debugfs_create_bool("tpc", 0600, dir, &dev->enable_tpc);
+
+       debugfs_create_file("ampdu_stat", 0400, dir, dev, &fops_ampdu_stat);
+       debugfs_create_file("dfs_stats", 0400, dir, dev, &fops_dfs_stat);
+       debugfs_create_devm_seqfile(dev->mt76.dev, "txpower", dir,
+                                   read_txpower);
+
+       debugfs_create_devm_seqfile(dev->mt76.dev, "agc", dir, read_agc);
+}
+EXPORT_SYMBOL_GPL(mt76x02_init_debugfs);
index b71bb10491701bd45e005fd29353d8e7c7a65788..696f071f47f86e5e31de9b44d55549f1de00f2ff 100644 (file)
@@ -3,7 +3,7 @@ obj-$(CONFIG_MT76x2E) += mt76x2e.o
 obj-$(CONFIG_MT76x2U) += mt76x2u.o
 
 mt76x2-common-y := \
-       eeprom.o mac.o init.o phy.o debugfs.o mcu.o
+       eeprom.o mac.o init.o phy.o mcu.o
 
 mt76x2e-y := \
        pci.o pci_main.o pci_init.o pci_tx.o \
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt76x2/debugfs.c
deleted file mode 100644 (file)
index e8f8ccc..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <linux/debugfs.h>
-#include "mt76x2.h"
-
-static int
-mt76x2_ampdu_stat_read(struct seq_file *file, void *data)
-{
-       struct mt76x02_dev *dev = file->private;
-       int i, j;
-
-       for (i = 0; i < 4; i++) {
-               seq_puts(file, "Length: ");
-               for (j = 0; j < 8; j++)
-                       seq_printf(file, "%8d | ", i * 8 + j + 1);
-               seq_puts(file, "\n");
-               seq_puts(file, "Count:  ");
-               for (j = 0; j < 8; j++)
-                       seq_printf(file, "%8d | ", dev->aggr_stats[i * 8 + j]);
-               seq_puts(file, "\n");
-               seq_puts(file, "--------");
-               for (j = 0; j < 8; j++)
-                       seq_puts(file, "-----------");
-               seq_puts(file, "\n");
-       }
-
-       return 0;
-}
-
-static int
-mt76x2_ampdu_stat_open(struct inode *inode, struct file *f)
-{
-       return single_open(f, mt76x2_ampdu_stat_read, inode->i_private);
-}
-
-static int read_txpower(struct seq_file *file, void *data)
-{
-       struct mt76x02_dev *dev = dev_get_drvdata(file->private);
-
-       seq_printf(file, "Target power: %d\n", dev->target_power);
-
-       mt76_seq_puts_array(file, "Delta", dev->target_power_delta,
-                           ARRAY_SIZE(dev->target_power_delta));
-       return 0;
-}
-
-static const struct file_operations fops_ampdu_stat = {
-       .open = mt76x2_ampdu_stat_open,
-       .read = seq_read,
-       .llseek = seq_lseek,
-       .release = single_release,
-};
-
-static int
-mt76x2_dfs_stat_read(struct seq_file *file, void *data)
-{
-       struct mt76x02_dev *dev = file->private;
-       struct mt76x02_dfs_pattern_detector *dfs_pd = &dev->dfs_pd;
-       int i;
-
-       seq_printf(file, "allocated sequences:\t%d\n",
-                  dfs_pd->seq_stats.seq_pool_len);
-       seq_printf(file, "used sequences:\t\t%d\n",
-                  dfs_pd->seq_stats.seq_len);
-       seq_puts(file, "\n");
-
-       for (i = 0; i < MT_DFS_NUM_ENGINES; i++) {
-               seq_printf(file, "engine: %d\n", i);
-               seq_printf(file, "  hw pattern detected:\t%d\n",
-                          dfs_pd->stats[i].hw_pattern);
-               seq_printf(file, "  hw pulse discarded:\t%d\n",
-                          dfs_pd->stats[i].hw_pulse_discarded);
-               seq_printf(file, "  sw pattern detected:\t%d\n",
-                          dfs_pd->stats[i].sw_pattern);
-       }
-
-       return 0;
-}
-
-static int
-mt76x2_dfs_stat_open(struct inode *inode, struct file *f)
-{
-       return single_open(f, mt76x2_dfs_stat_read, inode->i_private);
-}
-
-static const struct file_operations fops_dfs_stat = {
-       .open = mt76x2_dfs_stat_open,
-       .read = seq_read,
-       .llseek = seq_lseek,
-       .release = single_release,
-};
-
-static int read_agc(struct seq_file *file, void *data)
-{
-       struct mt76x02_dev *dev = dev_get_drvdata(file->private);
-
-       seq_printf(file, "avg_rssi: %d\n", dev->cal.avg_rssi_all);
-       seq_printf(file, "low_gain: %d\n", dev->cal.low_gain);
-       seq_printf(file, "false_cca: %d\n", dev->cal.false_cca);
-       seq_printf(file, "agc_gain_adjust: %d\n", dev->cal.agc_gain_adjust);
-
-       return 0;
-}
-
-void mt76x2_init_debugfs(struct mt76x02_dev *dev)
-{
-       struct dentry *dir;
-
-       dir = mt76_register_debugfs(&dev->mt76);
-       if (!dir)
-               return;
-
-       debugfs_create_u8("temperature", 0400, dir, &dev->cal.temp);
-       debugfs_create_bool("tpc", 0600, dir, &dev->enable_tpc);
-
-       debugfs_create_file("ampdu_stat", 0400, dir, dev, &fops_ampdu_stat);
-       debugfs_create_file("dfs_stats", 0400, dir, dev, &fops_dfs_stat);
-       debugfs_create_devm_seqfile(dev->mt76.dev, "txpower", dir,
-                                   read_txpower);
-
-       debugfs_create_devm_seqfile(dev->mt76.dev, "agc", dir, read_agc);
-}
-EXPORT_SYMBOL_GPL(mt76x2_init_debugfs);
index eca142ac656d3eaecef74c35e9d16febbab1a110..7408db7884099a2c0a186a5bccb5e98c3744961c 100644 (file)
@@ -52,7 +52,6 @@ extern const struct ieee80211_ops mt76x2_ops;
 
 struct mt76x02_dev *mt76x2_alloc_device(struct device *pdev);
 int mt76x2_register_device(struct mt76x02_dev *dev);
-void mt76x2_init_debugfs(struct mt76x02_dev *dev);
 void mt76x2_init_device(struct mt76x02_dev *dev);
 
 void mt76x2_phy_power_on(struct mt76x02_dev *dev);
index 0dea7d7b17a3373f39d529f110d548707542c661..5b167aaaf7f7aadaa6369d61a6bea5f6fca97344 100644 (file)
@@ -515,7 +515,7 @@ int mt76x2_register_device(struct mt76x02_dev *dev)
        if (ret)
                goto fail;
 
-       mt76x2_init_debugfs(dev);
+       mt76x02_init_debugfs(dev);
        mt76x2_init_txpower(dev, &dev->mt76.sband_2g.sband);
        mt76x2_init_txpower(dev, &dev->mt76.sband_5g.sband);
 
index 13cce29375739d431312cbe2ee86351bb71c02ab..dfc80ecfde922121f9bf107cc66ab61c448a79ef 100644 (file)
@@ -282,7 +282,7 @@ int mt76x2u_register_device(struct mt76x02_dev *dev)
 
        set_bit(MT76_STATE_INITIALIZED, &dev->mt76.state);
 
-       mt76x2_init_debugfs(dev);
+       mt76x02_init_debugfs(dev);
        mt76x2_init_txpower(dev, &dev->mt76.sband_2g.sband);
        mt76x2_init_txpower(dev, &dev->mt76.sband_5g.sband);