mac80211: update to 2014-10-08
[openwrt/svn-archive/archive.git] / package / kernel / 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 @@ -1313,6 +1313,53 @@ void ath9k_deinit_debug(struct ath_softc
4 ath9k_spectral_deinit_debug(sc);
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 @@ -1332,6 +1379,8 @@ int ath9k_init_debug(struct ath_hw *ah)
58 ath9k_tx99_init_debug(sc);
59 ath9k_spectral_init_debug(sc);
60
61 + debugfs_create_file("eeprom", S_IRUSR, sc->debug.debugfs_phy, sc,
62 + &fops_eeprom);
63 debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
64 &fops_dma);
65 debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc,