Skip to content

Commit 08cc96c

Browse files
abattersbyakpm00
authored andcommitted
dmapool: use sysfs_emit() instead of scnprintf()
Use sysfs_emit instead of scnprintf, snprintf or sprintf. Link: https://lkml.kernel.org/r/20230126215125.4069751-4-kbusch@meta.com Fixes: 2d55c16 ("dmapool: create/destroy cleanup") Signed-off-by: Tony Battersby <tonyb@cybernetics.com> Signed-off-by: Keith Busch <kbusch@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Matthew Wilcox <willy@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 67a540c commit 08cc96c

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

mm/dmapool.c

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,11 @@ static DEFINE_MUTEX(pools_reg_lock);
6464

6565
static ssize_t pools_show(struct device *dev, struct device_attribute *attr, char *buf)
6666
{
67-
unsigned temp;
68-
unsigned size;
69-
char *next;
67+
int size;
7068
struct dma_page *page;
7169
struct dma_pool *pool;
7270

73-
next = buf;
74-
size = PAGE_SIZE;
75-
76-
temp = scnprintf(next, size, "poolinfo - 0.1\n");
77-
size -= temp;
78-
next += temp;
71+
size = sysfs_emit(buf, "poolinfo - 0.1\n");
7972

8073
mutex_lock(&pools_lock);
8174
list_for_each_entry(pool, &dev->dma_pools, pools) {
@@ -90,16 +83,14 @@ static ssize_t pools_show(struct device *dev, struct device_attribute *attr, cha
9083
spin_unlock_irq(&pool->lock);
9184

9285
/* per-pool info, no real statistics yet */
93-
temp = scnprintf(next, size, "%-16s %4u %4zu %4zu %2u\n",
94-
pool->name, blocks,
95-
pages * (pool->allocation / pool->size),
96-
pool->size, pages);
97-
size -= temp;
98-
next += temp;
86+
size += sysfs_emit_at(buf, size, "%-16s %4u %4zu %4zu %2u\n",
87+
pool->name, blocks,
88+
pages * (pool->allocation / pool->size),
89+
pool->size, pages);
9990
}
10091
mutex_unlock(&pools_lock);
10192

102-
return PAGE_SIZE - size;
93+
return size;
10394
}
10495

10596
static DEVICE_ATTR_RO(pools);

0 commit comments

Comments
 (0)