[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-d9c5f32240f503481291a6d4e7246ee0a128d76d@git.kernel.org>
Date: Sat, 17 Feb 2018 03:21:00 -0800
From: tip-bot for Jiri Olsa <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: hpa@...or.com, acme@...hat.com, tglx@...utronix.de,
jolsa@...nel.org, dsahern@...il.com,
alexander.shishkin@...ux.intel.com, mingo@...nel.org,
peterz@...radead.org, linux-kernel@...r.kernel.org,
namhyung@...nel.org
Subject: [tip:perf/core] tools lib api fs: Add sysfs__read_xll function
Commit-ID: d9c5f32240f503481291a6d4e7246ee0a128d76d
Gitweb: https://git.kernel.org/tip/d9c5f32240f503481291a6d4e7246ee0a128d76d
Author: Jiri Olsa <jolsa@...nel.org>
AuthorDate: Tue, 6 Feb 2018 19:18:01 +0100
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Fri, 16 Feb 2018 10:09:23 -0300
tools lib api fs: Add sysfs__read_xll function
Adding sysfs__read_xll function to be able to read sysfs files with hex
numbers in, which do not have 0x prefix.
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: David Ahern <dsahern@...il.com>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Link: http://lkml.kernel.org/r/20180206181813.10943-6-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/lib/api/fs/fs.c | 15 +++++++++++++--
tools/lib/api/fs/fs.h | 1 +
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 8b0e4a4..6a12bbf 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -432,7 +432,8 @@ int procfs__read_str(const char *entry, char **buf, size_t *sizep)
return filename__read_str(path, buf, sizep);
}
-int sysfs__read_ull(const char *entry, unsigned long long *value)
+static int sysfs__read_ull_base(const char *entry,
+ unsigned long long *value, int base)
{
char path[PATH_MAX];
const char *sysfs = sysfs__mountpoint();
@@ -442,7 +443,17 @@ int sysfs__read_ull(const char *entry, unsigned long long *value)
snprintf(path, sizeof(path), "%s/%s", sysfs, entry);
- return filename__read_ull(path, value);
+ return filename__read_ull_base(path, value, base);
+}
+
+int sysfs__read_xll(const char *entry, unsigned long long *value)
+{
+ return sysfs__read_ull_base(entry, value, 16);
+}
+
+int sysfs__read_ull(const char *entry, unsigned long long *value)
+{
+ return sysfs__read_ull_base(entry, value, 0);
}
int sysfs__read_int(const char *entry, int *value)
diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
index 8ebee35..92d03b8 100644
--- a/tools/lib/api/fs/fs.h
+++ b/tools/lib/api/fs/fs.h
@@ -40,6 +40,7 @@ int procfs__read_str(const char *entry, char **buf, size_t *sizep);
int sysctl__read_int(const char *sysctl, int *value);
int sysfs__read_int(const char *entry, int *value);
int sysfs__read_ull(const char *entry, unsigned long long *value);
+int sysfs__read_xll(const char *entry, unsigned long long *value);
int sysfs__read_str(const char *entry, char **buf, size_t *sizep);
int sysfs__read_bool(const char *entry, bool *value);
Powered by blists - more mailing lists