Skip to content

Commit 8986003

Browse files
htejuntorvalds
authored andcommitted
wireless: use %*pb[l] to print bitmaps including cpumasks and nodemasks
printk and friends can now format bitmaps using '%*pb[l]'. cpumask and nodemask also provide cpumask_pr_args() and nodemask_pr_args() respectively which can be used to generate the two printf arguments necessary to format the specified cpu/nodemask. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: "John W. Linville" <linville@tuxdriver.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent f090682 commit 8986003

File tree

2 files changed

+12
-35
lines changed

2 files changed

+12
-35
lines changed

drivers/net/wireless/ath/ath9k/htc_drv_debug.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -291,26 +291,15 @@ static ssize_t read_file_slot(struct file *file, char __user *user_buf,
291291
{
292292
struct ath9k_htc_priv *priv = file->private_data;
293293
char buf[512];
294-
unsigned int len = 0;
294+
unsigned int len;
295295

296296
spin_lock_bh(&priv->tx.tx_lock);
297-
298-
len += scnprintf(buf + len, sizeof(buf) - len, "TX slot bitmap : ");
299-
300-
len += bitmap_scnprintf(buf + len, sizeof(buf) - len,
301-
priv->tx.tx_slot, MAX_TX_BUF_NUM);
302-
303-
len += scnprintf(buf + len, sizeof(buf) - len, "\n");
304-
305-
len += scnprintf(buf + len, sizeof(buf) - len,
306-
"Used slots : %d\n",
307-
bitmap_weight(priv->tx.tx_slot, MAX_TX_BUF_NUM));
308-
297+
len = scnprintf(buf, sizeof(buf),
298+
"TX slot bitmap : %*pb\n"
299+
"Used slots : %d\n",
300+
MAX_TX_BUF_NUM, priv->tx.tx_slot,
301+
bitmap_weight(priv->tx.tx_slot, MAX_TX_BUF_NUM));
309302
spin_unlock_bh(&priv->tx.tx_lock);
310-
311-
if (len > sizeof(buf))
312-
len = sizeof(buf);
313-
314303
return simple_read_from_buffer(user_buf, count, ppos, buf, len);
315304
}
316305

drivers/net/wireless/ath/carl9170/debug.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,10 @@ DEBUGFS_DECLARE_RO_FILE(name, _read_bufsize)
214214
static char *carl9170_debugfs_mem_usage_read(struct ar9170 *ar, char *buf,
215215
size_t bufsize, ssize_t *len)
216216
{
217-
ADD(buf, *len, bufsize, "jar: [");
218-
219217
spin_lock_bh(&ar->mem_lock);
220218

221-
*len += bitmap_scnprintf(&buf[*len], bufsize - *len,
222-
ar->mem_bitmap, ar->fw.mem_blocks);
223-
224-
ADD(buf, *len, bufsize, "]\n");
219+
ADD(buf, *len, bufsize, "jar: [%*pb]\n",
220+
ar->fw.mem_blocks, ar->mem_bitmap);
225221

226222
ADD(buf, *len, bufsize, "cookies: used:%3d / total:%3d, allocs:%d\n",
227223
bitmap_weight(ar->mem_bitmap, ar->fw.mem_blocks),
@@ -316,17 +312,13 @@ static char *carl9170_debugfs_ampdu_state_read(struct ar9170 *ar, char *buf,
316312
cnt, iter->tid, iter->bsn, iter->snx, iter->hsn,
317313
iter->max, iter->state, iter->counter);
318314

319-
ADD(buf, *len, bufsize, "\tWindow: [");
320-
321-
*len += bitmap_scnprintf(&buf[*len], bufsize - *len,
322-
iter->bitmap, CARL9170_BAW_BITS);
315+
ADD(buf, *len, bufsize, "\tWindow: [%*pb,W]\n",
316+
CARL9170_BAW_BITS, iter->bitmap);
323317

324318
#define BM_STR_OFF(offset) \
325319
((CARL9170_BAW_BITS - (offset) - 1) / 4 + \
326320
(CARL9170_BAW_BITS - (offset) - 1) / 32 + 1)
327321

328-
ADD(buf, *len, bufsize, ",W]\n");
329-
330322
offset = BM_STR_OFF(0);
331323
ADD(buf, *len, bufsize, "\tBase Seq: %*s\n", offset, "T");
332324

@@ -448,12 +440,8 @@ static char *carl9170_debugfs_vif_dump_read(struct ar9170 *ar, char *buf,
448440
ADD(buf, *len, bufsize, "registered VIFs:%d \\ %d\n",
449441
ar->vifs, ar->fw.vif_num);
450442

451-
ADD(buf, *len, bufsize, "VIF bitmap: [");
452-
453-
*len += bitmap_scnprintf(&buf[*len], bufsize - *len,
454-
&ar->vif_bitmap, ar->fw.vif_num);
455-
456-
ADD(buf, *len, bufsize, "]\n");
443+
ADD(buf, *len, bufsize, "VIF bitmap: [%*pb]\n",
444+
ar->fw.vif_num, &ar->vif_bitmap);
457445

458446
rcu_read_lock();
459447
list_for_each_entry_rcu(iter, &ar->vif_list, list) {

0 commit comments

Comments
 (0)