From 8d93a4f9ccfdeba2c6a2b6d1e070e4974734fe8c Mon Sep 17 00:00:00 2001 From: Junlin Yang Date: Sat, 27 Mar 2021 17:56:17 +0800 Subject: [PATCH] mt76: Convert to DEFINE_SHOW_ATTRIBUTE Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code. Signed-off-by: Junlin Yang Signed-off-by: David S. Miller --- .../wireless/mediatek/mt76/mt7915/debugfs.c | 36 ++++--------------- .../wireless/mediatek/mt76/mt7921/debugfs.c | 18 ++-------- 2 files changed, 9 insertions(+), 45 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c index 77dcd71e49a5..7bef36feb9c7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c @@ -192,7 +192,7 @@ mt7915_txbf_stat_read_phy(struct mt7915_phy *phy, struct seq_file *s) } static int -mt7915_tx_stats_read(struct seq_file *file, void *data) +mt7915_tx_stats_show(struct seq_file *file, void *data) { struct mt7915_dev *dev = file->private; int stat[8], i, n; @@ -222,19 +222,7 @@ mt7915_tx_stats_read(struct seq_file *file, void *data) return 0; } -static int -mt7915_tx_stats_open(struct inode *inode, struct file *f) -{ - return single_open(f, mt7915_tx_stats_read, inode->i_private); -} - -static const struct file_operations fops_tx_stats = { - .open = mt7915_tx_stats_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .owner = THIS_MODULE, -}; +DEFINE_SHOW_ATTRIBUTE(mt7915_tx_stats); static int mt7915_read_temperature(struct seq_file *s, void *data) { @@ -379,7 +367,7 @@ int mt7915_init_debugfs(struct mt7915_dev *dev) mt7915_queues_read); debugfs_create_devm_seqfile(dev->mt76.dev, "acq", dir, mt7915_queues_acq); - debugfs_create_file("tx_stats", 0400, dir, dev, &fops_tx_stats); + debugfs_create_file("tx_stats", 0400, dir, dev, &mt7915_tx_stats_fops); debugfs_create_file("fw_debug", 0600, dir, dev, &fops_fw_debug); debugfs_create_file("implicit_txbf", 0600, dir, dev, &fops_implicit_txbf); @@ -412,7 +400,7 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_fixed_rate, NULL, mt7915_sta_fixed_rate_set, "%llx\n"); static int -mt7915_sta_stats_read(struct seq_file *s, void *data) +mt7915_sta_stats_show(struct seq_file *s, void *data) { struct ieee80211_sta *sta = s->private; struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; @@ -455,24 +443,12 @@ mt7915_sta_stats_read(struct seq_file *s, void *data) return 0; } -static int -mt7915_sta_stats_open(struct inode *inode, struct file *f) -{ - return single_open(f, mt7915_sta_stats_read, inode->i_private); -} - -static const struct file_operations fops_sta_stats = { - .open = mt7915_sta_stats_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .owner = THIS_MODULE, -}; +DEFINE_SHOW_ATTRIBUTE(mt7915_sta_stats); void mt7915_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct dentry *dir) { debugfs_create_file("fixed_rate", 0600, dir, sta, &fops_fixed_rate); - debugfs_create_file("stats", 0400, dir, sta, &fops_sta_stats); + debugfs_create_file("stats", 0400, dir, sta, &mt7915_sta_stats_fops); } #endif diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c index 0dc8e25e18e4..c1a64ff6a197 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c @@ -62,7 +62,7 @@ mt7921_ampdu_stat_read_phy(struct mt7921_phy *phy, } static int -mt7921_tx_stats_read(struct seq_file *file, void *data) +mt7921_tx_stats_show(struct seq_file *file, void *data) { struct mt7921_dev *dev = file->private; int stat[8], i, n; @@ -88,19 +88,7 @@ mt7921_tx_stats_read(struct seq_file *file, void *data) return 0; } -static int -mt7921_tx_stats_open(struct inode *inode, struct file *f) -{ - return single_open(f, mt7921_tx_stats_read, inode->i_private); -} - -static const struct file_operations fops_tx_stats = { - .open = mt7921_tx_stats_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .owner = THIS_MODULE, -}; +DEFINE_SHOW_ATTRIBUTE(mt7921_tx_stats); static int mt7921_queues_acq(struct seq_file *s, void *data) @@ -239,7 +227,7 @@ int mt7921_init_debugfs(struct mt7921_dev *dev) mt7921_queues_read); debugfs_create_devm_seqfile(dev->mt76.dev, "acq", dir, mt7921_queues_acq); - debugfs_create_file("tx_stats", 0400, dir, dev, &fops_tx_stats); + debugfs_create_file("tx_stats", 0400, dir, dev, &mt7921_tx_stats_fops); debugfs_create_file("fw_debug", 0600, dir, dev, &fops_fw_debug); debugfs_create_file("runtime-pm", 0600, dir, dev, &fops_pm); debugfs_create_file("idle-timeout", 0600, dir, dev,