Skip to contentSkip to conversation

pwm: core: Use str_plural() in pwm_seq_show()

PATCH In review Jiapeng Chong 2 participants 2 messages Jun 18, 2024 – Jul 5, 2024 PWM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pwm: core: Use str_plural() in pwm_seq_show()

Use existing str_plural() function rather than duplicating its implementation.

./drivers/pwm/core.c:1690:6-16: opportunity for str_plural(chip->npwm).

---
 drivers/pwm/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pwm/core.c +1 -1
index 5c1d20985148..141c5003b216 100644
@@ -1687,7 +1687,7 @@ static int pwm_seq_show(struct seq_file *s, void *v)
 		   (char *)s->private, chip->id,
 		   pwmchip_parent(chip)->bus ? pwmchip_parent(chip)->bus->name : "no-bus",
 		   dev_name(pwmchip_parent(chip)), chip->npwm,
-		   (chip->npwm != 1) ? "s" : "");
+		   str_plural(chip->npwm));
 
 	pwm_dbg_show(chip, s);
 
Signature · 1 line
2.20.1.7.g153144c
#1 lore raw
Quoted 17 lines · Jiapeng Chong

Use existing str_plural() function rather than duplicating its implementation.

./drivers/pwm/core.c:1690:6-16: opportunity for str_plural(chip->npwm).

---
 drivers/pwm/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pwm/core.c +0 -0
index 5c1d20985148..141c5003b216 100644

drivers/pwm/core.c static int pwm_seq_show(struct seq_file *s, void *v) · line 1692

Quoted 7 lines
drivers/pwm/core.c +1 -1
@@ -1687,7 +1687,7 @@ static int pwm_seq_show(struct seq_file *s, void *v)
 		   (char *)s->private, chip->id,
 		   pwmchip_parent(chip)->bus ? pwmchip_parent(chip)->bus->name : "no-bus",
 		   dev_name(pwmchip_parent(chip)), chip->npwm,
-		   (chip->npwm != 1) ? "s" : "");
+		   str_plural(chip->npwm));
 
 	pwm_dbg_show(chip, s);

I'm not convinced this change to be beneficial. Given that emitting npwm doesn't add a valuable information[1], I tend to suggest instead:

drivers/pwm/core.c +2 -3
index 5c1d20985148..fc7aa17dc6b5 100644
@@ -1683,11 +1683,10 @@ static int pwm_seq_show(struct seq_file *s, void *v)
 {
 	struct pwm_chip *chip = v;
 
-	seq_printf(s, "%s%d: %s/%s, %d PWM device%s\n",
+	seq_printf(s, "%s%d: %s/%s\n",
 		   (char *)s->private, chip->id,
 		   pwmchip_parent(chip)->bus ? pwmchip_parent(chip)->bus->name : "no-bus",
-		   dev_name(pwmchip_parent(chip)), chip->npwm,
-		   (chip->npwm != 1) ? "s" : "");
+		   dev_name(pwmchip_parent(chip)))
 
 	pwm_dbg_show(chip, s);
 

If you want to pick up on this, feel free to use this patch without attribution.

Best regards
Uwe

[1] pwm_dbg_show() emits npwm lines, so the value can be determined easily.