From: Damien Le Moal <dlemoal@kernel.org>
To: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org
Subject: [PATCH 3/5] block: use pr_xxx() instead of printk() in partition code
Date: Tue, 8 Aug 2023 22:57:00 +0900 [thread overview]
Message-ID: <20230808135702.628588-4-dlemoal@kernel.org> (raw)
In-Reply-To: <20230808135702.628588-1-dlemoal@kernel.org>
Replace calls to printk() in the core, atari, efi and sun partition
code with the equivalent pr_info(), pr_err() etc calls. For each
partition type, the pr_fmt message prefix is defined as "partition: xxx:
" where "xxx" is the partition type name.
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
block/partitions/atari.c | 11 +++++++----
block/partitions/check.h | 1 +
block/partitions/core.c | 33 ++++++++++++++++-----------------
block/partitions/sgi.c | 7 +++++--
block/partitions/sun.c | 5 ++++-
5 files changed, 33 insertions(+), 24 deletions(-)
diff --git a/block/partitions/atari.c b/block/partitions/atari.c
index 9655c728262a..e48eec5b9fd0 100644
--- a/block/partitions/atari.c
+++ b/block/partitions/atari.c
@@ -12,6 +12,9 @@
#include "check.h"
#include "atari.h"
+#undef pr_fmt
+#define pr_fmt(fmt) "partition: atari: " fmt
+
/* ++guenther: this should be settable by the user ("make config")?.
*/
#define ICD_PARTS
@@ -94,14 +97,14 @@ int atari_partition(struct parsed_partitions *state)
while (1) {
xrs = read_part_sector(state, partsect, §2);
if (!xrs) {
- printk (" block %ld read failed\n", partsect);
+ pr_err(" block %ld read failed\n", partsect);
put_dev_sector(sect);
return -1;
}
/* ++roman: sanity check: bit 0 of flg field must be set */
if (!(xrs->part[0].flg & 1)) {
- printk( "\nFirst sub-partition in extended partition is not valid!\n" );
+ pr_err("\nFirst sub-partition in extended partition is not valid!\n");
put_dev_sector(sect2);
break;
}
@@ -116,7 +119,7 @@ int atari_partition(struct parsed_partitions *state)
break;
}
if (memcmp( xrs->part[1].id, "XGM", 3 ) != 0) {
- printk("\nID of extended partition is not XGM!\n");
+ pr_err("\nID of extended partition is not XGM!\n");
put_dev_sector(sect2);
break;
}
@@ -124,7 +127,7 @@ int atari_partition(struct parsed_partitions *state)
partsect = be32_to_cpu(xrs->part[1].st) + extensect;
put_dev_sector(sect2);
if (++slot == state->limit) {
- printk( "\nMaximum number of partitions reached!\n" );
+ pr_err("\nMaximum number of partitions reached!\n");
break;
}
}
diff --git a/block/partitions/check.h b/block/partitions/check.h
index 8d70a880c372..33c065339edc 100644
--- a/block/partitions/check.h
+++ b/block/partitions/check.h
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0 */
#include <linux/pagemap.h>
#include <linux/blkdev.h>
+#include <linux/printk.h>
#include "../blk.h"
/*
diff --git a/block/partitions/core.c b/block/partitions/core.c
index 13a7341299a9..fcf0cf321350 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -12,6 +12,9 @@
#include <linux/raid/detect.h>
#include "check.h"
+#undef pr_fmt
+#define pr_fmt(fmt) "partition: " fmt
+
static int (*const check_part[])(struct parsed_partitions *) = {
/*
* Probe partition formats with tables at disk address 0
@@ -147,8 +150,7 @@ static struct parsed_partitions *check_partition(struct gendisk *hd)
}
if (res > 0) {
- printk(KERN_INFO "%s", state->pp_buf);
-
+ pr_info("%s", state->pp_buf);
free_page((unsigned long)state->pp_buf);
return state;
}
@@ -162,7 +164,7 @@ static struct parsed_partitions *check_partition(struct gendisk *hd)
if (res) {
strlcat(state->pp_buf,
" unable to read partition table\n", PAGE_SIZE);
- printk(KERN_INFO "%s", state->pp_buf);
+ pr_info("%s", state->pp_buf);
}
free_page((unsigned long)state->pp_buf);
@@ -526,11 +528,11 @@ static bool disk_unlock_native_capacity(struct gendisk *disk)
{
if (!disk->fops->unlock_native_capacity ||
test_and_set_bit(GD_NATIVE_CAPACITY, &disk->state)) {
- printk(KERN_CONT "truncated\n");
+ pr_cont("truncated\n");
return false;
}
- printk(KERN_CONT "enabling native capacity\n");
+ pr_cont("enabling native capacity\n");
disk->fops->unlock_native_capacity(disk);
return true;
}
@@ -546,18 +548,16 @@ static bool blk_add_partition(struct gendisk *disk,
return true;
if (from >= get_capacity(disk)) {
- printk(KERN_WARNING
- "%s: p%d start %llu is beyond EOD, ",
- disk->disk_name, p, (unsigned long long) from);
+ pr_warn("%s: p%d start %llu is beyond EOD, ",
+ disk->disk_name, p, (unsigned long long) from);
if (disk_unlock_native_capacity(disk))
return false;
return true;
}
if (from + size > get_capacity(disk)) {
- printk(KERN_WARNING
- "%s: p%d size %llu extends beyond EOD, ",
- disk->disk_name, p, (unsigned long long) size);
+ pr_warn("%s: p%d size %llu extends beyond EOD, ",
+ disk->disk_name, p, (unsigned long long) size);
if (disk_unlock_native_capacity(disk))
return false;
@@ -573,7 +573,7 @@ static bool blk_add_partition(struct gendisk *disk,
part = add_partition(disk, p, from, size, state->parts[p].flags,
&state->parts[p].info);
if (IS_ERR(part) && PTR_ERR(part) != -ENXIO) {
- printk(KERN_ERR " %s: p%d could not be added: %ld\n",
+ pr_err(" %s: p%d could not be added: %ld\n",
disk->disk_name, p, -PTR_ERR(part));
return true;
}
@@ -605,8 +605,8 @@ static int blk_add_partitions(struct gendisk *disk)
* beyond EOD, retry after unlocking the native capacity.
*/
if (PTR_ERR(state) == -ENOSPC) {
- printk(KERN_WARNING "%s: partition table beyond EOD, ",
- disk->disk_name);
+ pr_warn("%s: partition table beyond EOD, ",
+ disk->disk_name);
if (disk_unlock_native_capacity(disk))
return -EAGAIN;
}
@@ -629,9 +629,8 @@ static int blk_add_partitions(struct gendisk *disk)
* partitions.
*/
if (state->access_beyond_eod) {
- printk(KERN_WARNING
- "%s: partition table partially beyond EOD, ",
- disk->disk_name);
+ pr_warn("%s: partition table partially beyond EOD, ",
+ disk->disk_name);
if (disk_unlock_native_capacity(disk))
goto out_free_state;
}
diff --git a/block/partitions/sgi.c b/block/partitions/sgi.c
index 9cc6b8c1eea4..598d3480aaeb 100644
--- a/block/partitions/sgi.c
+++ b/block/partitions/sgi.c
@@ -7,6 +7,9 @@
#include "check.h"
+#undef pr_fmt
+#define pr_fmt(fmt) "partition: sgi: " fmt
+
#define SGI_LABEL_MAGIC 0x0be5a941
enum {
@@ -61,8 +64,8 @@ int sgi_partition(struct parsed_partitions *state)
csum += be32_to_cpu(cs);
}
if(csum) {
- printk(KERN_WARNING "Dev %s SGI disklabel: csum bad, label corrupted\n",
- state->disk->disk_name);
+ pr_warn("Dev %s SGI disklabel: csum bad, label corrupted\n",
+ state->disk->disk_name);
put_dev_sector(sect);
return 0;
}
diff --git a/block/partitions/sun.c b/block/partitions/sun.c
index ddf9e6def4b2..ca3e57f63938 100644
--- a/block/partitions/sun.c
+++ b/block/partitions/sun.c
@@ -10,6 +10,9 @@
#include "check.h"
+#undef pr_fmt
+#define pr_fmt(fmt) "partition: sun: " fmt
+
#define SUN_LABEL_MAGIC 0xDABE
#define SUN_VTOC_SANITY 0x600DDEEE
@@ -84,7 +87,7 @@ int sun_partition(struct parsed_partitions *state)
for (csum = 0; ush >= ((__be16 *) label);)
csum ^= *ush--;
if (csum) {
- printk("Dev %s Sun disklabel: Csum bad, label corrupted\n",
+ pr_err("Dev %s Sun disklabel: Csum bad, label corrupted\n",
state->disk->disk_name);
put_dev_sector(sect);
return 0;
--
2.41.0
next prev parent reply other threads:[~2023-08-08 17:57 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-08 13:56 [PATCH 0/5] Some minor cleanups Damien Le Moal
2023-08-08 13:56 ` [PATCH 1/5] block: use PAGE_SECTORS_SHIFT to set limits Damien Le Moal
2023-08-09 2:04 ` Chaitanya Kulkarni
2023-08-09 6:07 ` Hannes Reinecke
2023-08-15 10:00 ` Johannes Thumshirn
2023-08-08 13:56 ` [PATCH 2/5] block: use pr_xxx() instead of printk() Damien Le Moal
2023-08-09 2:06 ` Chaitanya Kulkarni
2023-08-09 6:08 ` Hannes Reinecke
2023-08-15 10:01 ` Johannes Thumshirn
2023-08-08 13:57 ` Damien Le Moal [this message]
2023-08-09 2:07 ` [PATCH 3/5] block: use pr_xxx() instead of printk() in partition code Chaitanya Kulkarni
2023-08-09 3:42 ` Damien Le Moal
2023-08-09 6:09 ` Hannes Reinecke
2023-08-15 10:02 ` Johannes Thumshirn
2023-08-08 13:57 ` [PATCH 4/5] block: Improve efi partition debug messages Damien Le Moal
2023-08-09 2:07 ` Chaitanya Kulkarni
2023-08-09 6:09 ` Hannes Reinecke
2023-08-15 10:03 ` Johannes Thumshirn
2023-08-08 13:57 ` [PATCH 5/5] block: switch ldm partition code to use pr_xxx() functions Damien Le Moal
2023-08-09 2:08 ` Chaitanya Kulkarni
2023-08-09 6:10 ` Hannes Reinecke
2023-08-15 10:06 ` Johannes Thumshirn
2023-08-15 12:41 ` Damien Le Moal
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=20230808135702.628588-4-dlemoal@kernel.org \
--to=dlemoal@kernel.org \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.