ath9k: reorganize patches, reset hardware after full sleep (fixes #10349)
[openwrt.git] / 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 @@ -1610,6 +1610,53 @@ static const struct file_operations fops
4 };
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 @@ -1668,6 +1715,9 @@ 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 + debugfs_create_file("eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
62 + &fops_eeprom);
63 +
64 sc->debug.regidx = 0;
65 memset(&sc->debug.bb_mac_samp, 0, sizeof(sc->debug.bb_mac_samp));
66 sc->debug.sampidx = 0;
This page took 0.054566 seconds and 5 git commands to generate.