OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2008-2009 Atheros Communications Inc. | 2 * Copyright (c) 2008-2009 Atheros Communications Inc. |
3 * | 3 * |
4 * Permission to use, copy, modify, and/or distribute this software for any | 4 * Permission to use, copy, modify, and/or distribute this software for any |
5 * purpose with or without fee is hereby granted, provided that the above | 5 * purpose with or without fee is hereby granted, provided that the above |
6 * copyright notice and this permission notice appear in all copies. | 6 * copyright notice and this permission notice appear in all copies. |
7 * | 7 * |
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
15 */ | 15 */ |
16 | 16 |
17 #include <linux/slab.h> | 17 #include <linux/slab.h> |
| 18 #include <linux/vmalloc.h> |
18 #include <asm/unaligned.h> | 19 #include <asm/unaligned.h> |
19 | 20 |
20 #include "ath9k.h" | 21 #include "ath9k.h" |
21 | 22 |
22 #define REG_WRITE_D(_ah, _reg, _val) \ | 23 #define REG_WRITE_D(_ah, _reg, _val) \ |
23 ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg)) | 24 ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg)) |
24 #define REG_READ_D(_ah, _reg) \ | 25 #define REG_READ_D(_ah, _reg) \ |
25 ath9k_hw_common(_ah)->ops->read((_ah), (_reg)) | 26 ath9k_hw_common(_ah)->ops->read((_ah), (_reg)) |
26 | 27 |
27 static struct dentry *ath9k_debugfs_root; | 28 static struct dentry *ath9k_debugfs_root; |
28 | 29 |
29 static int ath9k_debugfs_open(struct inode *inode, struct file *file) | 30 static int ath9k_debugfs_open(struct inode *inode, struct file *file) |
30 { | 31 { |
31 file->private_data = inode->i_private; | 32 file->private_data = inode->i_private; |
32 return 0; | 33 return 0; |
33 } | 34 } |
34 | 35 |
| 36 static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf, |
| 37 size_t count, loff_t *ppos) |
| 38 { |
| 39 u8 *buf = file->private_data; |
| 40 return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf)); |
| 41 } |
| 42 |
| 43 static int ath9k_debugfs_release_buf (struct inode *inode, struct file *file) |
| 44 { |
| 45 vfree(file->private_data); |
| 46 return 0; |
| 47 } |
| 48 |
35 #ifdef CONFIG_ATH_DEBUG | 49 #ifdef CONFIG_ATH_DEBUG |
36 | 50 |
37 static ssize_t read_file_debug(struct file *file, char __user *user_buf, | 51 static ssize_t read_file_debug(struct file *file, char __user *user_buf, |
38 size_t count, loff_t *ppos) | 52 size_t count, loff_t *ppos) |
39 { | 53 { |
40 struct ath_softc *sc = file->private_data; | 54 struct ath_softc *sc = file->private_data; |
41 struct ath_common *common = ath9k_hw_common(sc->sc_ah); | 55 struct ath_common *common = ath9k_hw_common(sc->sc_ah); |
42 char buf[32]; | 56 char buf[32]; |
43 unsigned int len; | 57 unsigned int len; |
44 | 58 |
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 if (strict_strtoul(buf, 0, ®val)) | 902 if (strict_strtoul(buf, 0, ®val)) |
889 return -EINVAL; | 903 return -EINVAL; |
890 | 904 |
891 REG_WRITE_D(ah, sc->debug.regidx, regval); | 905 REG_WRITE_D(ah, sc->debug.regidx, regval); |
892 return count; | 906 return count; |
893 } | 907 } |
894 | 908 |
895 static const struct file_operations fops_regval = { | 909 static const struct file_operations fops_regval = { |
896 .read = read_file_regval, | 910 .read = read_file_regval, |
897 .write = write_file_regval, | 911 .write = write_file_regval, |
898 » .open = ath9k_debugfs_open, | 912 }; |
| 913 |
| 914 #define REGDUMP_LINE_SIZE» 20 |
| 915 #define REGDUMP_NUM_REGS» (0x16bd4 / 4 + 1) |
| 916 #define REGDUMP_DATA_LEN» (REGDUMP_NUM_REGS * REGDUMP_LINE_SIZE + 1) |
| 917 |
| 918 static int open_file_regdump(struct inode *inode, struct file *file) |
| 919 { |
| 920 » struct ath_softc *sc = inode->i_private; |
| 921 » unsigned int len = 0; |
| 922 » u8 *buf; |
| 923 » int i; |
| 924 |
| 925 » buf = vmalloc(REGDUMP_DATA_LEN); |
| 926 » if (!buf) |
| 927 » » return -ENOMEM; |
| 928 |
| 929 » ath9k_ps_wakeup(sc); |
| 930 » for (i = 0; i < REGDUMP_NUM_REGS; i++) |
| 931 » » len += scnprintf(buf + len, REGDUMP_DATA_LEN - len, |
| 932 » » » "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2)); |
| 933 » ath9k_ps_restore(sc); |
| 934 |
| 935 » file->private_data = buf; |
| 936 |
| 937 » return 0; |
| 938 } |
| 939 |
| 940 static const struct file_operations fops_regdump = { |
| 941 » .open = open_file_regdump, |
| 942 » .read = ath9k_debugfs_read_buf, |
| 943 » .release = ath9k_debugfs_release_buf, |
899 .owner = THIS_MODULE | 944 .owner = THIS_MODULE |
900 }; | 945 }; |
901 | 946 |
902 int ath9k_init_debug(struct ath_hw *ah) | 947 int ath9k_init_debug(struct ath_hw *ah) |
903 { | 948 { |
904 struct ath_common *common = ath9k_hw_common(ah); | 949 struct ath_common *common = ath9k_hw_common(ah); |
905 struct ath_softc *sc = (struct ath_softc *) common->priv; | 950 struct ath_softc *sc = (struct ath_softc *) common->priv; |
906 | 951 |
907 if (!ath9k_debugfs_root) | 952 if (!ath9k_debugfs_root) |
908 return -ENOENT; | 953 return -ENOENT; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 | 1001 |
957 if (!debugfs_create_file("regval", S_IRUSR | S_IWUSR, | 1002 if (!debugfs_create_file("regval", S_IRUSR | S_IWUSR, |
958 sc->debug.debugfs_phy, sc, &fops_regval)) | 1003 sc->debug.debugfs_phy, sc, &fops_regval)) |
959 goto err; | 1004 goto err; |
960 | 1005 |
961 if (!debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR, | 1006 if (!debugfs_create_bool("ignore_extcca", S_IRUSR | S_IWUSR, |
962 sc->debug.debugfs_phy, &ah->config.cwm_ignore_extcca)) | 1007 sc->debug.debugfs_phy, &ah->config.cwm_ignore_extcca)) |
963 goto err; | 1008 goto err; |
964 | 1009 |
965 sc->debug.regidx = 0; | 1010 sc->debug.regidx = 0; |
| 1011 |
| 1012 if (!debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, |
| 1013 sc, &fops_regdump)) |
| 1014 goto err; |
| 1015 |
| 1016 if (ath9k_init_pktlog(sc) != 0) |
| 1017 goto err; |
| 1018 |
966 return 0; | 1019 return 0; |
967 err: | 1020 err: |
968 ath9k_exit_debug(ah); | 1021 ath9k_exit_debug(ah); |
969 return -ENOMEM; | 1022 return -ENOMEM; |
970 } | 1023 } |
971 | 1024 |
972 void ath9k_exit_debug(struct ath_hw *ah) | 1025 void ath9k_exit_debug(struct ath_hw *ah) |
973 { | 1026 { |
974 struct ath_common *common = ath9k_hw_common(ah); | 1027 struct ath_common *common = ath9k_hw_common(ah); |
975 struct ath_softc *sc = (struct ath_softc *) common->priv; | 1028 struct ath_softc *sc = (struct ath_softc *) common->priv; |
976 | 1029 |
| 1030 ath9k_deinit_pktlog(sc); |
| 1031 debugfs_remove(sc->debug.debugfs_regdump); |
977 debugfs_remove_recursive(sc->debug.debugfs_phy); | 1032 debugfs_remove_recursive(sc->debug.debugfs_phy); |
978 } | 1033 } |
979 | 1034 |
980 int ath9k_debug_create_root(void) | 1035 int ath9k_debug_create_root(void) |
981 { | 1036 { |
982 ath9k_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL); | 1037 ath9k_debugfs_root = debugfs_create_dir(KBUILD_MODNAME, NULL); |
983 if (!ath9k_debugfs_root) | 1038 if (!ath9k_debugfs_root) |
984 return -ENOENT; | 1039 return -ENOENT; |
985 | 1040 |
986 return 0; | 1041 return 0; |
987 } | 1042 } |
988 | 1043 |
989 void ath9k_debug_remove_root(void) | 1044 void ath9k_debug_remove_root(void) |
990 { | 1045 { |
991 debugfs_remove(ath9k_debugfs_root); | 1046 debugfs_remove(ath9k_debugfs_root); |
992 ath9k_debugfs_root = NULL; | 1047 ath9k_debugfs_root = NULL; |
993 } | 1048 } |
OLD | NEW |