From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] treewide: replace inappropriate printk
Date: Mon, 31 Aug 2026 16:46:09 +0200 [thread overview]
Message-ID: <20260831144610.1034307-1-a.fatoum@pengutronix.de> (raw)
In preparation for making printk loglevel-aware in the future, replace bare
printk in command handlers with printf, as it's user-facing output,
and in library code with pr_err/pr_warn to get proper log level annotations.
Remaining instances of printk are mostly in driver code and will be fine
when we switch to logging instead of printf.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/mach-imx/imx6-mmdc.c | 8 ++++----
arch/mips/lib/cpuinfo.c | 8 ++++----
commands/ethlog.c | 4 ++--
drivers/mtd/nand/raw/nand_denali.c | 1 -
drivers/pci/pci-tegra.c | 7 +++----
drivers/usb/gadget/udc/fsl_udc.c | 2 +-
fs/cramfs/uncompress.c | 6 +++---
lib/gui/png_lode.c | 6 +++---
lib/gui/png_pico.c | 6 +++---
9 files changed, 23 insertions(+), 25 deletions(-)
diff --git a/arch/arm/mach-imx/imx6-mmdc.c b/arch/arm/mach-imx/imx6-mmdc.c
index 134a41bad58b..8d0dc5c496d9 100644
--- a/arch/arm/mach-imx/imx6-mmdc.c
+++ b/arch/arm/mach-imx/imx6-mmdc.c
@@ -829,10 +829,10 @@ int mmdc_do_software_calibration(void)
mmdc_sw_read_calib(ch, s);
}
- printk("ch0 total lower: %d upper: %d avg: 0x%02x\n",
+ printf("ch0 total lower: %d upper: %d avg: 0x%02x\n",
total_lower[0], total_upper[0],
(total_lower[0] + total_upper[0]) / 2);
- printk("ch1 total lower: %d upper: %d avg: 0x%02x\n",
+ printf("ch1 total lower: %d upper: %d avg: 0x%02x\n",
total_lower[1], total_upper[1],
(total_lower[1] + total_upper[1]) / 2);
@@ -857,10 +857,10 @@ int mmdc_do_software_calibration(void)
mmdc_sw_write_calib(ch, s);
}
- printk("ch0 total lower: %d upper: %d avg: 0x%02x\n",
+ printf("ch0 total lower: %d upper: %d avg: 0x%02x\n",
total_lower[0], total_upper[0],
(total_lower[0] + total_upper[0]) / 2);
- printk("ch1 total lower: %d upper: %d avg: 0x%02x\n",
+ printf("ch1 total lower: %d upper: %d avg: 0x%02x\n",
total_lower[1], total_upper[1],
(total_lower[1] + total_upper[1]) / 2);
diff --git a/arch/mips/lib/cpuinfo.c b/arch/mips/lib/cpuinfo.c
index 41ec7b8d532b..f7472ab169d1 100644
--- a/arch/mips/lib/cpuinfo.c
+++ b/arch/mips/lib/cpuinfo.c
@@ -19,18 +19,18 @@ static int do_cpuinfo(int argc, char *argv[])
unsigned int icache_size, dcache_size, scache_size;
struct cpuinfo_mips *c = ¤t_cpu_data;
- printk(KERN_INFO "CPU revision is: %08x (%s)\n",
+ printf("CPU revision is: %08x (%s)\n",
current_cpu_data.processor_id, __cpu_name);
icache_size = c->icache.sets * c->icache.ways * c->icache.linesz;
dcache_size = c->dcache.sets * c->dcache.ways * c->dcache.linesz;
- printk("Primary instruction cache %ukB, %s, %s, linesize %d bytes.\n",
+ printf("Primary instruction cache %ukB, %s, %s, linesize %d bytes.\n",
icache_size >> 10,
c->icache.flags & MIPS_CACHE_VTAG ? "VIVT" : "VIPT",
way_string[c->icache.ways], c->icache.linesz);
- printk("Primary data cache %ukB, %s, %s, %s, linesize %d bytes\n",
+ printf("Primary data cache %ukB, %s, %s, %s, linesize %d bytes\n",
dcache_size >> 10, way_string[c->dcache.ways],
(c->dcache.flags & MIPS_CACHE_PINDEX) ? "PIPT" : "VIPT",
(c->dcache.flags & MIPS_CACHE_ALIASES) ?
@@ -39,7 +39,7 @@ static int do_cpuinfo(int argc, char *argv[])
if (c->scache.flags & MIPS_CACHE_NOT_PRESENT)
return 0;
scache_size = c->scache.sets * c->scache.ways * c->scache.linesz;
- printk("Secondary data cache %ukB, %s, %s, %s, linesize %d bytes\n",
+ printf("Secondary data cache %ukB, %s, %s, %s, linesize %d bytes\n",
scache_size >> 10, way_string[c->scache.ways],
(c->scache.flags & MIPS_CACHE_PINDEX) ? "PIPT" : "VIPT",
(c->scache.flags & MIPS_CACHE_ALIASES) ?
diff --git a/commands/ethlog.c b/commands/ethlog.c
index d641fd90ddb8..69da0479e1fb 100644
--- a/commands/ethlog.c
+++ b/commands/ethlog.c
@@ -14,7 +14,7 @@ static void ethlog_rx_monitor(struct eth_device *edev, void *packet,
{
dev_print_hex_dump(&edev->dev, MSG_DEBUG, "rx data <: ",
DUMP_PREFIX_OFFSET, 16, 1, packet, length, true);
- printk("\n");
+ pr_print(MSG_DEBUG, "\n");
}
static void ethlog_tx_monitor(struct eth_device *edev, void *packet,
@@ -22,7 +22,7 @@ static void ethlog_tx_monitor(struct eth_device *edev, void *packet,
{
dev_print_hex_dump(&edev->dev, MSG_DEBUG, "tx data >: ",
DUMP_PREFIX_OFFSET, 16, 1, packet, length, true);
- printk("\n");
+ pr_print(MSG_DEBUG, "\n");
}
static int do_ethlog(int argc, char *argv[])
diff --git a/drivers/mtd/nand/raw/nand_denali.c b/drivers/mtd/nand/raw/nand_denali.c
index 8fef992ef89f..216979832d03 100644
--- a/drivers/mtd/nand/raw/nand_denali.c
+++ b/drivers/mtd/nand/raw/nand_denali.c
@@ -1011,7 +1011,6 @@ static int denali_attach_chip(struct nand_chip *chip)
ret = nand_ecc_choose_conf(chip, denali->ecc_caps,
mtd->oobsize - denali->oob_skip_bytes);
if (ret) {
- printk("%s: %d\n", __func__, ret);
dev_err(denali->dev, "Failed to setup ECC settings.\n");
return ret;
}
diff --git a/drivers/pci/pci-tegra.c b/drivers/pci/pci-tegra.c
index dabe63500a4a..1c89caaf33e1 100644
--- a/drivers/pci/pci-tegra.c
+++ b/drivers/pci/pci-tegra.c
@@ -1249,10 +1249,9 @@ static int tegra_pcie_probe(struct device *dev)
pcie->soc_data = device_get_match_data(dev);
err = tegra_pcie_parse_dt(pcie);
- if (err < 0) {
- printk("parse DT failed\n");
- return err;
- }
+ if (err < 0)
+ return dev_err_probe(dev, err,
+ "failed to parse device tree\n");
err = tegra_pcie_get_resources(pcie);
if (err < 0) {
diff --git a/drivers/usb/gadget/udc/fsl_udc.c b/drivers/usb/gadget/udc/fsl_udc.c
index 54fc0df65567..f118a252a98f 100644
--- a/drivers/usb/gadget/udc/fsl_udc.c
+++ b/drivers/usb/gadget/udc/fsl_udc.c
@@ -680,7 +680,7 @@ static void fsl_free_request(struct usb_ep *_ep, struct usb_request *_req)
req = container_of(_req, struct fsl_req, req);
if (!list_empty(&req->queue)) {
- printk("%s: Freeing queued request\n", __func__);
+ pr_err("%s: Freeing queued request\n", __func__);
dump_stack();
}
diff --git a/fs/cramfs/uncompress.c b/fs/cramfs/uncompress.c
index 82c82adf044c..500ad8d28169 100644
--- a/fs/cramfs/uncompress.c
+++ b/fs/cramfs/uncompress.c
@@ -41,7 +41,7 @@ int cramfs_uncompress_block(void *dst, int dstlen, void *src, int srclen)
err = zlib_inflateReset(&stream);
if (err != Z_OK) {
- printk("zlib_inflateReset error %d\n", err);
+ pr_warn("zlib_inflateReset error %d\n", err);
zlib_inflateEnd(&stream);
zlib_inflateInit(&stream);
}
@@ -52,8 +52,8 @@ int cramfs_uncompress_block(void *dst, int dstlen, void *src, int srclen)
return stream.total_out;
err:
- printk("Error %d while decompressing!\n", err);
- printk("%p(%d)->%p(%d)\n", src, srclen, dst, dstlen);
+ pr_err("Error %d while decompressing: %p(%d)->%p(%d)\n",
+ err, src, srclen, dst, dstlen);
return -EIO;
}
diff --git a/lib/gui/png_lode.c b/lib/gui/png_lode.c
index 68149c848d5b..d1709b84b880 100644
--- a/lib/gui/png_lode.c
+++ b/lib/gui/png_lode.c
@@ -27,7 +27,7 @@ unsigned lodepng_custom_zlib_decompress(unsigned char** out, size_t* outsize,
err = zlib_inflateReset(&png_stream);
if (err != Z_OK) {
- printk("zlib_inflateReset error %d\n", err);
+ pr_warn("zlib_inflateReset error %d\n", err);
zlib_inflateEnd(&png_stream);
zlib_inflateInit(&png_stream);
}
@@ -38,8 +38,8 @@ unsigned lodepng_custom_zlib_decompress(unsigned char** out, size_t* outsize,
return 0;
err:
- printk("Error %d while decompressing!\n", err);
- printk("%p(%zd)->%p(%zd)\n", in, insize, *out, *outsize);
+ pr_err("Error %d while decompressing: %p(%zd)->%p(%zd)\n",
+ err, in, insize, *out, *outsize);
return -EIO;
}
diff --git a/lib/gui/png_pico.c b/lib/gui/png_pico.c
index bf6eddb74b4d..cadbd52de7d1 100644
--- a/lib/gui/png_pico.c
+++ b/lib/gui/png_pico.c
@@ -26,7 +26,7 @@ unsigned picopng_zlib_decompress(unsigned char* out, size_t outsize,
err = zlib_inflateReset(&png_stream);
if (err != Z_OK) {
- printk("zlib_inflateReset error %d\n", err);
+ pr_warn("zlib_inflateReset error %d\n", err);
zlib_inflateEnd(&png_stream);
zlib_inflateInit(&png_stream);
}
@@ -37,8 +37,8 @@ unsigned picopng_zlib_decompress(unsigned char* out, size_t outsize,
return 0;
err:
- printk("Error %d while decompressing!\n", err);
- printk("%p(%zd)->%p(%zd)\n", in, insize, out, outsize);
+ pr_err("Error %d while decompressing: %p(%zd)->%p(%zd)\n",
+ err, in, insize, out, outsize);
return -EIO;
}
--
2.47.3
reply other threads:[~2026-08-31 14:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260831144610.1034307-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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