]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
initrd: Use str_plural() in rd_load_image()
authorThorsten Blum <thorsten.blum@linux.dev>
Fri, 12 Sep 2025 07:46:52 +0000 (09:46 +0200)
committerChristian Brauner <brauner@kernel.org>
Mon, 15 Sep 2025 12:47:14 +0000 (14:47 +0200)
Add the local variable 'nr_disks' and replace the manual ternary "s"
pluralization with the standardized str_plural() helper function.

Use pr_notice() instead of printk(KERN_NOTICE) to silence a checkpatch
warning.

No functional changes intended.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
init/do_mounts_rd.c

index 3cbdf43a42dff551008fdbd4d27178714c6b89f2..19d9f33dcacf85df4fe0462a3f69bfbf4335c793 100644 (file)
@@ -7,6 +7,7 @@
 #include <uapi/linux/cramfs_fs.h>
 #include <linux/initrd.h>
 #include <linux/string.h>
+#include <linux/string_choices.h>
 #include <linux/slab.h>
 
 #include "do_mounts.h"
@@ -186,7 +187,7 @@ static unsigned long nr_blocks(struct file *file)
 int __init rd_load_image(char *from)
 {
        int res = 0;
-       unsigned long rd_blocks, devblocks;
+       unsigned long rd_blocks, devblocks, nr_disks;
        int nblocks, i;
        char *buf = NULL;
        unsigned short rotate = 0;
@@ -242,8 +243,9 @@ int __init rd_load_image(char *from)
                goto done;
        }
 
-       printk(KERN_NOTICE "RAMDISK: Loading %dKiB [%ld disk%s] into ram disk... ",
-               nblocks, ((nblocks-1)/devblocks)+1, nblocks>devblocks ? "s" : "");
+       nr_disks = (nblocks - 1) / devblocks + 1;
+       pr_notice("RAMDISK: Loading %dKiB [%ld disk%s] into ram disk... ",
+                 nblocks, nr_disks, str_plural(nr_disks));
        for (i = 0; i < nblocks; i++) {
                if (i && (i % devblocks == 0)) {
                        pr_cont("done disk #1.\n");