diff mbox series

[2/5] sysreset: mpc83xx: shuffle newline logic in mpc83xx_sysreset_get_status

Message ID 20200501145516.18168-3-rasmus.villemoes@prevas.dk
State Deferred
Delegated to: Tom Rini
Headers show
Series some sysreset patches (mostly for mpc83xx) | expand

Commit Message

Rasmus Villemoes May 1, 2020, 2:55 p.m. UTC
mpc83xx_sysreset_get_status() adds a newline to the buffer at the end
of the function. There's no point adding a newline in case the reset
status word happens to contain the RSR_HRS bit.

On the other hand, if one of the CONFIG_DISPLAY_AER_* options is
enabled, and the RSR_HSR bit wasn't set, we'd miss a newline before
the print_83xx_arb_event() output. That latter always includes a
newline in its output, so just pull up the scnprintf("\n") a bit.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 drivers/sysreset/sysreset_mpc83xx.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/sysreset/sysreset_mpc83xx.c b/drivers/sysreset/sysreset_mpc83xx.c
index 7148464d8b..3447b8e75c 100644
--- a/drivers/sysreset/sysreset_mpc83xx.c
+++ b/drivers/sysreset/sysreset_mpc83xx.c
@@ -158,13 +158,16 @@  static int mpc83xx_sysreset_get_status(struct udevice *dev, char *buf, int size)
 	for (i = 0; i < ARRAY_SIZE(bits); i++)
 		/* Print description of set bits */
 		if (rsr & bits[i].mask) {
-			res = scnprintf(buf, size, "%s%s%s", sep, bits[i].desc,
-				       (i == ARRAY_SIZE(bits) - 1) ? "\n" : "");
+			res = scnprintf(buf, size, "%s%s", sep, bits[i].desc);
 			buf += res;
 			size -= res;
 			sep = ", ";
 		}
 
+	res = scnprintf(buf, size, "\n");
+	buf += res;
+	size -= res;
+
 	/*
 	 * TODO(mario.six@gdsys.cc): Move this into a dedicated
 	 *			     arbiter driver
@@ -179,7 +182,6 @@  static int mpc83xx_sysreset_get_status(struct udevice *dev, char *buf, int size)
 		buf += res;
 		size -= res;
 	}
-	scnprintf(buf, size, "\n");
 
 	return 0;
 }