mt76: overwrite default reg_ops if necessary
Introduce mt76_register_debugfs_fops routine in order to define per-driver regs file operations and make sure the device is up before reading or writing its registers Fixes:1d8efc741d
("mt76: mt7921: introduce Runtime PM support") Fixes:de5ff3c9d1
("mt76: mt7615: introduce pm_power_save delayed work") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
890809ca19
commit
f6e1f59885
|
@ -116,8 +116,11 @@ static int mt76_read_rate_txpower(struct seq_file *s, void *data)
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct dentry *mt76_register_debugfs(struct mt76_dev *dev)
|
||||
struct dentry *
|
||||
mt76_register_debugfs_fops(struct mt76_dev *dev,
|
||||
const struct file_operations *ops)
|
||||
{
|
||||
const struct file_operations *fops = ops ? ops : &fops_regval;
|
||||
struct dentry *dir;
|
||||
|
||||
dir = debugfs_create_dir("mt76", dev->hw->wiphy->debugfsdir);
|
||||
|
@ -126,8 +129,7 @@ struct dentry *mt76_register_debugfs(struct mt76_dev *dev)
|
|||
|
||||
debugfs_create_u8("led_pin", 0600, dir, &dev->led_pin);
|
||||
debugfs_create_u32("regidx", 0600, dir, &dev->debugfs_reg);
|
||||
debugfs_create_file_unsafe("regval", 0600, dir, dev,
|
||||
&fops_regval);
|
||||
debugfs_create_file_unsafe("regval", 0600, dir, dev, fops);
|
||||
debugfs_create_file_unsafe("napi_threaded", 0600, dir, dev,
|
||||
&fops_napi_threaded);
|
||||
debugfs_create_blob("eeprom", 0400, dir, &dev->eeprom);
|
||||
|
@ -140,4 +142,4 @@ struct dentry *mt76_register_debugfs(struct mt76_dev *dev)
|
|||
|
||||
return dir;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mt76_register_debugfs);
|
||||
EXPORT_SYMBOL_GPL(mt76_register_debugfs_fops);
|
||||
|
|
|
@ -879,7 +879,13 @@ struct mt76_phy *mt76_alloc_phy(struct mt76_dev *dev, unsigned int size,
|
|||
int mt76_register_phy(struct mt76_phy *phy, bool vht,
|
||||
struct ieee80211_rate *rates, int n_rates);
|
||||
|
||||
struct dentry *mt76_register_debugfs(struct mt76_dev *dev);
|
||||
struct dentry *mt76_register_debugfs_fops(struct mt76_dev *dev,
|
||||
const struct file_operations *ops);
|
||||
static inline struct dentry *mt76_register_debugfs(struct mt76_dev *dev)
|
||||
{
|
||||
return mt76_register_debugfs_fops(dev, NULL);
|
||||
}
|
||||
|
||||
int mt76_queues_read(struct seq_file *s, void *data);
|
||||
void mt76_seq_puts_array(struct seq_file *file, const char *str,
|
||||
s8 *val, int len);
|
||||
|
|
|
@ -2,6 +2,33 @@
|
|||
|
||||
#include "mt7615.h"
|
||||
|
||||
static int
|
||||
mt7615_reg_set(void *data, u64 val)
|
||||
{
|
||||
struct mt7615_dev *dev = data;
|
||||
|
||||
mt7615_mutex_acquire(dev);
|
||||
mt76_wr(dev, dev->mt76.debugfs_reg, val);
|
||||
mt7615_mutex_release(dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
mt7615_reg_get(void *data, u64 *val)
|
||||
{
|
||||
struct mt7615_dev *dev = data;
|
||||
|
||||
mt7615_mutex_acquire(dev);
|
||||
*val = mt76_rr(dev, dev->mt76.debugfs_reg);
|
||||
mt7615_mutex_release(dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_DEBUGFS_ATTRIBUTE(fops_regval, mt7615_reg_get, mt7615_reg_set,
|
||||
"0x%08llx\n");
|
||||
|
||||
static int
|
||||
mt7615_radar_pattern_set(void *data, u64 val)
|
||||
{
|
||||
|
@ -506,7 +533,7 @@ int mt7615_init_debugfs(struct mt7615_dev *dev)
|
|||
{
|
||||
struct dentry *dir;
|
||||
|
||||
dir = mt76_register_debugfs(&dev->mt76);
|
||||
dir = mt76_register_debugfs_fops(&dev->mt76, &fops_regval);
|
||||
if (!dir)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -4,6 +4,32 @@
|
|||
#include "mt7921.h"
|
||||
#include "eeprom.h"
|
||||
|
||||
static int
|
||||
mt7921_reg_set(void *data, u64 val)
|
||||
{
|
||||
struct mt7921_dev *dev = data;
|
||||
|
||||
mt7921_mutex_acquire(dev);
|
||||
mt76_wr(dev, dev->mt76.debugfs_reg, val);
|
||||
mt7921_mutex_release(dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
mt7921_reg_get(void *data, u64 *val)
|
||||
{
|
||||
struct mt7921_dev *dev = data;
|
||||
|
||||
mt7921_mutex_acquire(dev);
|
||||
*val = mt76_rr(dev, dev->mt76.debugfs_reg);
|
||||
mt7921_mutex_release(dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_DEBUGFS_ATTRIBUTE(fops_regval, mt7921_reg_get, mt7921_reg_set,
|
||||
"0x%08llx\n");
|
||||
static int
|
||||
mt7921_fw_debug_set(void *data, u64 val)
|
||||
{
|
||||
|
@ -381,7 +407,7 @@ int mt7921_init_debugfs(struct mt7921_dev *dev)
|
|||
{
|
||||
struct dentry *dir;
|
||||
|
||||
dir = mt76_register_debugfs(&dev->mt76);
|
||||
dir = mt76_register_debugfs_fops(&dev->mt76, &fops_regval);
|
||||
if (!dir)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
Loading…
Reference in New Issue