Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3615629imm; Wed, 5 Sep 2018 03:10:43 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdam+O/gZAeZ51YnSAtsChQdmRTzpYgzzB29D291VIs0nW4HbU1/m0tUdck6sqnEWtBl6d6m X-Received: by 2002:a17:902:8506:: with SMTP id bj6-v6mr37466138plb.210.1536142243367; Wed, 05 Sep 2018 03:10:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536142243; cv=none; d=google.com; s=arc-20160816; b=aSgO1I4ITP/VwwZjbESPqc52kHIY5NmY83U3gDEWMy8fzFR65qrT//0mMyV2a6VcKI Dtb/4cTGw8J8zknXAlM+/D3mdpGQU3k/6CiT+hOwqARpflxlyAPxIV/0bqztc70K9gxr hMr2ffBQFxNXY/2Ch2uaTjJfJY6U6zMLoanrtAQCGsbY4nWAYKqXtEAF3HS70KkuR0ZI n/1WJlJQxyxJF2thNvptxlD36ydnAViOFsedFtsJYDQtm55fMPQqo7vBYOQ1GOnrf+ho kOTWDPKSkFBkr40Lkal47tb2a/IW8wEnkp+hfOZPZAzAtZ7+Tm2U0Yz6BQAXnMfLW5wi tP6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=D4UX4I+iWIOl3BO9AbpXuaPHeGc3l7Q0z9qksRl/Q3M=; b=q9mBHak8utiPdVRXuYlmXMV6zw7O+3Q83CcRJmp1nzxn7uM4nRhdOJm4KX0wJYMedc N/ssFZLtyArbJVcy8APJAUme51mcKd02YHf/6M0Fpn4QCEEDiDCvPkAIjiuhXYDZHVBp YEnZujYDgjkGcwEk5q/RhF7YPdMRo4G47UWphu2tK8lAyIKX5KvgmQT0vK+S+WIkqt1o v5FFwz1Qcf/ec/adh8U1SLLPkVgPUfL0brEhkosFQiuFhjGcKgILQGs90oci3FonLhtU rnUkIBoKYJqwoYZoUBP5oXk4XeZ411a3TfKuYS9ki7UrhJ0bAJkasJ95CgK76/zZZhjV v+tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N+Pu+ww1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i12-v6si1730498pfj.190.2018.09.05.03.10.27; Wed, 05 Sep 2018 03:10:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N+Pu+ww1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727598AbeIEOiv (ORCPT + 99 others); Wed, 5 Sep 2018 10:38:51 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:40767 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727234AbeIEOiv (ORCPT ); Wed, 5 Sep 2018 10:38:51 -0400 Received: by mail-wm0-f68.google.com with SMTP id 207-v6so7037703wme.5 for ; Wed, 05 Sep 2018 03:09:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=D4UX4I+iWIOl3BO9AbpXuaPHeGc3l7Q0z9qksRl/Q3M=; b=N+Pu+ww1sAawu78T7yChQzRjKkVLnnP2eDRCdUuK7FMvfPQPFiBG2oPcL4ZAlkCMUL ZhnORBCC29+5Yzyt9CR6xz9jI0gRy7CeoYgd2y14fi5QbM876n5TlK3P5Azd35UIuEKZ DQKYcDMvJmOJanBAs/ukx56Z2q/WxWdWXMLPk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=D4UX4I+iWIOl3BO9AbpXuaPHeGc3l7Q0z9qksRl/Q3M=; b=mYNedTZ3jFIWOdqa0uNaiUa+eH6uxXmkPO62rlgORAmzeF+1jakemv5PTemBUMqpj8 PBvy6BZUSpus4qpZ/Cn3OmLV5HaeWu2vlExDSiQVD8fQleV77q1Tlt9PpoHozInwn672 I8X2pP/8fFFLotk02plW8MtVgVV9jOS2wYpGIs7/XgSz6zvmmlgVA0s6PKQqyT0L4nuy l+Lq2ffA2wBI58RP8hPwmzx5oYptTnTn4fvYBvaDQIOFMoiWsQKId1uNDTaxincu1xz8 Kqy4hFvR5FICjbxDDU4gMuvVXZGhwnamWfv7paGVWQIoS5YKWhbci4op2cx9fFnmY4BZ BoIA== X-Gm-Message-State: APzg51BoB+MfxEU4ATUextjB4wHpai+7aQ2Upe+aWXcPQJatOjy6CPMy EYof/Yyd6vuzn3OHdmXrhqKeHA== X-Received: by 2002:a1c:46c4:: with SMTP id t187-v6mr5162358wma.158.1536142159329; Wed, 05 Sep 2018 03:09:19 -0700 (PDT) Received: from localhost.localdomain ([45.76.138.171]) by smtp.gmail.com with ESMTPSA id x16-v6sm2065229wrm.69.2018.09.05.03.09.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Sep 2018 03:09:18 -0700 (PDT) From: Leo Yan To: Mathieu Poirier , Alexander Shishkin , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Coresight ML Cc: Leo Yan Subject: [PATCH] coresight: tmc: Refactor loops in etb dump Date: Wed, 5 Sep 2018 18:09:07 +0800 Message-Id: <1536142147-21323-1-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/coresight-tmc-etf.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index 9c599c9..8b34161 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -34,23 +34,20 @@ static void tmc_etb_dump_hw(struct tmc_drvdata *drvdata) { char *bufp; u32 read_data, lost; - int i; /* Check if the buffer wrapped around. */ lost = readl_relaxed(drvdata->base + TMC_STS) & TMC_STS_FULL; bufp = drvdata->buf; drvdata->len = 0; while (1) { - for (i = 0; i < drvdata->memwidth; i++) { - read_data = readl_relaxed(drvdata->base + TMC_RRD); - if (read_data == 0xFFFFFFFF) - goto done; - memcpy(bufp, &read_data, 4); - bufp += 4; - drvdata->len += 4; - } + read_data = readl_relaxed(drvdata->base + TMC_RRD); + if (read_data == 0xFFFFFFFF) + break; + memcpy(bufp, &read_data, 4); + bufp += 4; + drvdata->len += 4; } -done: + if (lost) coresight_insert_barrier_packet(drvdata->buf); return; -- 2.7.4