Skip to contentSkip to conversation

pwm: More efficient data output in pwm_dbg_show()

PATCH In review Markus Elfring 2 participants 6 messages Jun 5 – Jul 19

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover pwm: More efficient data output in pwm_dbg_show()

From: Markus Elfring <[email protected]>
Date: Fri, 5 Jun 2026 16:18:19 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Simplify data output
Use seq_putc() calls

 drivers/pwm/core.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
Signature · 1 line
2.54.0
#1 lore raw

PATCH 1/2 pwm: Simplify data output in pwm_dbg_show()

From: Markus Elfring <[email protected]>
Date: Fri, 5 Jun 2026 15:57:58 +0200

Move the specification for a line break from a seq_puts() call to a seq_printf() call.

The source code was transformed by using the Coccinelle software.

---
 drivers/pwm/core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/pwm/core.c +1 -3
index be4885da85b6..1138b3ffbc12 100644
@@ -2647,9 +2647,7 @@ static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s)
 		if (test_bit(PWMF_REQUESTED, &pwm->flags))
 			seq_puts(s, " requested");
 
-		seq_puts(s, "\n");
-
-		seq_printf(s, "  requested configuration: %3sabled, %llu/%llu ns, %s polarity",
+		seq_printf(s, "\n  requested configuration: %3sabled, %llu/%llu ns, %s polarity",
 			   state.enabled ? "en" : "dis", state.duty_cycle, state.period,
 			   state.polarity ? "inverse" : "normal");
 		if (state.usage_power)
Signature · 1 line
2.54.0
#2 lore raw

PATCH 2/2 pwm: Use seq_putc() calls in pwm_dbg_show()

In reply to Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 5 Jun 2026 16:12:53 +0200

Single characters should occasionally be put into a sequence. Thus use the corresponding function “seq_putc”.

The source code was transformed by using the Coccinelle software.

---
 drivers/pwm/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pwm/core.c +2 -2
index 1138b3ffbc12..41b02a4a94f3 100644
@@ -2652,7 +2652,7 @@ static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s)
 			   state.polarity ? "inverse" : "normal");
 		if (state.usage_power)
 			seq_puts(s, ", usage_power");
-		seq_puts(s, "\n");
+		seq_putc(s, '\n');
 
 		if (pwmchip_supports_waveform(chip)) {
 			struct pwm_waveform wf;
@@ -2675,7 +2675,7 @@ static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s)
 				seq_printf(s, "  actual configuration: read out error: %pe", ERR_PTR(err));
 		}
 
-		seq_puts(s, "\n");
+		seq_putc(s, '\n');
 	}
 }
 
Signature · 1 line
2.54.0
#3 lore raw
In reply to Markus Elfring

Hello,

Quoted 9 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 5 Jun 2026 16:18:19 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Simplify data output
Use seq_putc() calls

I applied the 2nd patch. I don't consider the first an improvement as the output isn't on a fast path and having the end-of-line separated from the next is logically sound.

Best regards
Uwe

#4 lore raw

PATCH 1/1 pwm: Use another seq_putc() call in pwm_dbg_show()

From: Markus Elfring <[email protected]>
Date: Fri, 17 Jul 2026 11:33:55 +0200

A single line break should be put into a sequence. Thus use the corresponding function “seq_putc”.

The source code was transformed by using the Coccinelle software.

---
 drivers/pwm/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pwm/core.c +1 -2
index fa0f8f1f6ed0..c2d77082c549 100644
@@ -2647,8 +2647,7 @@ static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s)
 		if (test_bit(PWMF_REQUESTED, &pwm->flags))
 			seq_puts(s, " requested");
 
-		seq_puts(s, "\n");
-
+		seq_putc(s, '\n');
 		seq_printf(s, "  requested configuration: %3sabled, %llu/%llu ns, %s polarity",
 			   state.enabled ? "en" : "dis", state.duty_cycle, state.period,
 			   state.polarity ? "inverse" : "normal");
Signature · 1 line
2.55.0
#5 lore raw

Re: [PATCH] pwm: Use another seq_putc() call in pwm_dbg_show()

Quoted 9 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 17 Jul 2026 11:33:55 +0200

A single line break should be put into a sequence. Thus use the corresponding function “seq_putc”.

The source code was transformed by using the Coccinelle software.

I squashed this into the commit created from the original patch #2.

Thanks
Uwe