From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23A27C282CA for ; Tue, 12 Feb 2019 17:17:45 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E699F222C1 for ; Tue, 12 Feb 2019 17:17:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ksUpbFEM"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="GGgVP5XA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E699F222C1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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=xXWjS/WZ6xXBO4uQLOAVAfgOolLRlwfwKbBPwsN4Y80=; b=ksUpbFEMTnN3+/0J1p+0cXDlDY UUatNYqJBkWXwFgnoJ0YZIBo5GBsuHXufE+lUSrkyHoPPcSJrLUpT/fqwoVuPZcMT51a1NfyK82OF Ihdd3ArP1MXioWqkMhDkP0VnZEdHeLKRPIrB7SjulJ1QpL1q4QU6LCmILUd0madHXkvX3tzO3TZEo JGX5ZcGcY124AYqvCePu8szVNdjz2Hs0VF3byKLp5SvsMNzG9fOtiJZoIJCcoC09lCaJR6doKeSDs 0LkT5AW1dS3qdBqYNepYvLTWneEbx/q9Q9W2OMSIjR+LRgoPcMWUB8y4DjawV5UdKr7ZSrT1ToNrh Z5pakhjA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtbgd-0002LS-Dq; Tue, 12 Feb 2019 17:17:35 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtbfV-0001Ia-HH for linux-arm-kernel@lists.infradead.org; Tue, 12 Feb 2019 17:16:30 +0000 Received: by mail-pf1-x443.google.com with SMTP id c123so1611010pfb.0 for ; Tue, 12 Feb 2019 09:16:25 -0800 (PST) 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=d25EPOQ1/eL3uzzHkP0zLvCcnfX2yAd0t0DIGDfrgSI=; b=GGgVP5XANqmy0QCTFX14LkYAMfmmOgC+GSwRJVdBwgg6qA4U2J3nPYCMpJGBUMLBVO AZjG/MNQ8hDEjiDqMc7REehUZAAgXjHgdwvn4fXZQBpb9MdarapyjHATTQXqIs06Nsd1 JVUaQwcXhP4Pv2xCAH2lxRHrSk8Y4Zz11CLrPNGi0OlsW+5NPA0p+g2vmRqCG6N+qZma YPwbgX4eLoebY3fTdh+IAgE/6DPaR4VghWMZQQGyfFuRAtxiz6+FTYVtN8V3qkjN3WXT yrtFDXN/BLx2dMOn7AmYBNMTUtdUTr3iaOmhWqKyLCZdyJSnWFKfNRhIvjFRC6om8a9c 7igw== 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=d25EPOQ1/eL3uzzHkP0zLvCcnfX2yAd0t0DIGDfrgSI=; b=DA56RIQAxjSMoZZVyt1jjOxCJFXOOmjrgUiNQgiELB1AAhoA39a8a/xRTf714CwjrI RfwVWAkY166/soqVzumhTx6C6oxfuEc37tDaf6PZKILuxakP9w44izxG8rdLZzKjfihk ef/owKwqPK2+s71/ohb/Vaq5+LkacZT0icUoD8wOMK1FaV4U0ofT5hiL1xXgfK9Ry4ZR WrCGgRXsaH8TEqEEgYUMQBSJZJec4aROn+1xrcdieL88ud0R/QAb+t2XVVNU1V1zwqJ5 EsDqOIj5HqDzl03X4vG0uHnE5MYOx/TaIrPS2TZuaO72sKKX0wXwoyfyZbnpX2zkk3rz uH/g== X-Gm-Message-State: AHQUAuaC5m46ttRANPKdVZCaSE7GndEFauhW52Nl54M0LXrqo9iEaKT7 uFYYaGyBtjusebOI3ibZABwIKw== X-Google-Smtp-Source: AHgI3IZJVTS6IpcnyXXlDDqH6NHHCMl2J6tP6lo1Wl2h/tBadSM4FIAOed+uLa5bWjcZ4dbtK5AMMQ== X-Received: by 2002:aa7:808a:: with SMTP id v10mr5037856pff.8.1549991784951; Tue, 12 Feb 2019 09:16:24 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id z4sm8659231pgu.10.2019.02.12.09.16.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 09:16:24 -0800 (PST) From: Mathieu Poirier To: acme@kernel.org Subject: [PATCH 04/13] perf tools: Introducing function cs_etm_decoder__init_dparams() Date: Tue, 12 Feb 2019 10:16:09 -0700 Message-Id: <20190212171618.25355-5-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190212171618.25355-1-mathieu.poirier@linaro.org> References: <20190212171618.25355-1-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190212_091625_926038_CF1EFCF2 X-CRM114-Status: GOOD ( 13.27 ) 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: suzuki.poulose@arm.com, peterz@infradead.org, linux-kernel@vger.kernel.org, mingo@redhat.com, leo.yan@linaro.org, jolsa@redhat.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Introducing function cs_etm_decoder__init_dparams() to avoid repeating code at two different places. Signed-off-by: Mathieu Poirier --- .../perf/util/cs-etm-decoder/cs-etm-decoder.h | 3 +- tools/perf/util/cs-etm.c | 41 +++++++++++++------ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h index 7e6a8850be4a..663309486784 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.h @@ -105,9 +105,10 @@ enum { CS_ETM_PROTO_PTM, }; -enum { +enum cs_etm_decoder_operation { CS_ETM_OPERATION_PRINT = 1, CS_ETM_OPERATION_DECODE, + CS_ETM_OPERATION_MAX, }; int cs_etm_decoder__process_data_block(struct cs_etm_decoder *decoder, diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index f396fee9bb95..3011c6cae531 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -136,6 +136,28 @@ static void cs_etm__packet_dump(const char *pkt_string) fflush(stdout); } +static int cs_etm__init_decoder_params(struct cs_etm_decoder_params *d_params, + struct cs_etm_queue *etmq, + enum cs_etm_decoder_operation mode) +{ + int ret = -EINVAL; + + if (!(mode < CS_ETM_OPERATION_MAX)) + goto out; + + d_params->packet_printer = cs_etm__packet_dump; + d_params->operation = mode; + d_params->data = etmq; + d_params->formatted = true; + d_params->fsyncs = false; + d_params->hsyncs = false; + d_params->frame_aligned = true; + + ret = 0; +out: + return ret; +} + static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, struct auxtrace_buffer *buffer) { @@ -182,12 +204,9 @@ static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, } /* Set decoder parameters to simply print the trace packets */ - d_params.packet_printer = cs_etm__packet_dump; - d_params.operation = CS_ETM_OPERATION_PRINT; - d_params.formatted = true; - d_params.fsyncs = false; - d_params.hsyncs = false; - d_params.frame_aligned = true; + if (cs_etm__init_decoder_params(&d_params, NULL, + CS_ETM_OPERATION_PRINT)) + return; decoder = cs_etm_decoder__new(etm->num_cpu, &d_params, t_params); @@ -436,13 +455,9 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, } /* Set decoder parameters to simply print the trace packets */ - d_params.packet_printer = cs_etm__packet_dump; - d_params.operation = CS_ETM_OPERATION_DECODE; - d_params.formatted = true; - d_params.fsyncs = false; - d_params.hsyncs = false; - d_params.frame_aligned = true; - d_params.data = etmq; + if (cs_etm__init_decoder_params(&d_params, etmq, + CS_ETM_OPERATION_DECODE)) + goto out_free; etmq->decoder = cs_etm_decoder__new(etm->num_cpu, &d_params, t_params); -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel