diff mbox series

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

Message ID 20240618075248.1325-1-jiapeng.chong@linux.alibaba.com
State Rejected
Headers show
Series pwm: core: Use str_plural() in pwm_seq_show() | expand

Commit Message

Jiapeng Chong June 18, 2024, 7:52 a.m. UTC
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(-)

Comments

Uwe Kleine-König July 5, 2024, 9:30 a.m. UTC | #1
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.
diff mbox series

Patch

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);