common-spectral.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. /*
  2. * Copyright (c) 2013 Qualcomm Atheros, Inc.
  3. *
  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
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  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
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include <linux/relay.h>
  17. #include "ath9k.h"
  18. static s8 fix_rssi_inv_only(u8 rssi_val)
  19. {
  20. if (rssi_val == 128)
  21. rssi_val = 0;
  22. return (s8) rssi_val;
  23. }
  24. static void ath_debug_send_fft_sample(struct ath_spec_scan_priv *spec_priv,
  25. struct fft_sample_tlv *fft_sample_tlv)
  26. {
  27. int length;
  28. if (!spec_priv->rfs_chan_spec_scan)
  29. return;
  30. length = __be16_to_cpu(fft_sample_tlv->length) +
  31. sizeof(*fft_sample_tlv);
  32. relay_write(spec_priv->rfs_chan_spec_scan, fft_sample_tlv, length);
  33. }
  34. /* returns 1 if this was a spectral frame, even if not handled. */
  35. int ath_cmn_process_fft(struct ath_spec_scan_priv *spec_priv, struct ieee80211_hdr *hdr,
  36. struct ath_rx_status *rs, u64 tsf)
  37. {
  38. struct ath_hw *ah = spec_priv->ah;
  39. struct ath_common *common = ath9k_hw_common(spec_priv->ah);
  40. u8 num_bins, *bins, *vdata = (u8 *)hdr;
  41. struct fft_sample_ht20 fft_sample_20;
  42. struct fft_sample_ht20_40 fft_sample_40;
  43. struct fft_sample_tlv *tlv;
  44. struct ath_radar_info *radar_info;
  45. int len = rs->rs_datalen;
  46. int dc_pos;
  47. u16 fft_len, length, freq = ah->curchan->chan->center_freq;
  48. enum nl80211_channel_type chan_type;
  49. /* AR9280 and before report via ATH9K_PHYERR_RADAR, AR93xx and newer
  50. * via ATH9K_PHYERR_SPECTRAL. Haven't seen ATH9K_PHYERR_FALSE_RADAR_EXT
  51. * yet, but this is supposed to be possible as well.
  52. */
  53. if (rs->rs_phyerr != ATH9K_PHYERR_RADAR &&
  54. rs->rs_phyerr != ATH9K_PHYERR_FALSE_RADAR_EXT &&
  55. rs->rs_phyerr != ATH9K_PHYERR_SPECTRAL)
  56. return 0;
  57. /* check if spectral scan bit is set. This does not have to be checked
  58. * if received through a SPECTRAL phy error, but shouldn't hurt.
  59. */
  60. radar_info = ((struct ath_radar_info *)&vdata[len]) - 1;
  61. if (!(radar_info->pulse_bw_info & SPECTRAL_SCAN_BITMASK))
  62. return 0;
  63. chan_type = cfg80211_get_chandef_type(&common->hw->conf.chandef);
  64. if ((chan_type == NL80211_CHAN_HT40MINUS) ||
  65. (chan_type == NL80211_CHAN_HT40PLUS)) {
  66. fft_len = SPECTRAL_HT20_40_TOTAL_DATA_LEN;
  67. num_bins = SPECTRAL_HT20_40_NUM_BINS;
  68. bins = (u8 *)fft_sample_40.data;
  69. } else {
  70. fft_len = SPECTRAL_HT20_TOTAL_DATA_LEN;
  71. num_bins = SPECTRAL_HT20_NUM_BINS;
  72. bins = (u8 *)fft_sample_20.data;
  73. }
  74. /* Variation in the data length is possible and will be fixed later */
  75. if ((len > fft_len + 2) || (len < fft_len - 1))
  76. return 1;
  77. switch (len - fft_len) {
  78. case 0:
  79. /* length correct, nothing to do. */
  80. memcpy(bins, vdata, num_bins);
  81. break;
  82. case -1:
  83. /* first byte missing, duplicate it. */
  84. memcpy(&bins[1], vdata, num_bins - 1);
  85. bins[0] = vdata[0];
  86. break;
  87. case 2:
  88. /* MAC added 2 extra bytes at bin 30 and 32, remove them. */
  89. memcpy(bins, vdata, 30);
  90. bins[30] = vdata[31];
  91. memcpy(&bins[31], &vdata[33], num_bins - 31);
  92. break;
  93. case 1:
  94. /* MAC added 2 extra bytes AND first byte is missing. */
  95. bins[0] = vdata[0];
  96. memcpy(&bins[1], vdata, 30);
  97. bins[31] = vdata[31];
  98. memcpy(&bins[32], &vdata[33], num_bins - 32);
  99. break;
  100. default:
  101. return 1;
  102. }
  103. /* DC value (value in the middle) is the blind spot of the spectral
  104. * sample and invalid, interpolate it.
  105. */
  106. dc_pos = num_bins / 2;
  107. bins[dc_pos] = (bins[dc_pos + 1] + bins[dc_pos - 1]) / 2;
  108. if ((chan_type == NL80211_CHAN_HT40MINUS) ||
  109. (chan_type == NL80211_CHAN_HT40PLUS)) {
  110. s8 lower_rssi, upper_rssi;
  111. s16 ext_nf;
  112. u8 lower_max_index, upper_max_index;
  113. u8 lower_bitmap_w, upper_bitmap_w;
  114. u16 lower_mag, upper_mag;
  115. struct ath9k_hw_cal_data *caldata = ah->caldata;
  116. struct ath_ht20_40_mag_info *mag_info;
  117. if (caldata)
  118. ext_nf = ath9k_hw_getchan_noise(ah, ah->curchan,
  119. caldata->nfCalHist[3].privNF);
  120. else
  121. ext_nf = ATH_DEFAULT_NOISE_FLOOR;
  122. length = sizeof(fft_sample_40) - sizeof(struct fft_sample_tlv);
  123. fft_sample_40.tlv.type = ATH_FFT_SAMPLE_HT20_40;
  124. fft_sample_40.tlv.length = __cpu_to_be16(length);
  125. fft_sample_40.freq = __cpu_to_be16(freq);
  126. fft_sample_40.channel_type = chan_type;
  127. if (chan_type == NL80211_CHAN_HT40PLUS) {
  128. lower_rssi = fix_rssi_inv_only(rs->rs_rssi_ctl[0]);
  129. upper_rssi = fix_rssi_inv_only(rs->rs_rssi_ext[0]);
  130. fft_sample_40.lower_noise = ah->noise;
  131. fft_sample_40.upper_noise = ext_nf;
  132. } else {
  133. lower_rssi = fix_rssi_inv_only(rs->rs_rssi_ext[0]);
  134. upper_rssi = fix_rssi_inv_only(rs->rs_rssi_ctl[0]);
  135. fft_sample_40.lower_noise = ext_nf;
  136. fft_sample_40.upper_noise = ah->noise;
  137. }
  138. fft_sample_40.lower_rssi = lower_rssi;
  139. fft_sample_40.upper_rssi = upper_rssi;
  140. mag_info = ((struct ath_ht20_40_mag_info *)radar_info) - 1;
  141. lower_mag = spectral_max_magnitude(mag_info->lower_bins);
  142. upper_mag = spectral_max_magnitude(mag_info->upper_bins);
  143. fft_sample_40.lower_max_magnitude = __cpu_to_be16(lower_mag);
  144. fft_sample_40.upper_max_magnitude = __cpu_to_be16(upper_mag);
  145. lower_max_index = spectral_max_index(mag_info->lower_bins);
  146. upper_max_index = spectral_max_index(mag_info->upper_bins);
  147. fft_sample_40.lower_max_index = lower_max_index;
  148. fft_sample_40.upper_max_index = upper_max_index;
  149. lower_bitmap_w = spectral_bitmap_weight(mag_info->lower_bins);
  150. upper_bitmap_w = spectral_bitmap_weight(mag_info->upper_bins);
  151. fft_sample_40.lower_bitmap_weight = lower_bitmap_w;
  152. fft_sample_40.upper_bitmap_weight = upper_bitmap_w;
  153. fft_sample_40.max_exp = mag_info->max_exp & 0xf;
  154. fft_sample_40.tsf = __cpu_to_be64(tsf);
  155. tlv = (struct fft_sample_tlv *)&fft_sample_40;
  156. } else {
  157. u8 max_index, bitmap_w;
  158. u16 magnitude;
  159. struct ath_ht20_mag_info *mag_info;
  160. length = sizeof(fft_sample_20) - sizeof(struct fft_sample_tlv);
  161. fft_sample_20.tlv.type = ATH_FFT_SAMPLE_HT20;
  162. fft_sample_20.tlv.length = __cpu_to_be16(length);
  163. fft_sample_20.freq = __cpu_to_be16(freq);
  164. fft_sample_20.rssi = fix_rssi_inv_only(rs->rs_rssi_ctl[0]);
  165. fft_sample_20.noise = ah->noise;
  166. mag_info = ((struct ath_ht20_mag_info *)radar_info) - 1;
  167. magnitude = spectral_max_magnitude(mag_info->all_bins);
  168. fft_sample_20.max_magnitude = __cpu_to_be16(magnitude);
  169. max_index = spectral_max_index(mag_info->all_bins);
  170. fft_sample_20.max_index = max_index;
  171. bitmap_w = spectral_bitmap_weight(mag_info->all_bins);
  172. fft_sample_20.bitmap_weight = bitmap_w;
  173. fft_sample_20.max_exp = mag_info->max_exp & 0xf;
  174. fft_sample_20.tsf = __cpu_to_be64(tsf);
  175. tlv = (struct fft_sample_tlv *)&fft_sample_20;
  176. }
  177. ath_debug_send_fft_sample(spec_priv, tlv);
  178. return 1;
  179. }
  180. EXPORT_SYMBOL(ath_cmn_process_fft);
  181. /*********************/
  182. /* spectral_scan_ctl */
  183. /*********************/
  184. static ssize_t read_file_spec_scan_ctl(struct file *file, char __user *user_buf,
  185. size_t count, loff_t *ppos)
  186. {
  187. struct ath_spec_scan_priv *spec_priv = file->private_data;
  188. char *mode = "";
  189. unsigned int len;
  190. switch (spec_priv->spectral_mode) {
  191. case SPECTRAL_DISABLED:
  192. mode = "disable";
  193. break;
  194. case SPECTRAL_BACKGROUND:
  195. mode = "background";
  196. break;
  197. case SPECTRAL_CHANSCAN:
  198. mode = "chanscan";
  199. break;
  200. case SPECTRAL_MANUAL:
  201. mode = "manual";
  202. break;
  203. }
  204. len = strlen(mode);
  205. return simple_read_from_buffer(user_buf, count, ppos, mode, len);
  206. }
  207. void ath9k_cmn_spectral_scan_trigger(struct ath_common *common,
  208. struct ath_spec_scan_priv *spec_priv)
  209. {
  210. struct ath_hw *ah = spec_priv->ah;
  211. u32 rxfilter;
  212. if (config_enabled(CONFIG_ATH9K_TX99))
  213. return;
  214. if (!ath9k_hw_ops(ah)->spectral_scan_trigger) {
  215. ath_err(common, "spectrum analyzer not implemented on this hardware\n");
  216. return;
  217. }
  218. ath_ps_ops(common)->wakeup(common);
  219. rxfilter = ath9k_hw_getrxfilter(ah);
  220. ath9k_hw_setrxfilter(ah, rxfilter |
  221. ATH9K_RX_FILTER_PHYRADAR |
  222. ATH9K_RX_FILTER_PHYERR);
  223. /* TODO: usually this should not be neccesary, but for some reason
  224. * (or in some mode?) the trigger must be called after the
  225. * configuration, otherwise the register will have its values reset
  226. * (on my ar9220 to value 0x01002310)
  227. */
  228. ath9k_cmn_spectral_scan_config(common, spec_priv, spec_priv->spectral_mode);
  229. ath9k_hw_ops(ah)->spectral_scan_trigger(ah);
  230. ath_ps_ops(common)->restore(common);
  231. }
  232. EXPORT_SYMBOL(ath9k_cmn_spectral_scan_trigger);
  233. int ath9k_cmn_spectral_scan_config(struct ath_common *common,
  234. struct ath_spec_scan_priv *spec_priv,
  235. enum spectral_mode spectral_mode)
  236. {
  237. struct ath_hw *ah = spec_priv->ah;
  238. if (!ath9k_hw_ops(ah)->spectral_scan_trigger) {
  239. ath_err(common, "spectrum analyzer not implemented on this hardware\n");
  240. return -1;
  241. }
  242. switch (spectral_mode) {
  243. case SPECTRAL_DISABLED:
  244. spec_priv->spec_config.enabled = 0;
  245. break;
  246. case SPECTRAL_BACKGROUND:
  247. /* send endless samples.
  248. * TODO: is this really useful for "background"?
  249. */
  250. spec_priv->spec_config.endless = 1;
  251. spec_priv->spec_config.enabled = 1;
  252. break;
  253. case SPECTRAL_CHANSCAN:
  254. case SPECTRAL_MANUAL:
  255. spec_priv->spec_config.endless = 0;
  256. spec_priv->spec_config.enabled = 1;
  257. break;
  258. default:
  259. return -1;
  260. }
  261. ath_ps_ops(common)->wakeup(common);
  262. ath9k_hw_ops(ah)->spectral_scan_config(ah, &spec_priv->spec_config);
  263. ath_ps_ops(common)->restore(common);
  264. spec_priv->spectral_mode = spectral_mode;
  265. return 0;
  266. }
  267. EXPORT_SYMBOL(ath9k_cmn_spectral_scan_config);
  268. static ssize_t write_file_spec_scan_ctl(struct file *file,
  269. const char __user *user_buf,
  270. size_t count, loff_t *ppos)
  271. {
  272. struct ath_spec_scan_priv *spec_priv = file->private_data;
  273. struct ath_common *common = ath9k_hw_common(spec_priv->ah);
  274. char buf[32];
  275. ssize_t len;
  276. if (config_enabled(CONFIG_ATH9K_TX99))
  277. return -EOPNOTSUPP;
  278. len = min(count, sizeof(buf) - 1);
  279. if (copy_from_user(buf, user_buf, len))
  280. return -EFAULT;
  281. buf[len] = '\0';
  282. if (strncmp("trigger", buf, 7) == 0) {
  283. ath9k_cmn_spectral_scan_trigger(common, spec_priv);
  284. } else if (strncmp("background", buf, 10) == 0) {
  285. ath9k_cmn_spectral_scan_config(common, spec_priv, SPECTRAL_BACKGROUND);
  286. ath_dbg(common, CONFIG, "spectral scan: background mode enabled\n");
  287. } else if (strncmp("chanscan", buf, 8) == 0) {
  288. ath9k_cmn_spectral_scan_config(common, spec_priv, SPECTRAL_CHANSCAN);
  289. ath_dbg(common, CONFIG, "spectral scan: channel scan mode enabled\n");
  290. } else if (strncmp("manual", buf, 6) == 0) {
  291. ath9k_cmn_spectral_scan_config(common, spec_priv, SPECTRAL_MANUAL);
  292. ath_dbg(common, CONFIG, "spectral scan: manual mode enabled\n");
  293. } else if (strncmp("disable", buf, 7) == 0) {
  294. ath9k_cmn_spectral_scan_config(common, spec_priv, SPECTRAL_DISABLED);
  295. ath_dbg(common, CONFIG, "spectral scan: disabled\n");
  296. } else {
  297. return -EINVAL;
  298. }
  299. return count;
  300. }
  301. static const struct file_operations fops_spec_scan_ctl = {
  302. .read = read_file_spec_scan_ctl,
  303. .write = write_file_spec_scan_ctl,
  304. .open = simple_open,
  305. .owner = THIS_MODULE,
  306. .llseek = default_llseek,
  307. };
  308. /*************************/
  309. /* spectral_short_repeat */
  310. /*************************/
  311. static ssize_t read_file_spectral_short_repeat(struct file *file,
  312. char __user *user_buf,
  313. size_t count, loff_t *ppos)
  314. {
  315. struct ath_spec_scan_priv *spec_priv = file->private_data;
  316. char buf[32];
  317. unsigned int len;
  318. len = sprintf(buf, "%d\n", spec_priv->spec_config.short_repeat);
  319. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  320. }
  321. static ssize_t write_file_spectral_short_repeat(struct file *file,
  322. const char __user *user_buf,
  323. size_t count, loff_t *ppos)
  324. {
  325. struct ath_spec_scan_priv *spec_priv = file->private_data;
  326. unsigned long val;
  327. char buf[32];
  328. ssize_t len;
  329. len = min(count, sizeof(buf) - 1);
  330. if (copy_from_user(buf, user_buf, len))
  331. return -EFAULT;
  332. buf[len] = '\0';
  333. if (kstrtoul(buf, 0, &val))
  334. return -EINVAL;
  335. if (val > 1)
  336. return -EINVAL;
  337. spec_priv->spec_config.short_repeat = val;
  338. return count;
  339. }
  340. static const struct file_operations fops_spectral_short_repeat = {
  341. .read = read_file_spectral_short_repeat,
  342. .write = write_file_spectral_short_repeat,
  343. .open = simple_open,
  344. .owner = THIS_MODULE,
  345. .llseek = default_llseek,
  346. };
  347. /******************/
  348. /* spectral_count */
  349. /******************/
  350. static ssize_t read_file_spectral_count(struct file *file,
  351. char __user *user_buf,
  352. size_t count, loff_t *ppos)
  353. {
  354. struct ath_spec_scan_priv *spec_priv = file->private_data;
  355. char buf[32];
  356. unsigned int len;
  357. len = sprintf(buf, "%d\n", spec_priv->spec_config.count);
  358. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  359. }
  360. static ssize_t write_file_spectral_count(struct file *file,
  361. const char __user *user_buf,
  362. size_t count, loff_t *ppos)
  363. {
  364. struct ath_spec_scan_priv *spec_priv = file->private_data;
  365. unsigned long val;
  366. char buf[32];
  367. ssize_t len;
  368. len = min(count, sizeof(buf) - 1);
  369. if (copy_from_user(buf, user_buf, len))
  370. return -EFAULT;
  371. buf[len] = '\0';
  372. if (kstrtoul(buf, 0, &val))
  373. return -EINVAL;
  374. if (val > 255)
  375. return -EINVAL;
  376. spec_priv->spec_config.count = val;
  377. return count;
  378. }
  379. static const struct file_operations fops_spectral_count = {
  380. .read = read_file_spectral_count,
  381. .write = write_file_spectral_count,
  382. .open = simple_open,
  383. .owner = THIS_MODULE,
  384. .llseek = default_llseek,
  385. };
  386. /*******************/
  387. /* spectral_period */
  388. /*******************/
  389. static ssize_t read_file_spectral_period(struct file *file,
  390. char __user *user_buf,
  391. size_t count, loff_t *ppos)
  392. {
  393. struct ath_spec_scan_priv *spec_priv = file->private_data;
  394. char buf[32];
  395. unsigned int len;
  396. len = sprintf(buf, "%d\n", spec_priv->spec_config.period);
  397. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  398. }
  399. static ssize_t write_file_spectral_period(struct file *file,
  400. const char __user *user_buf,
  401. size_t count, loff_t *ppos)
  402. {
  403. struct ath_spec_scan_priv *spec_priv = file->private_data;
  404. unsigned long val;
  405. char buf[32];
  406. ssize_t len;
  407. len = min(count, sizeof(buf) - 1);
  408. if (copy_from_user(buf, user_buf, len))
  409. return -EFAULT;
  410. buf[len] = '\0';
  411. if (kstrtoul(buf, 0, &val))
  412. return -EINVAL;
  413. if (val > 255)
  414. return -EINVAL;
  415. spec_priv->spec_config.period = val;
  416. return count;
  417. }
  418. static const struct file_operations fops_spectral_period = {
  419. .read = read_file_spectral_period,
  420. .write = write_file_spectral_period,
  421. .open = simple_open,
  422. .owner = THIS_MODULE,
  423. .llseek = default_llseek,
  424. };
  425. /***********************/
  426. /* spectral_fft_period */
  427. /***********************/
  428. static ssize_t read_file_spectral_fft_period(struct file *file,
  429. char __user *user_buf,
  430. size_t count, loff_t *ppos)
  431. {
  432. struct ath_spec_scan_priv *spec_priv = file->private_data;
  433. char buf[32];
  434. unsigned int len;
  435. len = sprintf(buf, "%d\n", spec_priv->spec_config.fft_period);
  436. return simple_read_from_buffer(user_buf, count, ppos, buf, len);
  437. }
  438. static ssize_t write_file_spectral_fft_period(struct file *file,
  439. const char __user *user_buf,
  440. size_t count, loff_t *ppos)
  441. {
  442. struct ath_spec_scan_priv *spec_priv = file->private_data;
  443. unsigned long val;
  444. char buf[32];
  445. ssize_t len;
  446. len = min(count, sizeof(buf) - 1);
  447. if (copy_from_user(buf, user_buf, len))
  448. return -EFAULT;
  449. buf[len] = '\0';
  450. if (kstrtoul(buf, 0, &val))
  451. return -EINVAL;
  452. if (val > 15)
  453. return -EINVAL;
  454. spec_priv->spec_config.fft_period = val;
  455. return count;
  456. }
  457. static const struct file_operations fops_spectral_fft_period = {
  458. .read = read_file_spectral_fft_period,
  459. .write = write_file_spectral_fft_period,
  460. .open = simple_open,
  461. .owner = THIS_MODULE,
  462. .llseek = default_llseek,
  463. };
  464. /*******************/
  465. /* Relay interface */
  466. /*******************/
  467. static struct dentry *create_buf_file_handler(const char *filename,
  468. struct dentry *parent,
  469. umode_t mode,
  470. struct rchan_buf *buf,
  471. int *is_global)
  472. {
  473. struct dentry *buf_file;
  474. buf_file = debugfs_create_file(filename, mode, parent, buf,
  475. &relay_file_operations);
  476. *is_global = 1;
  477. return buf_file;
  478. }
  479. static int remove_buf_file_handler(struct dentry *dentry)
  480. {
  481. debugfs_remove(dentry);
  482. return 0;
  483. }
  484. static struct rchan_callbacks rfs_spec_scan_cb = {
  485. .create_buf_file = create_buf_file_handler,
  486. .remove_buf_file = remove_buf_file_handler,
  487. };
  488. /*********************/
  489. /* Debug Init/Deinit */
  490. /*********************/
  491. void ath9k_cmn_spectral_deinit_debug(struct ath_spec_scan_priv *spec_priv)
  492. {
  493. if (config_enabled(CONFIG_ATH9K_DEBUGFS)) {
  494. relay_close(spec_priv->rfs_chan_spec_scan);
  495. spec_priv->rfs_chan_spec_scan = NULL;
  496. }
  497. }
  498. EXPORT_SYMBOL(ath9k_cmn_spectral_deinit_debug);
  499. void ath9k_cmn_spectral_init_debug(struct ath_spec_scan_priv *spec_priv,
  500. struct dentry *debugfs_phy)
  501. {
  502. spec_priv->rfs_chan_spec_scan = relay_open("spectral_scan",
  503. debugfs_phy,
  504. 1024, 256, &rfs_spec_scan_cb,
  505. NULL);
  506. debugfs_create_file("spectral_scan_ctl",
  507. S_IRUSR | S_IWUSR,
  508. debugfs_phy, spec_priv,
  509. &fops_spec_scan_ctl);
  510. debugfs_create_file("spectral_short_repeat",
  511. S_IRUSR | S_IWUSR,
  512. debugfs_phy, spec_priv,
  513. &fops_spectral_short_repeat);
  514. debugfs_create_file("spectral_count",
  515. S_IRUSR | S_IWUSR,
  516. debugfs_phy, spec_priv,
  517. &fops_spectral_count);
  518. debugfs_create_file("spectral_period",
  519. S_IRUSR | S_IWUSR,
  520. debugfs_phy, spec_priv,
  521. &fops_spectral_period);
  522. debugfs_create_file("spectral_fft_period",
  523. S_IRUSR | S_IWUSR,
  524. debugfs_phy, spec_priv,
  525. &fops_spectral_fft_period);
  526. }
  527. EXPORT_SYMBOL(ath9k_cmn_spectral_init_debug);