aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wireless/ath/ath9k/ath9k.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.c186
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c7
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c23
4 files changed, 200 insertions, 17 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index b2d6c18d1678..342edc543665 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -754,6 +754,7 @@ struct ath_softc {
754 /* relay(fs) channel for spectral scan */ 754 /* relay(fs) channel for spectral scan */
755 struct rchan *rfs_chan_spec_scan; 755 struct rchan *rfs_chan_spec_scan;
756 enum spectral_mode spectral_mode; 756 enum spectral_mode spectral_mode;
757 struct ath_spec_scan spec_config;
757 int scanning; 758 int scanning;
758 759
759#ifdef CONFIG_PM_SLEEP 760#ifdef CONFIG_PM_SLEEP
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 6c5d313ebcb7..012446d27bc0 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -1035,6 +1035,182 @@ static const struct file_operations fops_spec_scan_ctl = {
1035 .llseek = default_llseek, 1035 .llseek = default_llseek,
1036}; 1036};
1037 1037
1038static ssize_t read_file_spectral_short_repeat(struct file *file,
1039 char __user *user_buf,
1040 size_t count, loff_t *ppos)
1041{
1042 struct ath_softc *sc = file->private_data;
1043 char buf[32];
1044 unsigned int len;
1045
1046 len = sprintf(buf, "%d\n", sc->spec_config.short_repeat);
1047 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1048}
1049
1050static ssize_t write_file_spectral_short_repeat(struct file *file,
1051 const char __user *user_buf,
1052 size_t count, loff_t *ppos)
1053{
1054 struct ath_softc *sc = file->private_data;
1055 unsigned long val;
1056 char buf[32];
1057 ssize_t len;
1058
1059 len = min(count, sizeof(buf) - 1);
1060 if (copy_from_user(buf, user_buf, len))
1061 return -EFAULT;
1062
1063 buf[len] = '\0';
1064 if (kstrtoul(buf, 0, &val))
1065 return -EINVAL;
1066
1067 if (val < 0 || val > 1)
1068 return -EINVAL;
1069
1070 sc->spec_config.short_repeat = val;
1071 return count;
1072}
1073
1074static const struct file_operations fops_spectral_short_repeat = {
1075 .read = read_file_spectral_short_repeat,
1076 .write = write_file_spectral_short_repeat,
1077 .open = simple_open,
1078 .owner = THIS_MODULE,
1079 .llseek = default_llseek,
1080};
1081
1082static ssize_t read_file_spectral_count(struct file *file,
1083 char __user *user_buf,
1084 size_t count, loff_t *ppos)
1085{
1086 struct ath_softc *sc = file->private_data;
1087 char buf[32];
1088 unsigned int len;
1089
1090 len = sprintf(buf, "%d\n", sc->spec_config.count);
1091 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1092}
1093
1094static ssize_t write_file_spectral_count(struct file *file,
1095 const char __user *user_buf,
1096 size_t count, loff_t *ppos)
1097{
1098 struct ath_softc *sc = file->private_data;
1099 unsigned long val;
1100 char buf[32];
1101 ssize_t len;
1102
1103 len = min(count, sizeof(buf) - 1);
1104 if (copy_from_user(buf, user_buf, len))
1105 return -EFAULT;
1106
1107 buf[len] = '\0';
1108 if (kstrtoul(buf, 0, &val))
1109 return -EINVAL;
1110
1111 if (val < 0 || val > 255)
1112 return -EINVAL;
1113
1114 sc->spec_config.count = val;
1115 return count;
1116}
1117
1118static const struct file_operations fops_spectral_count = {
1119 .read = read_file_spectral_count,
1120 .write = write_file_spectral_count,
1121 .open = simple_open,
1122 .owner = THIS_MODULE,
1123 .llseek = default_llseek,
1124};
1125
1126static ssize_t read_file_spectral_period(struct file *file,
1127 char __user *user_buf,
1128 size_t count, loff_t *ppos)
1129{
1130 struct ath_softc *sc = file->private_data;
1131 char buf[32];
1132 unsigned int len;
1133
1134 len = sprintf(buf, "%d\n", sc->spec_config.period);
1135 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1136}
1137
1138static ssize_t write_file_spectral_period(struct file *file,
1139 const char __user *user_buf,
1140 size_t count, loff_t *ppos)
1141{
1142 struct ath_softc *sc = file->private_data;
1143 unsigned long val;
1144 char buf[32];
1145 ssize_t len;
1146
1147 len = min(count, sizeof(buf) - 1);
1148 if (copy_from_user(buf, user_buf, len))
1149 return -EFAULT;
1150
1151 buf[len] = '\0';
1152 if (kstrtoul(buf, 0, &val))
1153 return -EINVAL;
1154
1155 if (val < 0 || val > 255)
1156 return -EINVAL;
1157
1158 sc->spec_config.period = val;
1159 return count;
1160}
1161
1162static const struct file_operations fops_spectral_period = {
1163 .read = read_file_spectral_period,
1164 .write = write_file_spectral_period,
1165 .open = simple_open,
1166 .owner = THIS_MODULE,
1167 .llseek = default_llseek,
1168};
1169
1170static ssize_t read_file_spectral_fft_period(struct file *file,
1171 char __user *user_buf,
1172 size_t count, loff_t *ppos)
1173{
1174 struct ath_softc *sc = file->private_data;
1175 char buf[32];
1176 unsigned int len;
1177
1178 len = sprintf(buf, "%d\n", sc->spec_config.fft_period);
1179 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1180}
1181
1182static ssize_t write_file_spectral_fft_period(struct file *file,
1183 const char __user *user_buf,
1184 size_t count, loff_t *ppos)
1185{
1186 struct ath_softc *sc = file->private_data;
1187 unsigned long val;
1188 char buf[32];
1189 ssize_t len;
1190
1191 len = min(count, sizeof(buf) - 1);
1192 if (copy_from_user(buf, user_buf, len))
1193 return -EFAULT;
1194
1195 buf[len] = '\0';
1196 if (kstrtoul(buf, 0, &val))
1197 return -EINVAL;
1198
1199 if (val < 0 || val > 15)
1200 return -EINVAL;
1201
1202 sc->spec_config.fft_period = val;
1203 return count;
1204}
1205
1206static const struct file_operations fops_spectral_fft_period = {
1207 .read = read_file_spectral_fft_period,
1208 .write = write_file_spectral_fft_period,
1209 .open = simple_open,
1210 .owner = THIS_MODULE,
1211 .llseek = default_llseek,
1212};
1213
1038static struct dentry *create_buf_file_handler(const char *filename, 1214static struct dentry *create_buf_file_handler(const char *filename,
1039 struct dentry *parent, 1215 struct dentry *parent,
1040 umode_t mode, 1216 umode_t mode,
@@ -1893,6 +2069,16 @@ int ath9k_init_debug(struct ath_hw *ah)
1893 debugfs_create_file("spectral_scan_ctl", S_IRUSR | S_IWUSR, 2069 debugfs_create_file("spectral_scan_ctl", S_IRUSR | S_IWUSR,
1894 sc->debug.debugfs_phy, sc, 2070 sc->debug.debugfs_phy, sc,
1895 &fops_spec_scan_ctl); 2071 &fops_spec_scan_ctl);
2072 debugfs_create_file("spectral_short_repeat", S_IRUSR | S_IWUSR,
2073 sc->debug.debugfs_phy, sc,
2074 &fops_spectral_short_repeat);
2075 debugfs_create_file("spectral_count", S_IRUSR | S_IWUSR,
2076 sc->debug.debugfs_phy, sc, &fops_spectral_count);
2077 debugfs_create_file("spectral_period", S_IRUSR | S_IWUSR,
2078 sc->debug.debugfs_phy, sc, &fops_spectral_period);
2079 debugfs_create_file("spectral_fft_period", S_IRUSR | S_IWUSR,
2080 sc->debug.debugfs_phy, sc,
2081 &fops_spectral_fft_period);
1896 2082
1897#ifdef CONFIG_ATH9K_MAC_DEBUG 2083#ifdef CONFIG_ATH9K_MAC_DEBUG
1898 debugfs_create_file("samples", S_IRUSR, sc->debug.debugfs_phy, sc, 2084 debugfs_create_file("samples", S_IRUSR, sc->debug.debugfs_phy, sc,
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 4b1abc7da98c..c7d116c2c615 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -497,6 +497,13 @@ static void ath9k_init_misc(struct ath_softc *sc)
497 497
498 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) 498 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)
499 sc->ant_comb.count = ATH_ANT_DIV_COMB_INIT_COUNT; 499 sc->ant_comb.count = ATH_ANT_DIV_COMB_INIT_COUNT;
500
501 sc->spec_config.enabled = 0;
502 sc->spec_config.short_repeat = true;
503 sc->spec_config.count = 8;
504 sc->spec_config.endless = false;
505 sc->spec_config.period = 0xFF;
506 sc->spec_config.fft_period = 0xF;
500} 507}
501 508
502static void ath9k_eeprom_request_cb(const struct firmware *eeprom_blob, 509static void ath9k_eeprom_request_cb(const struct firmware *eeprom_blob,
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 4b72b660f180..5432f1247e2e 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1099,45 +1099,34 @@ int ath9k_spectral_scan_config(struct ieee80211_hw *hw,
1099 struct ath_softc *sc = hw->priv; 1099 struct ath_softc *sc = hw->priv;
1100 struct ath_hw *ah = sc->sc_ah; 1100 struct ath_hw *ah = sc->sc_ah;
1101 struct ath_common *common = ath9k_hw_common(ah); 1101 struct ath_common *common = ath9k_hw_common(ah);
1102 struct ath_spec_scan param;
1103 1102
1104 if (!ath9k_hw_ops(ah)->spectral_scan_trigger) { 1103 if (!ath9k_hw_ops(ah)->spectral_scan_trigger) {
1105 ath_err(common, "spectrum analyzer not implemented on this hardware\n"); 1104 ath_err(common, "spectrum analyzer not implemented on this hardware\n");
1106 return -1; 1105 return -1;
1107 } 1106 }
1108 1107
1109 /* NOTE: this will generate a few samples ...
1110 *
1111 * TODO: review default parameters, and/or define an interface to set
1112 * them.
1113 */
1114 param.enabled = 1;
1115 param.short_repeat = true;
1116 param.count = 8;
1117 param.endless = false;
1118 param.period = 0xFF;
1119 param.fft_period = 0xF;
1120
1121 switch (spectral_mode) { 1108 switch (spectral_mode) {
1122 case SPECTRAL_DISABLED: 1109 case SPECTRAL_DISABLED:
1123 param.enabled = 0; 1110 sc->spec_config.enabled = 0;
1124 break; 1111 break;
1125 case SPECTRAL_BACKGROUND: 1112 case SPECTRAL_BACKGROUND:
1126 /* send endless samples. 1113 /* send endless samples.
1127 * TODO: is this really useful for "background"? 1114 * TODO: is this really useful for "background"?
1128 */ 1115 */
1129 param.endless = 1; 1116 sc->spec_config.endless = 1;
1117 sc->spec_config.enabled = 1;
1130 break; 1118 break;
1131 case SPECTRAL_CHANSCAN: 1119 case SPECTRAL_CHANSCAN:
1132 break;
1133 case SPECTRAL_MANUAL: 1120 case SPECTRAL_MANUAL:
1121 sc->spec_config.endless = 0;
1122 sc->spec_config.enabled = 1;
1134 break; 1123 break;
1135 default: 1124 default:
1136 return -1; 1125 return -1;
1137 } 1126 }
1138 1127
1139 ath9k_ps_wakeup(sc); 1128 ath9k_ps_wakeup(sc);
1140 ath9k_hw_ops(ah)->spectral_scan_config(ah, &param); 1129 ath9k_hw_ops(ah)->spectral_scan_config(ah, &sc->spec_config);
1141 ath9k_ps_restore(sc); 1130 ath9k_ps_restore(sc);
1142 1131
1143 sc->spectral_mode = spectral_mode; 1132 sc->spectral_mode = spectral_mode;