mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Marco Felsch <m.felsch@pengutronix.de>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	BAREBOX <barebox@lists.infradead.org>
Subject: Re: [PATCH 2/5] lib: hexdump: make use of pr_print
Date: Fri, 6 Feb 2026 14:05:15 +0100	[thread overview]
Message-ID: <4aa3046c-1220-48e2-8a6a-dfef3137778b@pengutronix.de> (raw)
In-Reply-To: <20260205-vmaster-customers-leicageo-system1600-v1-2-a80b234ce1a1@pengutronix.de>



On 2/5/26 4:45 PM, Marco Felsch wrote:
> The hexdump library was ported from Linux which supports different
> printk() level. Because the barebox print* facility is different
> compared to the one from Linux the barebox printk() doesn't support
> levels. Therefore the level is always set to an empty string.
> 
> Furthermore all barebox printk() calls aren't recorded by the internal
> barebox_logbuf because they are mostly used for command prints. Linux on
> the other hand record each printk() print.
> 
> Not recording the output can be an issue on systems which don't have a
> hw-console but a USB-ACM console, because the hexdump call may already
> occurred before the console was ready.
> 
> Make use of pr_print() instead to record the output within the
> barebox_logbuf to be available later on via dmesg. With that the hexdump
> API changes from a string based loglevel to a integer based loglevel
> parameter.
> 
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

> ---
>  commands/ethlog.c        |  4 ++--
>  drivers/mtd/ubi/attach.c |  2 +-
>  fs/ubifs/debug.c         |  4 ++--
>  include/linux/printk.h   |  4 ++--
>  include/printf.h         |  2 +-
>  include/soc/ti/cppi5.h   |  2 +-
>  lib/hexdump.c            | 13 +++++--------
>  7 files changed, 14 insertions(+), 17 deletions(-)
> 
> diff --git a/commands/ethlog.c b/commands/ethlog.c
> index 21d88bf1cbfba1b1688fd1101686c0c5c85bb56a..d641fd90ddb82c437348de11f8c3a99b686163ac 100644
> --- a/commands/ethlog.c
> +++ b/commands/ethlog.c
> @@ -12,7 +12,7 @@
>  static void ethlog_rx_monitor(struct eth_device *edev, void *packet,
>  			       int length)
>  {
> -	dev_print_hex_dump(&edev->dev, KERN_DEBUG, "rx data <: ",
> +	dev_print_hex_dump(&edev->dev, MSG_DEBUG, "rx data <: ",
>  			   DUMP_PREFIX_OFFSET, 16, 1, packet, length, true);
>  	printk("\n");
>  }
> @@ -20,7 +20,7 @@ static void ethlog_rx_monitor(struct eth_device *edev, void *packet,
>  static void ethlog_tx_monitor(struct eth_device *edev, void *packet,
>  			       int length)
>  {
> -	dev_print_hex_dump(&edev->dev, KERN_DEBUG, "tx data >: ",
> +	dev_print_hex_dump(&edev->dev, MSG_DEBUG, "tx data >: ",
>  			   DUMP_PREFIX_OFFSET, 16, 1, packet, length, true);
>  	printk("\n");
>  }
> diff --git a/drivers/mtd/ubi/attach.c b/drivers/mtd/ubi/attach.c
> index 44fe435e4163f81e4d120d246dab1a028c68ce37..e49ceb8690d8de0a14cb1de88458f3d79827ce56 100644
> --- a/drivers/mtd/ubi/attach.c
> +++ b/drivers/mtd/ubi/attach.c
> @@ -897,7 +897,7 @@ static int check_corruption(struct ubi_device *ubi, struct ubi_vid_hdr *vid_hdr,
>  	ubi_dump_vid_hdr(vid_hdr);
>  	pr_err("hexdump of PEB %d offset %d, length %d\n",
>  	       pnum, ubi->leb_start, ubi->leb_size);
> -	ubi_dbg_print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1,
> +	ubi_dbg_print_hex_dump(MSG_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1,
>  			       ubi->peb_buf, ubi->leb_size, 1);
>  	err = 1;
>  
> diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
> index a4cffe84df7118f062d63721982e3e88aaf45d49..2aae47b3b7d8dc36d68b02d125580d22eedf6852 100644
> --- a/fs/ubifs/debug.c
> +++ b/fs/ubifs/debug.c
> @@ -224,7 +224,7 @@ void ubifs_dump_node(const struct ubifs_info *c, const void *node)
>  	/* If the magic is incorrect, just hexdump the first bytes */
>  	if (le32_to_cpu(ch->magic) != UBIFS_NODE_MAGIC) {
>  		pr_err("Not a node, first %zu bytes:", UBIFS_CH_SZ);
> -		print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 32, 1,
> +		print_hex_dump(MSG_ERR, "", DUMP_PREFIX_OFFSET, 32, 1,
>  			       (void *)node, UBIFS_CH_SZ, 1);
>  		return;
>  	}
> @@ -400,7 +400,7 @@ void ubifs_dump_node(const struct ubifs_info *c, const void *node)
>  		       (int)le16_to_cpu(dn->compr_type));
>  		pr_err("\tdata size      %d\n", dlen);
>  		pr_err("\tdata:\n");
> -		print_hex_dump(KERN_ERR, "\t", DUMP_PREFIX_OFFSET, 32, 1,
> +		print_hex_dump(MSG_ERR, "\t", DUMP_PREFIX_OFFSET, 32, 1,
>  			       (void *)&dn->data, dlen, 0);
>  		break;
>  	}
> diff --git a/include/linux/printk.h b/include/linux/printk.h
> index 0d7180f0ebbca1dbe583a1798203e9ac61a64b0a..6c071af5158bcc36ae3582fe20e28a8dae0e6947 100644
> --- a/include/linux/printk.h
> +++ b/include/linux/printk.h
> @@ -202,7 +202,7 @@ struct va_format {
>  #if LOGLEVEL >= MSG_DEBUG
>  #define print_hex_dump_debug(prefix_str, prefix_type, rowsize,		\
>  			     groupsize, buf, len, ascii)		\
> -	print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, rowsize,	\
> +	print_hex_dump(MSG_DEBUG, prefix_str, prefix_type, rowsize,	\
>  		       groupsize, buf, len, ascii)
>  #else
>  static inline void print_hex_dump_debug(const char *prefix_str, int prefix_type,
> @@ -221,7 +221,7 @@ static inline void print_hex_dump_debug(const char *prefix_str, int prefix_type,
>   * @buf: data blob to dump
>   * @len: number of bytes in the @buf
>   *
> - * Calls print_hex_dump(), with log level of KERN_DEBUG,
> + * Calls print_hex_dump(), with log level of MSG_DEBUG,
>   * rowsize of 16, groupsize of 1, and ASCII output included.
>   */
>  #define print_hex_dump_bytes(prefix_str, prefix_type, buf, len)	\
> diff --git a/include/printf.h b/include/printf.h
> index 3503b72c9e5eca3e8a81cde4269db62a8080e203..92d6e18728f5baa9ab680962ef26b845c465a0a5 100644
> --- a/include/printf.h
> +++ b/include/printf.h
> @@ -52,7 +52,7 @@ enum {
>  extern int hex_dump_to_buffer(const void *buf, size_t len, int rowsize,
>  			      int groupsize, char *linebuf, size_t linebuflen,
>  			      bool ascii);
> -extern void dev_print_hex_dump(struct device *dev, const char *level,
> +extern void dev_print_hex_dump(struct device *dev, int level,
>  			       const char *prefix_str, int prefix_type,
>  			       int rowsize, int groupsize, const void *buf,
>  			       size_t len, bool ascii);
> diff --git a/include/soc/ti/cppi5.h b/include/soc/ti/cppi5.h
> index 34e118fff25a4348870f27953bcd32e98dc47860..6331a38a85f0f1528539b779ce1c995ed9186eaa 100644
> --- a/include/soc/ti/cppi5.h
> +++ b/include/soc/ti/cppi5.h
> @@ -150,7 +150,7 @@ struct cppi5_monolithic_desc_t {
>  
>  static inline void cppi5_desc_dump(void *desc, u32 size)
>  {
> -	print_hex_dump(KERN_ERR, "dump udmap_desc: ", DUMP_PREFIX_NONE,
> +	print_hex_dump(MSG_ERR, "dump udmap_desc: ", DUMP_PREFIX_NONE,
>  		       32, 4, desc, size, false);
>  }
>  
> diff --git a/lib/hexdump.c b/lib/hexdump.c
> index 940c4eec64e926cbb1ecaa3aa20863c3e672c81e..d98a4e6100d6e8783ad6cbda30845749875484cf 100644
> --- a/lib/hexdump.c
> +++ b/lib/hexdump.c
> @@ -228,7 +228,7 @@ EXPORT_SYMBOL(hex_dump_to_buffer);
>  
>  /**
>   * print_hex_dump - print a text hex dump to syslog for a binary blob of data
> - * @level: kernel log level (e.g. KERN_DEBUG)
> + * @level: barebox log level (e.g. MSG_DEBUG)
>   * @prefix_str: string to prefix each line with;
>   *  caller supplies trailing spaces for alignment if desired
>   * @prefix_type: controls whether prefix of an offset, address, or none
> @@ -257,7 +257,7 @@ EXPORT_SYMBOL(hex_dump_to_buffer);
>   * Example output using %DUMP_PREFIX_ADDRESS and 4-byte mode:
>   * ffffffff88089af0: 73727170 77767574 7b7a7978 7f7e7d7c  pqrstuvwxyz{|}~.
>   */
> -void dev_print_hex_dump(struct device *dev, const char *level,
> +void dev_print_hex_dump(struct device *dev, int level,
>  			const char *prefix_str, int prefix_type, int rowsize,
>  			int groupsize, const void *buf, size_t len, bool ascii)
>  {
> @@ -284,16 +284,13 @@ void dev_print_hex_dump(struct device *dev, const char *level,
>  
>  		switch (prefix_type) {
>  		case DUMP_PREFIX_ADDRESS:
> -			printk("%s%s%s%p: %s\n", level, name, prefix_str,
> -			       ptr + i, linebuf);
> +			pr_print(level, "%s%s%p: %s\n", name, prefix_str, ptr + i, linebuf);
>  			break;
>  		case DUMP_PREFIX_OFFSET:
> -			printk("%s%s%s%.8x: %s\n", level, name, prefix_str,
> -			       i, linebuf);
> +			pr_print(level, "%s%s%.8x: %s\n", name, prefix_str, i, linebuf);
>  			break;
>  		default:
> -			printk("%s%s%s%s\n", level, name, prefix_str,
> -			       linebuf);
> +			pr_print(level, "%s%s%s\n", name, prefix_str, linebuf);
>  			break;
>  		}
>  	}
> 

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




  reply	other threads:[~2026-02-06 13:05 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-05 15:45 [PATCH 0/5] Hexagon Geosystems GS05 Board Support Marco Felsch
2026-02-05 15:45 ` [PATCH 1/5] ARM: i.MX8MM: add MX8MM_PAD_CTL defines Marco Felsch
2026-02-06 13:04   ` Ahmad Fatoum
2026-02-05 15:45 ` [PATCH 2/5] lib: hexdump: make use of pr_print Marco Felsch
2026-02-06 13:05   ` Ahmad Fatoum [this message]
2026-02-05 15:45 ` [PATCH 3/5] mfd: Add Hexagon EFI driver Marco Felsch
2026-02-06 13:09   ` Ahmad Fatoum
2026-02-06 15:52     ` Marco Felsch
2026-02-09  9:03   ` Sascha Hauer
2026-02-09 11:13     ` Marco Felsch
2026-02-09 13:46       ` Sascha Hauer
2026-02-05 15:45 ` [PATCH 4/5] watchdog: Add Hexagon EFI watchdog driver Marco Felsch
2026-02-06 13:13   ` Ahmad Fatoum
2026-02-06 16:34     ` Marco Felsch
2026-02-05 15:45 ` [PATCH 5/5] ARM: i.MX8MM: add Hexagon Geosystems GS05 Marco Felsch
2026-02-06 13:47   ` Ahmad Fatoum
2026-02-06 14:07     ` SCHNEIDER Johannes
2026-02-06 15:43       ` Marco Felsch
2026-02-06 17:12     ` Marco Felsch
2026-02-09 10:42   ` Sascha Hauer
2026-02-09 11:39     ` Marco Felsch
2026-02-09 13:40       ` Sascha Hauer
2026-02-05 15:50 ` [PATCH 0/5] Hexagon Geosystems GS05 Board Support Marco Felsch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4aa3046c-1220-48e2-8a6a-dfef3137778b@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=m.felsch@pengutronix.de \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox