Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp342529rwj; Thu, 22 Dec 2022 08:23:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXs5qKaWPG5JumMQAAMWeuTPikebDXA+vJ+G7auOf6S7S8tTMRStbLI/oZXVujE/tN9SMld0 X-Received: by 2002:a17:906:555:b0:7c1:47bd:1814 with SMTP id k21-20020a170906055500b007c147bd1814mr5247891eja.63.1671726181840; Thu, 22 Dec 2022 08:23:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671726181; cv=none; d=google.com; s=arc-20160816; b=RVI0BmHbPWmh0fpVtsUH1jYi4eyoBPLgOAD5AroEkXxg9aQeAVTPX+BNYysJduQbIM EunrjGQvaV86PAVPbGm2q9ywuUS1JzpQVMnP9bDS5fzpQSTvy5OUOMUiPS1zLFixRRGo ZSlvd0PA9FzwEGF7JrlqHPQT2lt4uPO8UlM/ujaRsw97vR/waj/PrcSGAZzsicwf8YM3 ViOBTwFM72dPOSqyFMhWY0wuwF2Iw1tRf/HnMFPMJ6baM+uafM3yVAfz3CBcqpdg4Vgz YoAgnRDjBPcsr8FCghrosoIsivv7NCv66HT/cMID8HJI1ZIncjWmtkBUhCCzDI1Oez40 UvCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/8H13aJ0M2pGDx5KItC/HEyEzo9+JzYiRL1t7MmE4y4=; b=dpX0+k5orpDByiHB8bSFYWBNWocjsu/pefZRtUXwF6+2eKdZEM4zhOWrW32GeqkO0T it083ZkTfdurVGH12rBccr5zXr6DTjYiW65wyZ4bgoJrwIIWCY5IxIBmhBurE8UzOvi5 l9hb+/U3XfC0ulbxLnQcOSKH1cKzEo8tzqESTg2V0YPqW13upU5CIWsdP9Sq21/q3gyv A/jpdc6gbx0XaShFcLLdjr1HFFbsRX//jlPA7Mv2HRtkH+22SAwZoAUuJsdIlxl4cMKV 9RYPGWdotaZ7dgC6C5zlMvByLBmeY0wYxkEibssV6X+2ob0qCVrOqxZWSbjQ3wp0V5Y4 Zarg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b23-20020aa7cd17000000b00461c3758704si847375edw.36.2022.12.22.08.22.23; Thu, 22 Dec 2022 08:23:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235195AbiLVQHl (ORCPT + 67 others); Thu, 22 Dec 2022 11:07:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234880AbiLVQHd (ORCPT ); Thu, 22 Dec 2022 11:07:33 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 82B242EFAB; Thu, 22 Dec 2022 08:07:29 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 55E912F4; Thu, 22 Dec 2022 08:08:10 -0800 (PST) Received: from e126815.warwick.arm.com (e126815.arm.com [10.32.32.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 591F33FAFB; Thu, 22 Dec 2022 08:07:26 -0800 (PST) From: James Clark To: linux-perf-users@vger.kernel.org, tanmay@marvell.com Cc: sgoutham@marvell.com, gcherian@marvell.com, lcherian@marvell.com, bbhushan2@marvell.com, James Clark , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/7] perf: Remove remaining duplication of bus/event_source/devices/... Date: Thu, 22 Dec 2022 16:03:23 +0000 Message-Id: <20221222160328.3639989-4-james.clark@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221222160328.3639989-1-james.clark@arm.com> References: <20221222160328.3639989-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the new perf_pmu__pathname_scnprintf() instead. No functional changes. Signed-off-by: James Clark --- tools/perf/util/pmu.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index faaeec1e15aa..15b852b3c401 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -574,8 +574,6 @@ static void pmu_read_sysfs(void) * Uncore PMUs have a "cpumask" file under sysfs. CPU PMUs (e.g. on arm/arm64) * may have a "cpus" file. */ -#define SYS_TEMPLATE_ID "./bus/event_source/devices/%s/identifier" - static struct perf_cpu_map *pmu_cpumask(char *name) { struct perf_cpu_map *cpus; @@ -616,9 +614,9 @@ static char *pmu_id(const char *name) char path[PATH_MAX], *str; size_t len; - snprintf(path, PATH_MAX, SYS_TEMPLATE_ID, name); + perf_pmu__pathname_scnprintf(path, PATH_MAX, name, "identifier"); - if (sysfs__read_str(path, &str, &len) < 0) + if (filename__read_str(path, &str, &len) < 0) return NULL; str[len - 1] = 0; /* remove line feed */ @@ -864,16 +862,11 @@ pmu_find_alias_name(const char *name __maybe_unused) return NULL; } -static int pmu_max_precise(const char *name) +static int pmu_max_precise(struct perf_pmu *pmu) { - char path[PATH_MAX]; int max_precise = -1; - scnprintf(path, PATH_MAX, - "bus/event_source/devices/%s/caps/max_precise", - name); - - sysfs__read_int(path, &max_precise); + perf_pmu__scan_file(pmu, "caps/max_precise", "%d", &max_precise); return max_precise; } @@ -932,7 +925,7 @@ static struct perf_pmu *pmu_lookup(const char *lookup_name) pmu->is_uncore = pmu_is_uncore(name); if (pmu->is_uncore) pmu->id = pmu_id(name); - pmu->max_precise = pmu_max_precise(name); + pmu->max_precise = pmu_max_precise(pmu); pmu_add_cpu_aliases(&aliases, pmu); pmu_add_sys_aliases(&aliases, pmu); -- 2.25.1