mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] pwm: core: Use str_plural() in pwm_seq_show()
@ 2024-06-18  7:52 Jiapeng Chong
  2024-07-05  9:30 ` Uwe Kleine-König
  0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2024-06-18  7:52 UTC (permalink / raw)
  To: ukleinek; +Cc: linux-pwm, linux-kernel, Jiapeng Chong, Abaci Robot

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

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

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9352
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 drivers/pwm/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 5c1d20985148..141c5003b216 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -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);
 
-- 
2.20.1.7.g153144c


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] pwm: core: Use str_plural() in pwm_seq_show()
  2024-06-18  7:52 [PATCH] pwm: core: Use str_plural() in pwm_seq_show() Jiapeng Chong
@ 2024-07-05  9:30 ` Uwe Kleine-König
  0 siblings, 0 replies; 2+ messages in thread
From: Uwe Kleine-König @ 2024-07-05  9:30 UTC (permalink / raw)
  To: Jiapeng Chong; +Cc: linux-pwm, linux-kernel, Abaci Robot

[-- Attachment #1: Type: text/plain, Size: 1973 bytes --]

On Tue, Jun 18, 2024 at 03:52:48PM +0800, Jiapeng Chong wrote:
> Use existing str_plural() function rather than duplicating its
> implementation.
> 
> ./drivers/pwm/core.c:1690:6-16: opportunity for str_plural(chip->npwm).
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9352
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>  drivers/pwm/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
> index 5c1d20985148..141c5003b216 100644
> --- a/drivers/pwm/core.c
> +++ b/drivers/pwm/core.c
> @@ -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:

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 5c1d20985148..fc7aa17dc6b5 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-05  9:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-18  7:52 [PATCH] pwm: core: Use str_plural() in pwm_seq_show() Jiapeng Chong
2024-07-05  9:30 ` Uwe Kleine-König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®