d23d70b2ce7d177336c07da7dede2aff2d9cd769
[openwrt/staging/jow.git] / package / kernel / mac80211 / patches / ath9k / 500-ath9k_eeprom_debugfs.patch
1 --- a/drivers/net/wireless/ath/ath9k/debug.c
2 +++ b/drivers/net/wireless/ath/ath9k/debug.c
3 @@ -1471,6 +1471,7 @@ int ath9k_init_debug(struct ath_hw *ah)
4
5 ath9k_cmn_debug_base_eeprom(sc->debug.debugfs_phy, sc->sc_ah);
6 ath9k_cmn_debug_modal_eeprom(sc->debug.debugfs_phy, sc->sc_ah);
7 + ath9k_cmn_debug_eeprom(sc->debug.debugfs_phy, sc->sc_ah);
8
9 debugfs_create_u32("gpio_mask", 0600,
10 sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
11 --- a/drivers/net/wireless/ath/ath9k/common-debug.c
12 +++ b/drivers/net/wireless/ath/ath9k/common-debug.c
13 @@ -260,3 +260,58 @@ void ath9k_cmn_debug_phy_err(struct dent
14 &fops_phy_err);
15 }
16 EXPORT_SYMBOL(ath9k_cmn_debug_phy_err);
17 +
18 +static ssize_t read_file_eeprom(struct file *file, char __user *user_buf,
19 + size_t count, loff_t *ppos)
20 +{
21 + struct ath_hw *ah = file->private_data;
22 + struct ath_common *common = ath9k_hw_common(ah);
23 + int bytes = 0;
24 + int pos = *ppos;
25 + int size = 4096;
26 + u16 val;
27 + int i;
28 +
29 + if (AR_SREV_9300_20_OR_LATER(ah))
30 + size = 16384;
31 +
32 + if (*ppos < 0)
33 + return -EINVAL;
34 +
35 + if (count > size - *ppos)
36 + count = size - *ppos;
37 +
38 + for (i = *ppos / 2; count > 0; count -= bytes, *ppos += bytes, i++) {
39 + void *from = &val;
40 +
41 + if (!common->bus_ops->eeprom_read(common, i, &val))
42 + val = 0xffff;
43 +
44 + if (*ppos % 2) {
45 + from++;
46 + bytes = 1;
47 + } else if (count == 1) {
48 + bytes = 1;
49 + } else {
50 + bytes = 2;
51 + }
52 + if (copy_to_user(user_buf, from, bytes))
53 + return -EFAULT;
54 + user_buf += bytes;
55 + }
56 + return *ppos - pos;
57 +}
58 +
59 +static const struct file_operations fops_eeprom = {
60 + .read = read_file_eeprom,
61 + .open = simple_open,
62 + .owner = THIS_MODULE
63 +};
64 +
65 +void ath9k_cmn_debug_eeprom(struct dentry *debugfs_phy,
66 + struct ath_hw *ah)
67 +{
68 + debugfs_create_file("eeprom", S_IRUSR, debugfs_phy, ah,
69 + &fops_eeprom);
70 +}
71 +EXPORT_SYMBOL(ath9k_cmn_debug_eeprom);
72 --- a/drivers/net/wireless/ath/ath9k/common-debug.h
73 +++ b/drivers/net/wireless/ath/ath9k/common-debug.h
74 @@ -69,6 +69,8 @@ void ath9k_cmn_debug_modal_eeprom(struct
75 struct ath_hw *ah);
76 void ath9k_cmn_debug_base_eeprom(struct dentry *debugfs_phy,
77 struct ath_hw *ah);
78 +void ath9k_cmn_debug_eeprom(struct dentry *debugfs_phy,
79 + struct ath_hw *ah);
80 void ath9k_cmn_debug_stat_rx(struct ath_rx_stats *rxstats,
81 struct ath_rx_status *rs);
82 void ath9k_cmn_debug_recv(struct dentry *debugfs_phy,
83 --- a/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
84 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_debug.c
85 @@ -519,6 +519,7 @@ int ath9k_htc_init_debug(struct ath_hw *
86
87 ath9k_cmn_debug_base_eeprom(priv->debug.debugfs_phy, priv->ah);
88 ath9k_cmn_debug_modal_eeprom(priv->debug.debugfs_phy, priv->ah);
89 + ath9k_cmn_debug_eeprom(priv->debug.debugfs_phy, priv->ah);
90
91 return 0;
92 }