diff options
author | Bruno Randolf <br1@einfach.org> | 2010-05-18 21:31:32 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-06-02 16:13:26 -0400 |
commit | 40ca22eafeb61ee1419dd7c4c2698459183c582c (patch) | |
tree | 334285722b332023d7216621b022026e59ba8f7d /drivers/net/wireless/ath/ath5k | |
parent | 6673e2e8e040e319e0505f31580b7f1dbb5862e4 (diff) |
ath5k: add sysfs files for ANI parameters
/sys/class/ieee80211/phy0/device/ani/ani_mode
/sys/class/ieee80211/phy0/device/ani/noise_immunity_level
/sys/class/ieee80211/phy0/device/ani/spur_level
/sys/class/ieee80211/phy0/device/ani/firstep_level
/sys/class/ieee80211/phy0/device/ani/ofdm_weak_signal_detection
/sys/class/ieee80211/phy0/device/ani/cck_weak_signal_detection
/sys/class/ieee80211/phy0/device/ani/noise_immunity_level_max
/sys/class/ieee80211/phy0/device/ani/spur_level_max
/sys/class/ieee80211/phy0/device/ani/firstep_level_max
sysfs has a lot of symlinks, so you can find the files also in other locations,
like (by PCI ID) /sys/devices/pci0000:00/0000:00:11.0/ani and others.
Signed-off-by: Bruno Randolf <br1@einfach.org>
Acked-by: Nick Kossifidis <mickflemm@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath5k')
-rw-r--r-- | drivers/net/wireless/ath/ath5k/Makefile | 1 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath5k/ath5k.h | 3 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath5k/base.c | 3 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath5k/reset.c | 1 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath5k/sysfs.c | 116 |
5 files changed, 123 insertions, 1 deletions
diff --git a/drivers/net/wireless/ath/ath5k/Makefile b/drivers/net/wireless/ath/ath5k/Makefile index cc09595b781..2242a140e4f 100644 --- a/drivers/net/wireless/ath/ath5k/Makefile +++ b/drivers/net/wireless/ath/ath5k/Makefile | |||
@@ -13,5 +13,6 @@ ath5k-y += base.o | |||
13 | ath5k-y += led.o | 13 | ath5k-y += led.o |
14 | ath5k-y += rfkill.o | 14 | ath5k-y += rfkill.o |
15 | ath5k-y += ani.o | 15 | ath5k-y += ani.o |
16 | ath5k-y += sysfs.o | ||
16 | ath5k-$(CONFIG_ATH5K_DEBUG) += debug.o | 17 | ath5k-$(CONFIG_ATH5K_DEBUG) += debug.o |
17 | obj-$(CONFIG_ATH5K) += ath5k.o | 18 | obj-$(CONFIG_ATH5K) += ath5k.o |
diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h index d6f9afebf92..eace74dac00 100644 --- a/drivers/net/wireless/ath/ath5k/ath5k.h +++ b/drivers/net/wireless/ath/ath5k/ath5k.h | |||
@@ -1150,6 +1150,9 @@ struct ath5k_hw { | |||
1150 | int ath5k_hw_attach(struct ath5k_softc *sc); | 1150 | int ath5k_hw_attach(struct ath5k_softc *sc); |
1151 | void ath5k_hw_detach(struct ath5k_hw *ah); | 1151 | void ath5k_hw_detach(struct ath5k_hw *ah); |
1152 | 1152 | ||
1153 | int ath5k_sysfs_register(struct ath5k_softc *sc); | ||
1154 | void ath5k_sysfs_unregister(struct ath5k_softc *sc); | ||
1155 | |||
1153 | /* LED functions */ | 1156 | /* LED functions */ |
1154 | int ath5k_init_leds(struct ath5k_softc *sc); | 1157 | int ath5k_init_leds(struct ath5k_softc *sc); |
1155 | void ath5k_led_enable(struct ath5k_softc *sc); | 1158 | void ath5k_led_enable(struct ath5k_softc *sc); |
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c index e63aeaa36c3..0aabfab2770 100644 --- a/drivers/net/wireless/ath/ath5k/base.c +++ b/drivers/net/wireless/ath/ath5k/base.c | |||
@@ -862,6 +862,8 @@ ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw) | |||
862 | 862 | ||
863 | ath5k_init_leds(sc); | 863 | ath5k_init_leds(sc); |
864 | 864 | ||
865 | ath5k_sysfs_register(sc); | ||
866 | |||
865 | return 0; | 867 | return 0; |
866 | err_queues: | 868 | err_queues: |
867 | ath5k_txq_release(sc); | 869 | ath5k_txq_release(sc); |
@@ -897,6 +899,7 @@ ath5k_detach(struct pci_dev *pdev, struct ieee80211_hw *hw) | |||
897 | ath5k_hw_release_tx_queue(sc->ah, sc->bhalq); | 899 | ath5k_hw_release_tx_queue(sc->ah, sc->bhalq); |
898 | ath5k_unregister_leds(sc); | 900 | ath5k_unregister_leds(sc); |
899 | 901 | ||
902 | ath5k_sysfs_unregister(sc); | ||
900 | /* | 903 | /* |
901 | * NB: can't reclaim these until after ieee80211_ifdetach | 904 | * NB: can't reclaim these until after ieee80211_ifdetach |
902 | * returns because we'll get called back to reclaim node | 905 | * returns because we'll get called back to reclaim node |
diff --git a/drivers/net/wireless/ath/ath5k/reset.c b/drivers/net/wireless/ath/ath5k/reset.c index a1bc01528ab..c17c84e9356 100644 --- a/drivers/net/wireless/ath/ath5k/reset.c +++ b/drivers/net/wireless/ath/ath5k/reset.c | |||
@@ -850,7 +850,6 @@ static void ath5k_hw_commit_eeprom_settings(struct ath5k_hw *ah, | |||
850 | AR5K_PHY_NF_THRESH62, | 850 | AR5K_PHY_NF_THRESH62, |
851 | ee->ee_thr_62[ee_mode]); | 851 | ee->ee_thr_62[ee_mode]); |
852 | 852 | ||
853 | |||
854 | /* False detect backoff for channels | 853 | /* False detect backoff for channels |
855 | * that have spur noise. Write the new | 854 | * that have spur noise. Write the new |
856 | * cyclic power RSSI threshold. */ | 855 | * cyclic power RSSI threshold. */ |
diff --git a/drivers/net/wireless/ath/ath5k/sysfs.c b/drivers/net/wireless/ath/ath5k/sysfs.c new file mode 100644 index 00000000000..90757de7bf5 --- /dev/null +++ b/drivers/net/wireless/ath/ath5k/sysfs.c | |||
@@ -0,0 +1,116 @@ | |||
1 | #include <linux/device.h> | ||
2 | #include <linux/pci.h> | ||
3 | |||
4 | #include "base.h" | ||
5 | #include "ath5k.h" | ||
6 | #include "reg.h" | ||
7 | |||
8 | #define SIMPLE_SHOW_STORE(name, get, set) \ | ||
9 | static ssize_t ath5k_attr_show_##name(struct device *dev, \ | ||
10 | struct device_attribute *attr, \ | ||
11 | char *buf) \ | ||
12 | { \ | ||
13 | struct ath5k_softc *sc = dev_get_drvdata(dev); \ | ||
14 | return snprintf(buf, PAGE_SIZE, "%d\n", get); \ | ||
15 | } \ | ||
16 | \ | ||
17 | static ssize_t ath5k_attr_store_##name(struct device *dev, \ | ||
18 | struct device_attribute *attr, \ | ||
19 | const char *buf, size_t count) \ | ||
20 | { \ | ||
21 | struct ath5k_softc *sc = dev_get_drvdata(dev); \ | ||
22 | int val; \ | ||
23 | \ | ||
24 | val = (int)simple_strtoul(buf, NULL, 10); \ | ||
25 | set(sc->ah, val); \ | ||
26 | return count; \ | ||
27 | } \ | ||
28 | static DEVICE_ATTR(name, S_IRUGO | S_IWUSR, \ | ||
29 | ath5k_attr_show_##name, ath5k_attr_store_##name) | ||
30 | |||
31 | #define SIMPLE_SHOW(name, get) \ | ||
32 | static ssize_t ath5k_attr_show_##name(struct device *dev, \ | ||
33 | struct device_attribute *attr, \ | ||
34 | char *buf) \ | ||
35 | { \ | ||
36 | struct ath5k_softc *sc = dev_get_drvdata(dev); \ | ||
37 | return snprintf(buf, PAGE_SIZE, "%d\n", get); \ | ||
38 | } \ | ||
39 | static DEVICE_ATTR(name, S_IRUGO, ath5k_attr_show_##name, NULL) | ||
40 | |||
41 | /*** ANI ***/ | ||
42 | |||
43 | SIMPLE_SHOW_STORE(ani_mode, sc->ani_state.ani_mode, ath5k_ani_init); | ||
44 | SIMPLE_SHOW_STORE(noise_immunity_level, sc->ani_state.noise_imm_level, | ||
45 | ath5k_ani_set_noise_immunity_level); | ||
46 | SIMPLE_SHOW_STORE(spur_level, sc->ani_state.spur_level, | ||
47 | ath5k_ani_set_spur_immunity_level); | ||
48 | SIMPLE_SHOW_STORE(firstep_level, sc->ani_state.firstep_level, | ||
49 | ath5k_ani_set_firstep_level); | ||
50 | SIMPLE_SHOW_STORE(ofdm_weak_signal_detection, sc->ani_state.ofdm_weak_sig, | ||
51 | ath5k_ani_set_ofdm_weak_signal_detection); | ||
52 | SIMPLE_SHOW_STORE(cck_weak_signal_detection, sc->ani_state.cck_weak_sig, | ||
53 | ath5k_ani_set_cck_weak_signal_detection); | ||
54 | SIMPLE_SHOW(spur_level_max, sc->ani_state.max_spur_level); | ||
55 | |||
56 | static ssize_t ath5k_attr_show_noise_immunity_level_max(struct device *dev, | ||
57 | struct device_attribute *attr, | ||
58 | char *buf) | ||
59 | { | ||
60 | return snprintf(buf, PAGE_SIZE, "%d\n", ATH5K_ANI_MAX_NOISE_IMM_LVL); | ||
61 | } | ||
62 | static DEVICE_ATTR(noise_immunity_level_max, S_IRUGO, | ||
63 | ath5k_attr_show_noise_immunity_level_max, NULL); | ||
64 | |||
65 | static ssize_t ath5k_attr_show_firstep_level_max(struct device *dev, | ||
66 | struct device_attribute *attr, | ||
67 | char *buf) | ||
68 | { | ||
69 | return snprintf(buf, PAGE_SIZE, "%d\n", ATH5K_ANI_MAX_FIRSTEP_LVL); | ||
70 | } | ||
71 | static DEVICE_ATTR(firstep_level_max, S_IRUGO, | ||
72 | ath5k_attr_show_firstep_level_max, NULL); | ||
73 | |||
74 | static struct attribute *ath5k_sysfs_entries_ani[] = { | ||
75 | &dev_attr_ani_mode.attr, | ||
76 | &dev_attr_noise_immunity_level.attr, | ||
77 | &dev_attr_spur_level.attr, | ||
78 | &dev_attr_firstep_level.attr, | ||
79 | &dev_attr_ofdm_weak_signal_detection.attr, | ||
80 | &dev_attr_cck_weak_signal_detection.attr, | ||
81 | &dev_attr_noise_immunity_level_max.attr, | ||
82 | &dev_attr_spur_level_max.attr, | ||
83 | &dev_attr_firstep_level_max.attr, | ||
84 | NULL | ||
85 | }; | ||
86 | |||
87 | static struct attribute_group ath5k_attribute_group_ani = { | ||
88 | .name = "ani", | ||
89 | .attrs = ath5k_sysfs_entries_ani, | ||
90 | }; | ||
91 | |||
92 | |||
93 | /*** register / unregister ***/ | ||
94 | |||
95 | int | ||
96 | ath5k_sysfs_register(struct ath5k_softc *sc) | ||
97 | { | ||
98 | struct device *dev = &sc->pdev->dev; | ||
99 | int err; | ||
100 | |||
101 | err = sysfs_create_group(&dev->kobj, &ath5k_attribute_group_ani); | ||
102 | if (err) { | ||
103 | ATH5K_ERR(sc, "failed to create sysfs group\n"); | ||
104 | return err; | ||
105 | } | ||
106 | |||
107 | return 0; | ||
108 | } | ||
109 | |||
110 | void | ||
111 | ath5k_sysfs_unregister(struct ath5k_softc *sc) | ||
112 | { | ||
113 | struct device *dev = &sc->pdev->dev; | ||
114 | |||
115 | sysfs_remove_group(&dev->kobj, &ath5k_attribute_group_ani); | ||
116 | } | ||