aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2013-11-12 10:48:03 -0500
committerEmmanuel Grumbach <emmanuel.grumbach@intel.com>2013-12-09 15:29:03 -0500
commit8a0bd168fa750d7c57d3494b331e9fb2b0bbd928 (patch)
treec9d359948842fb08f4c67898a99245854cc5ded9 /drivers/net
parent8a5e3660c645200ca5d965903c73b97fb86c9518 (diff)
iwlwifi: mvm: small debugfs cleanups
Just clean up the code a bit, in particular * make all the debugfs writes follow the same pattern with respect to buf/buf_size variables * get rid of useless comments * check return values of all file creations * drop unnecessary parentheses * remove an unused struct definition * fix some whitespace Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/debugfs.c77
1 files changed, 27 insertions, 50 deletions
diff --git a/drivers/net/wireless/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/iwlwifi/mvm/debugfs.c
index 342bd1a07ab7..a34fb80422c0 100644
--- a/drivers/net/wireless/iwlwifi/mvm/debugfs.c
+++ b/drivers/net/wireless/iwlwifi/mvm/debugfs.c
@@ -65,26 +65,19 @@
65#include "iwl-io.h" 65#include "iwl-io.h"
66#include "iwl-prph.h" 66#include "iwl-prph.h"
67 67
68struct iwl_dbgfs_mvm_ctx {
69 struct iwl_mvm *mvm;
70 struct ieee80211_vif *vif;
71};
72
73static ssize_t iwl_dbgfs_tx_flush_write(struct file *file, 68static ssize_t iwl_dbgfs_tx_flush_write(struct file *file,
74 const char __user *user_buf, 69 const char __user *user_buf,
75 size_t count, loff_t *ppos) 70 size_t count, loff_t *ppos)
76{ 71{
77 struct iwl_mvm *mvm = file->private_data; 72 struct iwl_mvm *mvm = file->private_data;
78 73 char buf[16] = {};
79 char buf[16]; 74 size_t buf_size = min(count, sizeof(buf) - 1);
80 int buf_size, ret; 75 int ret;
81 u32 scd_q_msk; 76 u32 scd_q_msk;
82 77
83 if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR) 78 if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR)
84 return -EIO; 79 return -EIO;
85 80
86 memset(buf, 0, sizeof(buf));
87 buf_size = min(count, sizeof(buf) - 1);
88 if (copy_from_user(buf, user_buf, buf_size)) 81 if (copy_from_user(buf, user_buf, buf_size))
89 return -EFAULT; 82 return -EFAULT;
90 83
@@ -106,15 +99,13 @@ static ssize_t iwl_dbgfs_sta_drain_write(struct file *file,
106{ 99{
107 struct iwl_mvm *mvm = file->private_data; 100 struct iwl_mvm *mvm = file->private_data;
108 struct ieee80211_sta *sta; 101 struct ieee80211_sta *sta;
109 102 char buf[8] = {};
110 char buf[8]; 103 size_t buf_size = min(count, sizeof(buf) - 1);
111 int buf_size, sta_id, drain, ret; 104 int sta_id, drain, ret;
112 105
113 if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR) 106 if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR)
114 return -EIO; 107 return -EIO;
115 108
116 memset(buf, 0, sizeof(buf));
117 buf_size = min(count, sizeof(buf) - 1);
118 if (copy_from_user(buf, user_buf, buf_size)) 109 if (copy_from_user(buf, user_buf, buf_size))
119 return -EFAULT; 110 return -EFAULT;
120 111
@@ -200,12 +191,10 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
200 loff_t *ppos) 191 loff_t *ppos)
201{ 192{
202 struct iwl_mvm *mvm = file->private_data; 193 struct iwl_mvm *mvm = file->private_data;
203 char buf[64]; 194 char buf[64] = {};
204 int buf_size; 195 size_t buf_size = min(count, sizeof(buf) - 1);
205 u32 offset, len; 196 u32 offset, len;
206 197
207 memset(buf, 0, sizeof(buf));
208 buf_size = min(count, sizeof(buf) - 1);
209 if (copy_from_user(buf, user_buf, buf_size)) 198 if (copy_from_user(buf, user_buf, buf_size))
210 return -EFAULT; 199 return -EFAULT;
211 200
@@ -274,14 +263,14 @@ static ssize_t iwl_dbgfs_disable_power_off_write(struct file *file,
274{ 263{
275 struct iwl_mvm *mvm = file->private_data; 264 struct iwl_mvm *mvm = file->private_data;
276 char buf[64] = {}; 265 char buf[64] = {};
266 size_t buf_size = min(count, sizeof(buf) - 1);
277 int ret; 267 int ret;
278 int val; 268 int val;
279 269
280 if (!mvm->ucode_loaded) 270 if (!mvm->ucode_loaded)
281 return -EIO; 271 return -EIO;
282 272
283 count = min_t(size_t, count, sizeof(buf) - 1); 273 if (copy_from_user(buf, user_buf, buf_size))
284 if (copy_from_user(buf, user_buf, count))
285 return -EFAULT; 274 return -EFAULT;
286 275
287 if (!strncmp("disable_power_off_d0=", buf, 21)) { 276 if (!strncmp("disable_power_off_d0=", buf, 21)) {
@@ -319,11 +308,10 @@ static void iwl_dbgfs_update_pm(struct iwl_mvm *mvm,
319 int dtimper_msec = dtimper * vif->bss_conf.beacon_int; 308 int dtimper_msec = dtimper * vif->bss_conf.beacon_int;
320 309
321 IWL_DEBUG_POWER(mvm, "debugfs: set keep_alive= %d sec\n", val); 310 IWL_DEBUG_POWER(mvm, "debugfs: set keep_alive= %d sec\n", val);
322 if (val * MSEC_PER_SEC < 3 * dtimper_msec) { 311 if (val * MSEC_PER_SEC < 3 * dtimper_msec)
323 IWL_WARN(mvm, 312 IWL_WARN(mvm,
324 "debugfs: keep alive period (%ld msec) is less than minimum required (%d msec)\n", 313 "debugfs: keep alive period (%ld msec) is less than minimum required (%d msec)\n",
325 val * MSEC_PER_SEC, 3 * dtimper_msec); 314 val * MSEC_PER_SEC, 3 * dtimper_msec);
326 }
327 dbgfs_pm->keep_alive_seconds = val; 315 dbgfs_pm->keep_alive_seconds = val;
328 break; 316 break;
329 } 317 }
@@ -372,11 +360,11 @@ static ssize_t iwl_dbgfs_pm_params_write(struct file *file,
372 struct iwl_mvm *mvm = mvmvif->dbgfs_data; 360 struct iwl_mvm *mvm = mvmvif->dbgfs_data;
373 enum iwl_dbgfs_pm_mask param; 361 enum iwl_dbgfs_pm_mask param;
374 char buf[32] = {}; 362 char buf[32] = {};
363 size_t buf_size = min(count, sizeof(buf) - 1);
375 int val; 364 int val;
376 int ret; 365 int ret;
377 366
378 count = min_t(size_t, count, sizeof(buf) - 1); 367 if (copy_from_user(buf, user_buf, buf_size))
379 if (copy_from_user(buf, user_buf, count))
380 return -EFAULT; 368 return -EFAULT;
381 369
382 if (!strncmp("keep_alive=", buf, 11)) { 370 if (!strncmp("keep_alive=", buf, 11)) {
@@ -471,7 +459,7 @@ static ssize_t iwl_dbgfs_mac_params_read(struct file *file,
471 pos += scnprintf(buf+pos, bufsz-pos, "bssid: %pM\n", 459 pos += scnprintf(buf+pos, bufsz-pos, "bssid: %pM\n",
472 vif->bss_conf.bssid); 460 vif->bss_conf.bssid);
473 pos += scnprintf(buf+pos, bufsz-pos, "QoS:\n"); 461 pos += scnprintf(buf+pos, bufsz-pos, "QoS:\n");
474 for (i = 0; i < ARRAY_SIZE(mvmvif->queue_params); i++) { 462 for (i = 0; i < ARRAY_SIZE(mvmvif->queue_params); i++)
475 pos += scnprintf(buf+pos, bufsz-pos, 463 pos += scnprintf(buf+pos, bufsz-pos,
476 "\t%d: txop:%d - cw_min:%d - cw_max = %d - aifs = %d upasd = %d\n", 464 "\t%d: txop:%d - cw_min:%d - cw_max = %d - aifs = %d upasd = %d\n",
477 i, mvmvif->queue_params[i].txop, 465 i, mvmvif->queue_params[i].txop,
@@ -479,7 +467,6 @@ static ssize_t iwl_dbgfs_mac_params_read(struct file *file,
479 mvmvif->queue_params[i].cw_max, 467 mvmvif->queue_params[i].cw_max,
480 mvmvif->queue_params[i].aifs, 468 mvmvif->queue_params[i].aifs,
481 mvmvif->queue_params[i].uapsd); 469 mvmvif->queue_params[i].uapsd);
482 }
483 470
484 if (vif->type == NL80211_IFTYPE_STATION && 471 if (vif->type == NL80211_IFTYPE_STATION &&
485 ap_sta_id != IWL_MVM_STATION_COUNT) { 472 ap_sta_id != IWL_MVM_STATION_COUNT) {
@@ -496,12 +483,11 @@ static ssize_t iwl_dbgfs_mac_params_read(struct file *file,
496 483
497 rcu_read_lock(); 484 rcu_read_lock();
498 chanctx_conf = rcu_dereference(vif->chanctx_conf); 485 chanctx_conf = rcu_dereference(vif->chanctx_conf);
499 if (chanctx_conf) { 486 if (chanctx_conf)
500 pos += scnprintf(buf+pos, bufsz-pos, 487 pos += scnprintf(buf+pos, bufsz-pos,
501 "idle rx chains %d, active rx chains: %d\n", 488 "idle rx chains %d, active rx chains: %d\n",
502 chanctx_conf->rx_chains_static, 489 chanctx_conf->rx_chains_static,
503 chanctx_conf->rx_chains_dynamic); 490 chanctx_conf->rx_chains_dynamic);
504 }
505 rcu_read_unlock(); 491 rcu_read_unlock();
506 492
507 mutex_unlock(&mvm->mutex); 493 mutex_unlock(&mvm->mutex);
@@ -845,14 +831,10 @@ iwl_dbgfs_scan_ant_rxchain_write(struct file *file,
845 size_t count, loff_t *ppos) 831 size_t count, loff_t *ppos)
846{ 832{
847 struct iwl_mvm *mvm = file->private_data; 833 struct iwl_mvm *mvm = file->private_data;
848 char buf[8]; 834 char buf[8] = {};
849 int buf_size; 835 size_t buf_size = min(count, sizeof(buf) - 1);
850 u8 scan_rx_ant; 836 u8 scan_rx_ant;
851 837
852 memset(buf, 0, sizeof(buf));
853 buf_size = min(count, sizeof(buf) - 1);
854
855 /* get the argument from the user and check if it is valid */
856 if (copy_from_user(buf, user_buf, buf_size)) 838 if (copy_from_user(buf, user_buf, buf_size))
857 return -EFAULT; 839 return -EFAULT;
858 if (sscanf(buf, "%hhx", &scan_rx_ant) != 1) 840 if (sscanf(buf, "%hhx", &scan_rx_ant) != 1)
@@ -862,7 +844,6 @@ iwl_dbgfs_scan_ant_rxchain_write(struct file *file,
862 if (scan_rx_ant & ~iwl_fw_valid_rx_ant(mvm->fw)) 844 if (scan_rx_ant & ~iwl_fw_valid_rx_ant(mvm->fw))
863 return -EINVAL; 845 return -EINVAL;
864 846
865 /* change the rx antennas for scan command */
866 mvm->scan_rx_ant = scan_rx_ant; 847 mvm->scan_rx_ant = scan_rx_ant;
867 848
868 return count; 849 return count;
@@ -922,13 +903,10 @@ static ssize_t iwl_dbgfs_bf_params_write(struct file *file,
922 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 903 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
923 struct iwl_mvm *mvm = mvmvif->dbgfs_data; 904 struct iwl_mvm *mvm = mvmvif->dbgfs_data;
924 enum iwl_dbgfs_bf_mask param; 905 enum iwl_dbgfs_bf_mask param;
925 char buf[256]; 906 char buf[256] = {};
926 int buf_size; 907 size_t buf_size = min(count, sizeof(buf) - 1);
927 int value; 908 int value, ret = 0;
928 int ret = 0;
929 909
930 memset(buf, 0, sizeof(buf));
931 buf_size = min(count, sizeof(buf) - 1);
932 if (copy_from_user(buf, user_buf, buf_size)) 910 if (copy_from_user(buf, user_buf, buf_size))
933 return -EFAULT; 911 return -EFAULT;
934 912
@@ -1012,11 +990,10 @@ static ssize_t iwl_dbgfs_bf_params_write(struct file *file,
1012 990
1013 mutex_lock(&mvm->mutex); 991 mutex_lock(&mvm->mutex);
1014 iwl_dbgfs_update_bf(vif, param, value); 992 iwl_dbgfs_update_bf(vif, param, value);
1015 if (param == MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER && !value) { 993 if (param == MVM_DEBUGFS_BF_ENABLE_BEACON_FILTER && !value)
1016 ret = iwl_mvm_disable_beacon_filter(mvm, vif); 994 ret = iwl_mvm_disable_beacon_filter(mvm, vif);
1017 } else { 995 else
1018 ret = iwl_mvm_enable_beacon_filter(mvm, vif); 996 ret = iwl_mvm_enable_beacon_filter(mvm, vif);
1019 }
1020 mutex_unlock(&mvm->mutex); 997 mutex_unlock(&mvm->mutex);
1021 998
1022 return ret ?: count; 999 return ret ?: count;
@@ -1078,10 +1055,10 @@ static ssize_t iwl_dbgfs_d3_sram_write(struct file *file,
1078{ 1055{
1079 struct iwl_mvm *mvm = file->private_data; 1056 struct iwl_mvm *mvm = file->private_data;
1080 char buf[8] = {}; 1057 char buf[8] = {};
1058 size_t buf_size = min(count, sizeof(buf) - 1);
1081 int store; 1059 int store;
1082 1060
1083 count = min_t(size_t, count, sizeof(buf) - 1); 1061 if (copy_from_user(buf, user_buf, buf_size))
1084 if (copy_from_user(buf, user_buf, count))
1085 return -EFAULT; 1062 return -EFAULT;
1086 1063
1087 if (sscanf(buf, "%d", &store) != 1) 1064 if (sscanf(buf, "%d", &store) != 1)
@@ -1137,14 +1114,14 @@ static ssize_t iwl_dbgfs_d3_sram_read(struct file *file, char __user *user_buf,
1137#endif 1114#endif
1138 1115
1139#define MVM_DEBUGFS_READ_FILE_OPS(name) \ 1116#define MVM_DEBUGFS_READ_FILE_OPS(name) \
1140static const struct file_operations iwl_dbgfs_##name##_ops = { \ 1117static const struct file_operations iwl_dbgfs_##name##_ops = { \
1141 .read = iwl_dbgfs_##name##_read, \ 1118 .read = iwl_dbgfs_##name##_read, \
1142 .open = simple_open, \ 1119 .open = simple_open, \
1143 .llseek = generic_file_llseek, \ 1120 .llseek = generic_file_llseek, \
1144} 1121}
1145 1122
1146#define MVM_DEBUGFS_READ_WRITE_FILE_OPS(name) \ 1123#define MVM_DEBUGFS_READ_WRITE_FILE_OPS(name) \
1147static const struct file_operations iwl_dbgfs_##name##_ops = { \ 1124static const struct file_operations iwl_dbgfs_##name##_ops = { \
1148 .write = iwl_dbgfs_##name##_write, \ 1125 .write = iwl_dbgfs_##name##_write, \
1149 .read = iwl_dbgfs_##name##_read, \ 1126 .read = iwl_dbgfs_##name##_read, \
1150 .open = simple_open, \ 1127 .open = simple_open, \
@@ -1152,7 +1129,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \
1152}; 1129};
1153 1130
1154#define MVM_DEBUGFS_WRITE_FILE_OPS(name) \ 1131#define MVM_DEBUGFS_WRITE_FILE_OPS(name) \
1155static const struct file_operations iwl_dbgfs_##name##_ops = { \ 1132static const struct file_operations iwl_dbgfs_##name##_ops = { \
1156 .write = iwl_dbgfs_##name##_write, \ 1133 .write = iwl_dbgfs_##name##_write, \
1157 .open = simple_open, \ 1134 .open = simple_open, \
1158 .llseek = generic_file_llseek, \ 1135 .llseek = generic_file_llseek, \