From patchwork Wed Feb 15 02:20:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olav Haugan X-Patchwork-Id: 9573229 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3028A6045F for ; Wed, 15 Feb 2017 02:21:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 208F328438 for ; Wed, 15 Feb 2017 02:21:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 155C82844E; Wed, 15 Feb 2017 02:21:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A00DB28438 for ; Wed, 15 Feb 2017 02:21:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=cSbLJFxEvJ1We7/BpYh5hMu7yvU6FGXmPYZ5ApN2H3c=; b=kWwXECyelOD7XuoTTez1Nx8Ray ubtTURm5qSYrYl4GfVZWMB/KNfeDr8+gE0ABhUoV/hP4LkEHBVm3ot1+7EXMflWaTCBOvTZ8DPLV0 8P6fQzc/YuJxD22ARus7rghbkgwA7dXXRtIN9bGXwhKFUh/nAtdB66NmHZ2Nspkaoh8QHqncZRijK 13wAVaT9RcZge+8skASpcdEhL7ZGghJ4daAAIn6gv9o5vojWZutXwlt6XmT7V3ztUs2RD3puXY83u XEN4stGE7ropjC62/f8h7GPvVuzwIq4huLFKiKn08574w8AbLf1BNAiVeBwbLfvg/VKHjbG1z5djc HR/o4oVw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cdpDm-0001A3-Lc; Wed, 15 Feb 2017 02:21:30 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cdpDT-0000sf-MO for linux-arm-kernel@lists.infradead.org; Wed, 15 Feb 2017 02:21:14 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 6E94960D57; Wed, 15 Feb 2017 02:20:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1487125253; bh=X1oiJWjazq/qn+YkdO6cLWWlJk2P4Sb78lHHEpwxAZg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ecoQTYvS/BytgcIqIULEAP4v9wpDPGDUp1q+UotEGi8tJVbhzBxmx7/fspDi+8ULF YnW+miBa/I+FhgdBJDAwgbJ3RePg39xonok1LOw58oG1giF0spT+nLBRJJxcAnbx0H 08HwNhA3SEgLktWivGnsma7wV8S4ShpAPRhoQ7M4= Received: from ohaugan-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: ohaugan@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 621CE609E9; Wed, 15 Feb 2017 02:20:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1487125252; bh=X1oiJWjazq/qn+YkdO6cLWWlJk2P4Sb78lHHEpwxAZg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BlskwwdOuRO7PqGrPKErcFGMX43V7Ufpl5Op9xPhXCh3zV2P2rb3xaYCY/JifbPrb cGHDa9sD9CbZRYszxqDfjpH2FWt95l2bU1fPrJPSdbSjvL9XVdJ7gQm7wD0HUWoVoS lzMoxHSg3qFlWxQveuE4PebA6fAkMkFnLrMFiofk= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 621CE609E9 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=ohaugan@codeaurora.org From: Olav Haugan To: mathieu.poirier@linaro.org Subject: [PATCH 2/2] coresight: etm3x: Correctly output counter values in sysfs node Date: Tue, 14 Feb 2017 18:20:29 -0800 Message-Id: <20170215022029.21744-3-ohaugan@codeaurora.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170215022029.21744-1-ohaugan@codeaurora.org> References: <20170215022029.21744-1-ohaugan@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170214_182111_959260_ED4AE680 X-CRM114-Status: GOOD ( 11.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Olav Haugan , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP cntr_val_show function does not print the intended information. It is only printing the latest counter value. Fix this. Signed-off-by: Olav Haugan --- drivers/hwtracing/coresight/coresight-etm3x-sysfs.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c index 4cbbd1313331..62acf07d604b 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c @@ -730,19 +730,29 @@ static ssize_t cntr_val_show(struct device *dev, u32 val; struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); struct etm_config *config = &drvdata->config; + int buf_size = PAGE_SIZE; if (!local_read(&drvdata->mode)) { spin_lock(&drvdata->spinlock); - for (i = 0; i < drvdata->nr_cntr; i++) - ret += scnprintf(buf, PAGE_SIZE, "counter %d: %x\n", - i, config->cntr_val[i]); + for (i = 0; i < drvdata->nr_cntr; i++) { + ret += scnprintf(&buf[ret], buf_size, + "counter %d: %x\n", + i, config->cntr_val[i]); + buf_size -= ret; + if (buf_size <= 0) + break; + } spin_unlock(&drvdata->spinlock); return ret; } for (i = 0; i < drvdata->nr_cntr; i++) { val = etm_readl(drvdata, ETMCNTVRn(i)); - ret += scnprintf(buf, PAGE_SIZE, "counter %d: %x\n", i, val); + ret += scnprintf(&buf[ret], buf_size, + "counter %d: %x\n", i, val); + buf_size -= ret; + if (buf_size <= 0) + break; } return ret;