mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
seq_file: provide an analogue of print_hex_dump()
This introduces a new helper and switches current users to use it. All patches are compiled tested. kmemleak is tested via its own test suite. This patch (of 6): The new seq_hex_dump() is a complete analogue of print_hex_dump(). We have few users of this functionality already. It allows to reduce their codebase. Signed-off-by: Andy Shevchenko <[email protected]> Cc: Alexander Viro <[email protected]> Cc: Joe Perches <[email protected]> Cc: Tadeusz Struk <[email protected]> Cc: Helge Deller <[email protected]> Cc: Ingo Tuchscherer <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Vladimir Kondratiev <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
40f705a736
commit
37607102c4
2 changed files with 46 additions and 0 deletions
|
|
@ -12,6 +12,7 @@
|
|||
#include <linux/slab.h>
|
||||
#include <linux/cred.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/printk.h>
|
||||
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/page.h>
|
||||
|
|
@ -773,6 +774,47 @@ void seq_pad(struct seq_file *m, char c)
|
|||
}
|
||||
EXPORT_SYMBOL(seq_pad);
|
||||
|
||||
/* A complete analogue of print_hex_dump() */
|
||||
void seq_hex_dump(struct seq_file *m, const char *prefix_str, int prefix_type,
|
||||
int rowsize, int groupsize, const void *buf, size_t len,
|
||||
bool ascii)
|
||||
{
|
||||
const u8 *ptr = buf;
|
||||
int i, linelen, remaining = len;
|
||||
int ret;
|
||||
|
||||
if (rowsize != 16 && rowsize != 32)
|
||||
rowsize = 16;
|
||||
|
||||
for (i = 0; i < len && !seq_has_overflowed(m); i += rowsize) {
|
||||
linelen = min(remaining, rowsize);
|
||||
remaining -= rowsize;
|
||||
|
||||
switch (prefix_type) {
|
||||
case DUMP_PREFIX_ADDRESS:
|
||||
seq_printf(m, "%s%p: ", prefix_str, ptr + i);
|
||||
break;
|
||||
case DUMP_PREFIX_OFFSET:
|
||||
seq_printf(m, "%s%.8x: ", prefix_str, i);
|
||||
break;
|
||||
default:
|
||||
seq_printf(m, "%s", prefix_str);
|
||||
break;
|
||||
}
|
||||
|
||||
ret = hex_dump_to_buffer(ptr + i, linelen, rowsize, groupsize,
|
||||
m->buf + m->count, m->size - m->count,
|
||||
ascii);
|
||||
if (ret >= m->size - m->count) {
|
||||
seq_set_overflow(m);
|
||||
} else {
|
||||
m->count += ret;
|
||||
seq_putc(m, '\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(seq_hex_dump);
|
||||
|
||||
struct list_head *seq_list_start(struct list_head *head, loff_t pos)
|
||||
{
|
||||
struct list_head *lh;
|
||||
|
|
|
|||
Loading…
Reference in a new issue