aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi
diff options
context:
space:
mode:
authorEyal Shapira <eyal@wizery.com>2014-02-24 03:24:34 -0500
committerEmmanuel Grumbach <emmanuel.grumbach@intel.com>2014-03-09 10:39:07 -0400
commitf754b5ca0ac40dc7f805d6fe7de911ccf1d0f0e2 (patch)
tree57a8068f696d6d1877a7f3becae196ead39e8e40 /drivers/net/wireless/iwlwifi
parentc42e8109103c0773c1e76704d9e4ff57cf1d2a71 (diff)
iwlwifi: mvm: cleanups in iwl_dbgfs_frame_stats_read
Switch pos to char * which makes the code a bit shorter as well as other minor cleanups suggested by Joe Perches. Signed-off-by: Eyal Shapira <eyalx.shapira@intel.com> Reviewed-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi')
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/debugfs.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/net/wireless/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/iwlwifi/mvm/debugfs.c
index 41c637034687..e3b42b4fa438 100644
--- a/drivers/net/wireless/iwlwifi/mvm/debugfs.c
+++ b/drivers/net/wireless/iwlwifi/mvm/debugfs.c
@@ -536,56 +536,60 @@ static ssize_t iwl_dbgfs_frame_stats_read(struct iwl_mvm *mvm,
536 loff_t *ppos, 536 loff_t *ppos,
537 struct iwl_mvm_frame_stats *stats) 537 struct iwl_mvm_frame_stats *stats)
538{ 538{
539 char *buff; 539 char *buff, *pos, *endpos;
540 int pos = 0, idx, i; 540 int idx, i;
541 int ret; 541 int ret;
542 size_t bufsz = 1024; 542 static const size_t bufsz = 1024;
543 543
544 buff = kmalloc(bufsz, GFP_KERNEL); 544 buff = kmalloc(bufsz, GFP_KERNEL);
545 if (!buff) 545 if (!buff)
546 return -ENOMEM; 546 return -ENOMEM;
547 547
548 spin_lock_bh(&mvm->drv_stats_lock); 548 spin_lock_bh(&mvm->drv_stats_lock);
549 pos += scnprintf(buff + pos, bufsz - pos, 549
550 pos = buff;
551 endpos = pos + bufsz;
552
553 pos += scnprintf(pos, endpos - pos,
550 "Legacy/HT/VHT\t:\t%d/%d/%d\n", 554 "Legacy/HT/VHT\t:\t%d/%d/%d\n",
551 stats->legacy_frames, 555 stats->legacy_frames,
552 stats->ht_frames, 556 stats->ht_frames,
553 stats->vht_frames); 557 stats->vht_frames);
554 pos += scnprintf(buff + pos, bufsz - pos, "20/40/80\t:\t%d/%d/%d\n", 558 pos += scnprintf(pos, endpos - pos, "20/40/80\t:\t%d/%d/%d\n",
555 stats->bw_20_frames, 559 stats->bw_20_frames,
556 stats->bw_40_frames, 560 stats->bw_40_frames,
557 stats->bw_80_frames); 561 stats->bw_80_frames);
558 pos += scnprintf(buff + pos, bufsz - pos, "NGI/SGI\t\t:\t%d/%d\n", 562 pos += scnprintf(pos, endpos - pos, "NGI/SGI\t\t:\t%d/%d\n",
559 stats->ngi_frames, 563 stats->ngi_frames,
560 stats->sgi_frames); 564 stats->sgi_frames);
561 pos += scnprintf(buff + pos, bufsz - pos, "SISO/MIMO2\t:\t%d/%d\n", 565 pos += scnprintf(pos, endpos - pos, "SISO/MIMO2\t:\t%d/%d\n",
562 stats->siso_frames, 566 stats->siso_frames,
563 stats->mimo2_frames); 567 stats->mimo2_frames);
564 pos += scnprintf(buff + pos, bufsz - pos, "FAIL/SCSS\t:\t%d/%d\n", 568 pos += scnprintf(pos, endpos - pos, "FAIL/SCSS\t:\t%d/%d\n",
565 stats->fail_frames, 569 stats->fail_frames,
566 stats->success_frames); 570 stats->success_frames);
567 pos += scnprintf(buff + pos, bufsz - pos, "MPDUs agg\t:\t%d\n", 571 pos += scnprintf(pos, endpos - pos, "MPDUs agg\t:\t%d\n",
568 stats->agg_frames); 572 stats->agg_frames);
569 pos += scnprintf(buff + pos, bufsz - pos, "A-MPDUs\t\t:\t%d\n", 573 pos += scnprintf(pos, endpos - pos, "A-MPDUs\t\t:\t%d\n",
570 stats->ampdu_count); 574 stats->ampdu_count);
571 pos += scnprintf(buff + pos, bufsz - pos, "Avg MPDUs/A-MPDU:\t%d\n", 575 pos += scnprintf(pos, endpos - pos, "Avg MPDUs/A-MPDU:\t%d\n",
572 stats->ampdu_count > 0 ? 576 stats->ampdu_count > 0 ?
573 (stats->agg_frames / stats->ampdu_count) : 0); 577 (stats->agg_frames / stats->ampdu_count) : 0);
574 578
575 pos += scnprintf(buff + pos, bufsz - pos, "Last Rates\n"); 579 pos += scnprintf(pos, endpos - pos, "Last Rates\n");
576 580
577 idx = stats->last_frame_idx - 1; 581 idx = stats->last_frame_idx - 1;
578 for (i = 0; i < ARRAY_SIZE(stats->last_rates); i++) { 582 for (i = 0; i < ARRAY_SIZE(stats->last_rates); i++) {
579 idx = (idx + 1) % ARRAY_SIZE(stats->last_rates); 583 idx = (idx + 1) % ARRAY_SIZE(stats->last_rates);
580 if (stats->last_rates[idx] == 0) 584 if (stats->last_rates[idx] == 0)
581 continue; 585 continue;
582 pos += scnprintf(buff + pos, bufsz - pos, "Rate[%d]: ", 586 pos += scnprintf(pos, endpos - pos, "Rate[%d]: ",
583 (int)(ARRAY_SIZE(stats->last_rates) - i)); 587 (int)(ARRAY_SIZE(stats->last_rates) - i));
584 pos += rs_pretty_print_rate(buff + pos, stats->last_rates[idx]); 588 pos += rs_pretty_print_rate(pos, stats->last_rates[idx]);
585 } 589 }
586 spin_unlock_bh(&mvm->drv_stats_lock); 590 spin_unlock_bh(&mvm->drv_stats_lock);
587 591
588 ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos); 592 ret = simple_read_from_buffer(user_buf, count, ppos, buff, pos - buff);
589 kfree(buff); 593 kfree(buff);
590 594
591 return ret; 595 return ret;