aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/wil6210/debugfs.c
diff options
context:
space:
mode:
authorBoris Sorochkin <boriss@codeaurora.org>2015-02-15 07:02:35 -0500
committerKalle Valo <kvalo@codeaurora.org>2015-02-27 03:15:20 -0500
commit8f55cbec7f8856438eef80e23f26331bea124128 (patch)
tree9d3bdefd6a77da6ab45c747046ebfabc564cbd4c /drivers/net/wireless/ath/wil6210/debugfs.c
parent0436fd9a2d1e0c87a621841ab48e779cf8f237b4 (diff)
wil6210: Fix division by zero in wil_vring_debugfs_show
On some platforms get_cycles() implemented to allways return 0. On such platforms "Division by zero" bug was triggered. Signed-off-by: Boris Sorochkin <boriss@codeaurora.org> Signed-off-by: Vladimir Kondratiev <qca_vkondrat@qca.qualcomm.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Diffstat (limited to 'drivers/net/wireless/ath/wil6210/debugfs.c')
-rw-r--r--drivers/net/wireless/ath/wil6210/debugfs.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c b/drivers/net/wireless/ath/wil6210/debugfs.c
index eb6de8cbdd7a..fd5975153386 100644
--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -103,23 +103,30 @@ static int wil_vring_debugfs_show(struct seq_file *s, void *data)
103 % vring->size; 103 % vring->size;
104 int avail = vring->size - used - 1; 104 int avail = vring->size - used - 1;
105 char name[10]; 105 char name[10];
106 char sidle[10];
106 /* performance monitoring */ 107 /* performance monitoring */
107 cycles_t now = get_cycles(); 108 cycles_t now = get_cycles();
108 uint64_t idle = txdata->idle * 100; 109 uint64_t idle = txdata->idle * 100;
109 uint64_t total = now - txdata->begin; 110 uint64_t total = now - txdata->begin;
110 111
111 do_div(idle, total); 112 if (total != 0) {
113 do_div(idle, total);
114 snprintf(sidle, sizeof(sidle), "%3d%%",
115 (int)idle);
116 } else {
117 snprintf(sidle, sizeof(sidle), "N/A");
118 }
112 txdata->begin = now; 119 txdata->begin = now;
113 txdata->idle = 0ULL; 120 txdata->idle = 0ULL;
114 121
115 snprintf(name, sizeof(name), "tx_%2d", i); 122 snprintf(name, sizeof(name), "tx_%2d", i);
116 123
117 seq_printf(s, 124 seq_printf(s,
118 "\n%pM CID %d TID %d BACK([%d] %d TU A%s) [%3d|%3d] idle %3d%%\n", 125 "\n%pM CID %d TID %d BACK([%d] %d TU A%s) [%3d|%3d] idle %s\n",
119 wil->sta[cid].addr, cid, tid, 126 wil->sta[cid].addr, cid, tid,
120 txdata->agg_wsize, txdata->agg_timeout, 127 txdata->agg_wsize, txdata->agg_timeout,
121 txdata->agg_amsdu ? "+" : "-", 128 txdata->agg_amsdu ? "+" : "-",
122 used, avail, (int)idle); 129 used, avail, sidle);
123 130
124 wil_print_vring(s, wil, name, vring, '_', 'H'); 131 wil_print_vring(s, wil, name, vring, '_', 'H');
125 } 132 }