[PATCH 2/5] sysreset: mpc83xx: shuffle newline logic in mpc83xx_sysreset_get_status
Rasmus Villemoes
rasmus.villemoes at prevas.dk
Fri May 1 16:55:13 CEST 2020
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 at prevas.dk>
---
drivers/sysreset/sysreset_mpc83xx.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
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 at 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;
}
--
2.23.0
More information about the U-Boot
mailing list