From patchwork Fri May 1 14:55:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 244747 List-Id: U-Boot discussion From: rasmus.villemoes at prevas.dk (Rasmus Villemoes) Date: Fri, 1 May 2020 16:55:13 +0200 Subject: [PATCH 2/5] sysreset: mpc83xx: shuffle newline logic in mpc83xx_sysreset_get_status In-Reply-To: <20200501145516.18168-1-rasmus.villemoes@prevas.dk> References: <20200501145516.18168-1-rasmus.villemoes@prevas.dk> Message-ID: <20200501145516.18168-3-rasmus.villemoes@prevas.dk> 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 --- 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; }