| b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | --- a/drivers/net/wireless/ath/ath9k/debug.c |
| 2 | +++ b/drivers/net/wireless/ath/ath9k/debug.c |
| 3 | @@ -1364,6 +1364,53 @@ void ath9k_deinit_debug(struct ath_softc |
| 4 | ath9k_cmn_spectral_deinit_debug(&sc->spec_priv); |
| 5 | } |
| 6 | |
| 7 | +static ssize_t read_file_eeprom(struct file *file, char __user *user_buf, |
| 8 | + size_t count, loff_t *ppos) |
| 9 | +{ |
| 10 | + struct ath_softc *sc = file->private_data; |
| 11 | + struct ath_hw *ah = sc->sc_ah; |
| 12 | + struct ath_common *common = ath9k_hw_common(ah); |
| 13 | + int bytes = 0; |
| 14 | + int pos = *ppos; |
| 15 | + int size = 4096; |
| 16 | + u16 val; |
| 17 | + int i; |
| 18 | + |
| 19 | + if (AR_SREV_9300_20_OR_LATER(ah)) |
| 20 | + size = 16384; |
| 21 | + |
| 22 | + if (*ppos < 0) |
| 23 | + return -EINVAL; |
| 24 | + |
| 25 | + if (count > size - *ppos) |
| 26 | + count = size - *ppos; |
| 27 | + |
| 28 | + for (i = *ppos / 2; count > 0; count -= bytes, *ppos += bytes, i++) { |
| 29 | + void *from = &val; |
| 30 | + |
| 31 | + if (!common->bus_ops->eeprom_read(common, i, &val)) |
| 32 | + val = 0xffff; |
| 33 | + |
| 34 | + if (*ppos % 2) { |
| 35 | + from++; |
| 36 | + bytes = 1; |
| 37 | + } else if (count == 1) { |
| 38 | + bytes = 1; |
| 39 | + } else { |
| 40 | + bytes = 2; |
| 41 | + } |
| 42 | + copy_to_user(user_buf, from, bytes); |
| 43 | + user_buf += bytes; |
| 44 | + } |
| 45 | + return *ppos - pos; |
| 46 | +} |
| 47 | + |
| 48 | +static const struct file_operations fops_eeprom = { |
| 49 | + .read = read_file_eeprom, |
| 50 | + .open = simple_open, |
| 51 | + .owner = THIS_MODULE |
| 52 | +}; |
| 53 | + |
| 54 | int ath9k_init_debug(struct ath_hw *ah) |
| 55 | { |
| 56 | struct ath_common *common = ath9k_hw_common(ah); |
| 57 | @@ -1383,6 +1430,8 @@ int ath9k_init_debug(struct ath_hw *ah) |
| 58 | ath9k_tx99_init_debug(sc); |
| 59 | ath9k_cmn_spectral_init_debug(&sc->spec_priv, sc->debug.debugfs_phy); |
| 60 | |
| 61 | + debugfs_create_file("eeprom", S_IRUSR, sc->debug.debugfs_phy, sc, |
| 62 | + &fops_eeprom); |
| 63 | debugfs_create_devm_seqfile(sc->dev, "dma", sc->debug.debugfs_phy, |
| 64 | read_file_dma); |
| 65 | debugfs_create_devm_seqfile(sc->dev, "interrupt", sc->debug.debugfs_phy, |