From patchwork Thu Sep 20 19:18:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 147146 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp2376524ljw; Thu, 20 Sep 2018 12:19:04 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYfERIX1qtRVCgZY/dlZb0C1zVglBpXERZSYs4+/muHD9m6+d3+mMOr/XVYU/gCUYHScZpB X-Received: by 2002:a63:f002:: with SMTP id k2-v6mr37853616pgh.8.1537471144778; Thu, 20 Sep 2018 12:19:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537471144; cv=none; d=google.com; s=arc-20160816; b=rDRb+sb5c/VC1XGMnGaSigp/pZuv0+eux1dFv55aYiZwYrXhwVkheHQP19+8SkdRLc ADtUlI+qqTs0gL5g7nVzD6J5zl8zOJfepq21rsHfUPMBvtO0ApOPfo/t3/gPHAZ3AhgA +TnEfC1QFNMfbLivy42XvLN0pndIr/+sQjnXHq5BOx6mUBXufzUstjir6vQ9MAC5KAml Jgxzh27swMJ8tcSHAadyx1QyBfEVUa3l+hGAQmgYjwrtpfPHUFPU0Fr+EqloCzKQyHHk 5UrRfaMI21nHP04yhYeRNOCVACr3dXHAzu37tbrxFS+Soz3lw4ISVyroyfxr7qNQozlh Nkyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=vUlaXOV4lrMht0i3G1NCeaTNFl9Rgz+PCtRI8r+MSMM=; b=CXs8YTKwhUuJF1bIjlg/PNIBRR3aCUkV4iAkFe/0alDt3lKvIdEJx8YmNcO1kft2SH 7LNHVbU3iboxShDjp7UigC7BuaKMZ9RfT7TxXgBQ6/pvLuBESzg8GeCo49hV80rbsjRC JedNT48B6prMizrG06/fWxOjcWNGJRE5enxJlgQhwqHEqduRMLBa3iGp9jc6w3RZu/kx WgbICX+tuZMOfzvsirwWSDCJzuM9ql32pKre3QIS206ozv+F952DgMVPxmtXk7Cehm3O okmRbOlNhc7ZLtPZggRaIcGRmrAqX5n4wH5RtQU9e6mccB0bGwkcu7UmRDeN4FqBjVCU BjXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="JpZ/3Ow6"; 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 b2-v6si24596827pgk.491.2018.09.20.12.19.04; Thu, 20 Sep 2018 12:19:04 -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="JpZ/3Ow6"; 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 S2388978AbeIUBEB (ORCPT + 32 others); Thu, 20 Sep 2018 21:04:01 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:36720 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388926AbeIUBEA (ORCPT ); Thu, 20 Sep 2018 21:04:00 -0400 Received: by mail-pl1-f195.google.com with SMTP id p5-v6so4798604plk.3 for ; Thu, 20 Sep 2018 12:19:01 -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:in-reply-to:references; bh=vUlaXOV4lrMht0i3G1NCeaTNFl9Rgz+PCtRI8r+MSMM=; b=JpZ/3Ow6nsnaluMufdjD2+VP+5pZGOPE4exkPo9ksN6zmGX5TerxyNTomm2ReFWAI7 ytIZBKwIDLnwUf9mJ0oB01E+ceM+uqFJuDpgD0LbWDS4s5ydxJNDHKdfZIO35GiDqsfE EXhvZDdiuvW1KqVWbMODEVCgjVYa4+uSfwEns= 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:in-reply-to :references; bh=vUlaXOV4lrMht0i3G1NCeaTNFl9Rgz+PCtRI8r+MSMM=; b=NTGizcLfbF55f4NHSofNEq3dfrUt6nIXZ/K0374ISEbY+6SlcHaD4RtHKXtEWh5QRY CgZInjwVbYdX8xN/1N6kgw/XLp1xl5pIcpBvhwPOkCWMwSPXTIFjGklpzq5JypOfjNry QIHq8WXZDtkiBEuyXwSfNStcdFPBznmI06GP1bfzDd6POgbuyQGQyg8Uj9WM3it8H2Xd ktgeG5AMuNu06oKepFl1R47jvQrpVbxktK9qJI/VAaLk39kzHv3q8X5Wxb7ROTF2Ucii iBDXFA0G4X2iaOVMfBOB3G4gHUpLzK8Od+WijDjKhPpt5f+DMRrlBcqf3wMVZFiyhLIZ p4wg== X-Gm-Message-State: APzg51DMqEKpzy0tfS1aCoFOfNCv14jiUVFWAy/eWyfyC8thbnangZEk ybgdoYQ6pgSscATrZxITxZ3cbQ== X-Received: by 2002:a17:902:758b:: with SMTP id j11-v6mr40823254pll.29.1537471141573; Thu, 20 Sep 2018 12:19:01 -0700 (PDT) Received: from localhost.localdomain ([209.121.128.187]) by smtp.gmail.com with ESMTPSA id k13-v6sm4424443pgf.37.2018.09.20.12.19.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Sep 2018 12:19:00 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 26/44] coresight: tmc: Refactor loops in etb dump Date: Thu, 20 Sep 2018 13:18:01 -0600 Message-Id: <1537471099-19781-27-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537471099-19781-1-git-send-email-mathieu.poirier@linaro.org> References: <1537471099-19781-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leo Yan 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 Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-tmc-etf.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index 4156c95ce1bb..4bf3bfd7c078 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -38,23 +38,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;