Skip to contentSkip to conversation

sh: dma: use str_plural helper in register_dmac

PATCH Superseded Thorsten Blum 2 participants 3 messages Jun 4 SuperH

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sh: dma: use str_plural helper in register_dmac

Replace the manual ternary "s" pluralization with str_plural() to simplify the code. This also corrects the "0 channels" case.

Use pr_info() while at it.

---
 arch/sh/drivers/dma/dma-api.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/sh/drivers/dma/dma-api.c +3 -2
index 31b614358270..7c8ee3a0bdf9 100644
@@ -17,6 +17,7 @@
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/string.h>
+#include <linux/string_choices.h>
 #include <asm/dma.h>
 
 DEFINE_SPINLOCK(dma_spin_lock);
@@ -200,8 +201,8 @@ int register_dmac(struct dma_info *info)
 
 	INIT_LIST_HEAD(&info->list);
 
-	printk(KERN_INFO "DMA: Registering %s handler (%d channel%s).\n",
-	       info->name, info->nr_channels, info->nr_channels > 1 ? "s" : "");
+	pr_info("DMA: Registering %s handler (%d channel%s).\n",
+		info->name, info->nr_channels, str_plural(info->nr_channels));
 
 	BUG_ON((info->flags & DMAC_CHANNELS_CONFIGURED) && !info->channels);
 
#1 lore raw

Please note that this patch requires the following to apply cleanly:
https://lore.kernel.org/lkml/[email protected]/

Quoted 33 lines · Thorsten Blum

Replace the manual ternary "s" pluralization with str_plural() to simplify the code. This also corrects the "0 channels" case.

Use pr_info() while at it.

---
 arch/sh/drivers/dma/dma-api.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/sh/drivers/dma/dma-api.c +3 -2
index 31b614358270..7c8ee3a0bdf9 100644
@@ -17,6 +17,7 @@
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/string.h>
+#include <linux/string_choices.h>
 #include <asm/dma.h>
 
 DEFINE_SPINLOCK(dma_spin_lock);
@@ -200,8 +201,8 @@ int register_dmac(struct dma_info *info)
 
 	INIT_LIST_HEAD(&info->list);
 
-	printk(KERN_INFO "DMA: Registering %s handler (%d channel%s).\n",
-	       info->name, info->nr_channels, info->nr_channels > 1 ? "s" : "");
+	pr_info("DMA: Registering %s handler (%d channel%s).\n",
+		info->name, info->nr_channels, str_plural(info->nr_channels));
 
 	BUG_ON((info->flags & DMAC_CHANNELS_CONFIGURED) && !info->channels);
 
Reviewed-by on v1 1/1
#2 lore raw
In reply to Thorsten Blum

Hi Thorsten,

Quoted 6 lines · Thorsten Blum

Replace the manual ternary "s" pluralization with str_plural() to simplify the code. This also corrects the "0 channels" case.

Use pr_info() while at it.

Thanks for your patch!

Quoted 11 lines
arch/sh/drivers/dma/dma-api.c +1 -0
@@ -17,6 +17,7 @@
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/string.h>
+#include <linux/string_choices.h>
 #include <asm/dma.h>
 
 DEFINE_SPINLOCK(dma_spin_lock);

arch/sh/drivers/dma/dma-api.c int register_dmac(struct dma_info *info) · line 204

Quoted 6 lines
arch/sh/drivers/dma/dma-api.c +1 -2
@@ -200,8 +201,8 @@ int register_dmac(struct dma_info *info)
 
        INIT_LIST_HEAD(&info->list);
 
-       printk(KERN_INFO "DMA: Registering %s handler (%d channel%s).\n",
-              info->name, info->nr_channels, info->nr_channels > 1 ? "s" : "");
+       pr_info("DMA: Registering %s handler (%d channel%s).\n",

%u, while at it?

arch/sh/drivers/dma/dma-api.c int register_dmac(struct dma_info *info) · line 207

Quoted 3 lines
arch/sh/drivers/dma/dma-api.c +1 -0
+               info->name, info->nr_channels, str_plural(info->nr_channels));
 
        BUG_ON((info->flags & DMAC_CHANNELS_CONFIGURED) && !info->channels);

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds