Re: [PATCH 2/2] hexdump: add a new dump prefix DUMP_PREFIX_ADDRESS_LOW16

From: Randy Dunlap
Date: Mon Aug 07 2023 - 18:37:32 EST




On 8/5/23 00:21, thunder.leizhen@xxxxxxxxxxxxxxx wrote:
> From: Zhen Lei <thunder.leizhen@xxxxxxxxxx>
>
>
> Signed-off-by: Zhen Lei <thunder.leizhen@xxxxxxxxxx>


Reviewed-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
Thanks.

> ---
> include/linux/printk.h | 1 +
> lib/hexdump.c | 4 ++++
> 2 files changed, 5 insertions(+)
>
> diff --git a/include/linux/printk.h b/include/linux/printk.h
> index 8ef499ab3c1ed2e..ccad9e8eaaf0c31 100644
> --- a/include/linux/printk.h
> +++ b/include/linux/printk.h
> @@ -704,6 +704,7 @@ extern const struct file_operations kmsg_fops;
> enum {
> DUMP_PREFIX_NONE,
> DUMP_PREFIX_ADDRESS,
> + DUMP_PREFIX_ADDRESS_LOW16,
> DUMP_PREFIX_OFFSET
> };
> extern int hex_dump_to_buffer(const void *buf, size_t len, int rowsize,
> diff --git a/lib/hexdump.c b/lib/hexdump.c
> index 86cb4cc3eec485a..eb33e477bc96df1 100644
> --- a/lib/hexdump.c
> +++ b/lib/hexdump.c
> @@ -290,6 +290,10 @@ void print_hex_dump(const char *level, const char *prefix_str, int prefix_type,
> printk("%s%s%p: %s\n",
> level, prefix_str, ptr + i, linebuf);
> break;
> + case DUMP_PREFIX_ADDRESS_LOW16:
> + printk("%s%s%04lx: %s\n", level,
> + prefix_str, 0xffff & (unsigned long)(ptr + i), linebuf);
> + break;
> case DUMP_PREFIX_OFFSET:
> printk("%s%s%0*x: %s\n", level, prefix_str, width, i, linebuf);
> break;

--
~Randy