Commit b3bee19e authored by Leo Yan's avatar Leo Yan Committed by Greg Kroah-Hartman

coresight: tmc: Refactor loops in etb dump

In ETB dump function tmc_etb_dump_hw() it has nested loops.  The second
level loop is to iterate index in the range [0 .. drvdata->memwidth);
but the index isn't really used in the code, thus the second level
loop is useless.

This patch is to remove the second level loop; the refactor also reduces
indentation and we can use 'break' to replace 'goto' tag.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b860801e
...@@ -38,23 +38,20 @@ static void tmc_etb_dump_hw(struct tmc_drvdata *drvdata) ...@@ -38,23 +38,20 @@ static void tmc_etb_dump_hw(struct tmc_drvdata *drvdata)
{ {
char *bufp; char *bufp;
u32 read_data, lost; u32 read_data, lost;
int i;
/* Check if the buffer wrapped around. */ /* Check if the buffer wrapped around. */
lost = readl_relaxed(drvdata->base + TMC_STS) & TMC_STS_FULL; lost = readl_relaxed(drvdata->base + TMC_STS) & TMC_STS_FULL;
bufp = drvdata->buf; bufp = drvdata->buf;
drvdata->len = 0; drvdata->len = 0;
while (1) { while (1) {
for (i = 0; i < drvdata->memwidth; i++) {
read_data = readl_relaxed(drvdata->base + TMC_RRD); read_data = readl_relaxed(drvdata->base + TMC_RRD);
if (read_data == 0xFFFFFFFF) if (read_data == 0xFFFFFFFF)
goto done; break;
memcpy(bufp, &read_data, 4); memcpy(bufp, &read_data, 4);
bufp += 4; bufp += 4;
drvdata->len += 4; drvdata->len += 4;
} }
}
done:
if (lost) if (lost)
coresight_insert_barrier_packet(drvdata->buf); coresight_insert_barrier_packet(drvdata->buf);
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment