Root/package/mac80211/patches/500-ath9k_eeprom_debugfs.patch

1--- a/drivers/net/wireless/ath/ath9k/debug.c
2+++ b/drivers/net/wireless/ath/ath9k/debug.c
3@@ -1007,6 +1007,53 @@ static const struct file_operations fops
4     .llseek = default_llseek,
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 = ath9k_debugfs_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@@ -1077,6 +1124,10 @@ int ath9k_init_debug(struct ath_hw *ah)
58     debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR,
59                sc->debug.debugfs_phy, &sc->sc_ah->gpio_val);
60 
61+ if (!debugfs_create_file("eeprom", S_IRUSR,
62+ sc->debug.debugfs_phy, sc, &fops_eeprom))
63+ goto err;
64+
65     sc->debug.regidx = 0;
66     return 0;
67 err:
68

Archive Download this file



interactive