diff options
author | Felix Fietkau <nbd@openwrt.org> | 2010-05-11 11:23:02 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-05-12 16:39:07 -0400 |
commit | 9bff0bc4012c7f079b297eb45b47780e3713f367 (patch) | |
tree | 039a4148df1a3cc8c64f81f87f1e4d835a1f8d8b /drivers | |
parent | 1534069491c67619bfaeb25368a1249b669503c3 (diff) |
ath9k: add debugfs files for reading/writing registers
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/debug.c | 89 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath9k/debug.h | 1 |
2 files changed, 90 insertions, 0 deletions
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index 7a2fe09d4a99..2ca9bba8a6af 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c | |||
@@ -794,6 +794,86 @@ static const struct file_operations fops_recv = { | |||
794 | .owner = THIS_MODULE | 794 | .owner = THIS_MODULE |
795 | }; | 795 | }; |
796 | 796 | ||
797 | static ssize_t read_file_regidx(struct file *file, char __user *user_buf, | ||
798 | size_t count, loff_t *ppos) | ||
799 | { | ||
800 | struct ath_softc *sc = file->private_data; | ||
801 | char buf[32]; | ||
802 | unsigned int len; | ||
803 | |||
804 | len = snprintf(buf, sizeof(buf), "0x%08x\n", sc->debug.regidx); | ||
805 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); | ||
806 | } | ||
807 | |||
808 | static ssize_t write_file_regidx(struct file *file, const char __user *user_buf, | ||
809 | size_t count, loff_t *ppos) | ||
810 | { | ||
811 | struct ath_softc *sc = file->private_data; | ||
812 | unsigned long regidx; | ||
813 | char buf[32]; | ||
814 | ssize_t len; | ||
815 | |||
816 | len = min(count, sizeof(buf) - 1); | ||
817 | if (copy_from_user(buf, user_buf, len)) | ||
818 | return -EINVAL; | ||
819 | |||
820 | buf[len] = '\0'; | ||
821 | if (strict_strtoul(buf, 0, ®idx)) | ||
822 | return -EINVAL; | ||
823 | |||
824 | sc->debug.regidx = regidx; | ||
825 | return count; | ||
826 | } | ||
827 | |||
828 | static const struct file_operations fops_regidx = { | ||
829 | .read = read_file_regidx, | ||
830 | .write = write_file_regidx, | ||
831 | .open = ath9k_debugfs_open, | ||
832 | .owner = THIS_MODULE | ||
833 | }; | ||
834 | |||
835 | static ssize_t read_file_regval(struct file *file, char __user *user_buf, | ||
836 | size_t count, loff_t *ppos) | ||
837 | { | ||
838 | struct ath_softc *sc = file->private_data; | ||
839 | struct ath_hw *ah = sc->sc_ah; | ||
840 | char buf[32]; | ||
841 | unsigned int len; | ||
842 | u32 regval; | ||
843 | |||
844 | regval = REG_READ_D(ah, sc->debug.regidx); | ||
845 | len = snprintf(buf, sizeof(buf), "0x%08x\n", regval); | ||
846 | return simple_read_from_buffer(user_buf, count, ppos, buf, len); | ||
847 | } | ||
848 | |||
849 | static ssize_t write_file_regval(struct file *file, const char __user *user_buf, | ||
850 | size_t count, loff_t *ppos) | ||
851 | { | ||
852 | struct ath_softc *sc = file->private_data; | ||
853 | struct ath_hw *ah = sc->sc_ah; | ||
854 | unsigned long regval; | ||
855 | char buf[32]; | ||
856 | ssize_t len; | ||
857 | |||
858 | len = min(count, sizeof(buf) - 1); | ||
859 | if (copy_from_user(buf, user_buf, len)) | ||
860 | return -EINVAL; | ||
861 | |||
862 | buf[len] = '\0'; | ||
863 | if (strict_strtoul(buf, 0, ®val)) | ||
864 | return -EINVAL; | ||
865 | |||
866 | REG_WRITE_D(ah, sc->debug.regidx, regval); | ||
867 | return count; | ||
868 | } | ||
869 | |||
870 | static const struct file_operations fops_regval = { | ||
871 | .read = read_file_regval, | ||
872 | .write = write_file_regval, | ||
873 | .open = ath9k_debugfs_open, | ||
874 | .owner = THIS_MODULE | ||
875 | }; | ||
876 | |||
797 | int ath9k_init_debug(struct ath_hw *ah) | 877 | int ath9k_init_debug(struct ath_hw *ah) |
798 | { | 878 | { |
799 | struct ath_common *common = ath9k_hw_common(ah); | 879 | struct ath_common *common = ath9k_hw_common(ah); |
@@ -845,6 +925,15 @@ int ath9k_init_debug(struct ath_hw *ah) | |||
845 | sc->debug.debugfs_phy, sc, &fops_tx_chainmask)) | 925 | sc->debug.debugfs_phy, sc, &fops_tx_chainmask)) |
846 | goto err; | 926 | goto err; |
847 | 927 | ||
928 | if (!debugfs_create_file("regidx", S_IRUSR | S_IWUSR, | ||
929 | sc->debug.debugfs_phy, sc, &fops_regidx)) | ||
930 | goto err; | ||
931 | |||
932 | if (!debugfs_create_file("regval", S_IRUSR | S_IWUSR, | ||
933 | sc->debug.debugfs_phy, sc, &fops_regval)) | ||
934 | goto err; | ||
935 | |||
936 | sc->debug.regidx = 0; | ||
848 | return 0; | 937 | return 0; |
849 | err: | 938 | err: |
850 | ath9k_exit_debug(ah); | 939 | ath9k_exit_debug(ah); |
diff --git a/drivers/net/wireless/ath/ath9k/debug.h b/drivers/net/wireless/ath/ath9k/debug.h index 731436035bac..5147b8709e10 100644 --- a/drivers/net/wireless/ath/ath9k/debug.h +++ b/drivers/net/wireless/ath/ath9k/debug.h | |||
@@ -153,6 +153,7 @@ struct ath_stats { | |||
153 | 153 | ||
154 | struct ath9k_debug { | 154 | struct ath9k_debug { |
155 | struct dentry *debugfs_phy; | 155 | struct dentry *debugfs_phy; |
156 | u32 regidx; | ||
156 | struct ath_stats stats; | 157 | struct ath_stats stats; |
157 | }; | 158 | }; |
158 | 159 | ||