diff options
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-debugfs.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-debugfs.c | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index ad25806dfaf1..29e16ba69cdb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c | |||
@@ -55,6 +55,13 @@ | |||
55 | goto err; \ | 55 | goto err; \ |
56 | } while (0) | 56 | } while (0) |
57 | 57 | ||
58 | #define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \ | ||
59 | dbgfs->dbgfs_##parent##_files.file_##name = \ | ||
60 | debugfs_create_bool(#name, 0644, dbgfs->dir_##parent, ptr); \ | ||
61 | if (IS_ERR(dbgfs->dbgfs_##parent##_files.file_##name)) \ | ||
62 | goto err; \ | ||
63 | } while (0) | ||
64 | |||
58 | #define DEBUGFS_REMOVE(name) do { \ | 65 | #define DEBUGFS_REMOVE(name) do { \ |
59 | debugfs_remove(name); \ | 66 | debugfs_remove(name); \ |
60 | name = NULL; \ | 67 | name = NULL; \ |
@@ -85,6 +92,14 @@ static const struct file_operations iwl_dbgfs_##name##_ops = { \ | |||
85 | .open = iwl_dbgfs_open_file_generic, \ | 92 | .open = iwl_dbgfs_open_file_generic, \ |
86 | }; | 93 | }; |
87 | 94 | ||
95 | #define DEBUGFS_WRITE_FILE_OPS(name) \ | ||
96 | DEBUGFS_WRITE_FUNC(name); \ | ||
97 | static const struct file_operations iwl_dbgfs_##name##_ops = { \ | ||
98 | .write = iwl_dbgfs_##name##_write, \ | ||
99 | .open = iwl_dbgfs_open_file_generic, \ | ||
100 | }; | ||
101 | |||
102 | |||
88 | #define DEBUGFS_READ_WRITE_FILE_OPS(name) \ | 103 | #define DEBUGFS_READ_WRITE_FILE_OPS(name) \ |
89 | DEBUGFS_READ_FUNC(name); \ | 104 | DEBUGFS_READ_FUNC(name); \ |
90 | DEBUGFS_WRITE_FUNC(name); \ | 105 | DEBUGFS_WRITE_FUNC(name); \ |
@@ -317,7 +332,29 @@ static ssize_t iwl_dbgfs_eeprom_read(struct file *file, | |||
317 | return ret; | 332 | return ret; |
318 | } | 333 | } |
319 | 334 | ||
335 | static ssize_t iwl_dbgfs_log_event_write(struct file *file, | ||
336 | const char __user *user_buf, | ||
337 | size_t count, loff_t *ppos) | ||
338 | { | ||
339 | struct iwl_priv *priv = file->private_data; | ||
340 | u32 event_log_flag; | ||
341 | char buf[8]; | ||
342 | int buf_size; | ||
343 | |||
344 | memset(buf, 0, sizeof(buf)); | ||
345 | buf_size = min(count, sizeof(buf) - 1); | ||
346 | if (copy_from_user(buf, user_buf, buf_size)) | ||
347 | return -EFAULT; | ||
348 | if (sscanf(buf, "%d", &event_log_flag) != 1) | ||
349 | return -EFAULT; | ||
350 | if (event_log_flag == 1) | ||
351 | iwl_dump_nic_event_log(priv); | ||
352 | |||
353 | return count; | ||
354 | } | ||
355 | |||
320 | DEBUGFS_READ_WRITE_FILE_OPS(sram); | 356 | DEBUGFS_READ_WRITE_FILE_OPS(sram); |
357 | DEBUGFS_WRITE_FILE_OPS(log_event); | ||
321 | DEBUGFS_READ_FILE_OPS(eeprom); | 358 | DEBUGFS_READ_FILE_OPS(eeprom); |
322 | DEBUGFS_READ_FILE_OPS(stations); | 359 | DEBUGFS_READ_FILE_OPS(stations); |
323 | DEBUGFS_READ_FILE_OPS(rx_statistics); | 360 | DEBUGFS_READ_FILE_OPS(rx_statistics); |
@@ -330,6 +367,7 @@ DEBUGFS_READ_FILE_OPS(tx_statistics); | |||
330 | int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) | 367 | int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) |
331 | { | 368 | { |
332 | struct iwl_debugfs *dbgfs; | 369 | struct iwl_debugfs *dbgfs; |
370 | struct dentry *phyd = priv->hw->wiphy->debugfsdir; | ||
333 | 371 | ||
334 | dbgfs = kzalloc(sizeof(struct iwl_debugfs), GFP_KERNEL); | 372 | dbgfs = kzalloc(sizeof(struct iwl_debugfs), GFP_KERNEL); |
335 | if (!dbgfs) { | 373 | if (!dbgfs) { |
@@ -338,18 +376,24 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) | |||
338 | 376 | ||
339 | priv->dbgfs = dbgfs; | 377 | priv->dbgfs = dbgfs; |
340 | dbgfs->name = name; | 378 | dbgfs->name = name; |
341 | dbgfs->dir_drv = debugfs_create_dir(name, NULL); | 379 | dbgfs->dir_drv = debugfs_create_dir(name, phyd); |
342 | if (!dbgfs->dir_drv || IS_ERR(dbgfs->dir_drv)){ | 380 | if (!dbgfs->dir_drv || IS_ERR(dbgfs->dir_drv)){ |
343 | goto err; | 381 | goto err; |
344 | } | 382 | } |
345 | 383 | ||
346 | DEBUGFS_ADD_DIR(data, dbgfs->dir_drv); | 384 | DEBUGFS_ADD_DIR(data, dbgfs->dir_drv); |
385 | DEBUGFS_ADD_DIR(rf, dbgfs->dir_drv); | ||
347 | DEBUGFS_ADD_FILE(eeprom, data); | 386 | DEBUGFS_ADD_FILE(eeprom, data); |
348 | DEBUGFS_ADD_FILE(sram, data); | 387 | DEBUGFS_ADD_FILE(sram, data); |
388 | DEBUGFS_ADD_FILE(log_event, data); | ||
349 | DEBUGFS_ADD_FILE(stations, data); | 389 | DEBUGFS_ADD_FILE(stations, data); |
350 | DEBUGFS_ADD_FILE(rx_statistics, data); | 390 | DEBUGFS_ADD_FILE(rx_statistics, data); |
351 | DEBUGFS_ADD_FILE(tx_statistics, data); | 391 | DEBUGFS_ADD_FILE(tx_statistics, data); |
352 | 392 | #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB | |
393 | DEBUGFS_ADD_BOOL(disable_sensitivity, rf, &priv->disable_sens_cal); | ||
394 | DEBUGFS_ADD_BOOL(disable_chain_noise, rf, | ||
395 | &priv->disable_chain_noise_cal); | ||
396 | #endif /* CONFIG_IWLWIFI_RUN_TIME_CALIB */ | ||
353 | return 0; | 397 | return 0; |
354 | 398 | ||
355 | err: | 399 | err: |
@@ -372,8 +416,14 @@ void iwl_dbgfs_unregister(struct iwl_priv *priv) | |||
372 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_rx_statistics); | 416 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_rx_statistics); |
373 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_tx_statistics); | 417 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_tx_statistics); |
374 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sram); | 418 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_sram); |
419 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_log_event); | ||
375 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_stations); | 420 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_data_files.file_stations); |
376 | DEBUGFS_REMOVE(priv->dbgfs->dir_data); | 421 | DEBUGFS_REMOVE(priv->dbgfs->dir_data); |
422 | #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB | ||
423 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_sensitivity); | ||
424 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_chain_noise); | ||
425 | #endif /* CONFIG_IWLWIFI_RUN_TIME_CALIB */ | ||
426 | DEBUGFS_REMOVE(priv->dbgfs->dir_rf); | ||
377 | DEBUGFS_REMOVE(priv->dbgfs->dir_drv); | 427 | DEBUGFS_REMOVE(priv->dbgfs->dir_drv); |
378 | kfree(priv->dbgfs); | 428 | kfree(priv->dbgfs); |
379 | priv->dbgfs = NULL; | 429 | priv->dbgfs = NULL; |
@@ -381,3 +431,4 @@ void iwl_dbgfs_unregister(struct iwl_priv *priv) | |||
381 | EXPORT_SYMBOL(iwl_dbgfs_unregister); | 431 | EXPORT_SYMBOL(iwl_dbgfs_unregister); |
382 | 432 | ||
383 | 433 | ||
434 | |||