perf fs: Rename NAME_find_mountpoint() to NAME__mountpoint()

Shorten it, "finding" it is an implementation detail, what callers want
is the pathname, not to ask for it to _always_ do the lookup.

And the existing implementation already caches it, i.e. it doesn't
"finds" it on every call.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-r24wa4bvtccg7mnkessrbbdj@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 4299a549
...@@ -1456,7 +1456,7 @@ static int test_pmu(void) ...@@ -1456,7 +1456,7 @@ static int test_pmu(void)
int ret; int ret;
snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/", snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/",
sysfs_find_mountpoint()); sysfs__mountpoint());
ret = stat(path, &st); ret = stat(path, &st);
if (ret) if (ret)
...@@ -1473,7 +1473,7 @@ static int test_pmu_events(void) ...@@ -1473,7 +1473,7 @@ static int test_pmu_events(void)
int ret; int ret;
snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/", snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/",
sysfs_find_mountpoint()); sysfs__mountpoint());
ret = stat(path, &st); ret = stat(path, &st);
if (ret) { if (ret) {
......
...@@ -216,7 +216,7 @@ int cpu_map__get_socket(struct cpu_map *map, int idx) ...@@ -216,7 +216,7 @@ int cpu_map__get_socket(struct cpu_map *map, int idx)
cpu = map->map[idx]; cpu = map->map[idx];
mnt = sysfs_find_mountpoint(); mnt = sysfs__mountpoint();
if (!mnt) if (!mnt)
return -1; return -1;
...@@ -279,7 +279,7 @@ int cpu_map__get_core(struct cpu_map *map, int idx) ...@@ -279,7 +279,7 @@ int cpu_map__get_core(struct cpu_map *map, int idx)
cpu = map->map[idx]; cpu = map->map[idx];
mnt = sysfs_find_mountpoint(); mnt = sysfs__mountpoint();
if (!mnt) if (!mnt)
return -1; return -1;
......
...@@ -88,7 +88,7 @@ static const char *fs__get_mountpoint(struct fs *fs) ...@@ -88,7 +88,7 @@ static const char *fs__get_mountpoint(struct fs *fs)
return fs__read_mounts(fs) ? fs->path : NULL; return fs__read_mounts(fs) ? fs->path : NULL;
} }
static const char *fs__find_mountpoint(int idx) static const char *fs__mountpoint(int idx)
{ {
struct fs *fs = &fs__entries[idx]; struct fs *fs = &fs__entries[idx];
...@@ -98,10 +98,10 @@ static const char *fs__find_mountpoint(int idx) ...@@ -98,10 +98,10 @@ static const char *fs__find_mountpoint(int idx)
return fs__get_mountpoint(fs); return fs__get_mountpoint(fs);
} }
#define FIND_MOUNTPOINT(name, idx) \ #define FS__MOUNTPOINT(name, idx) \
const char *name##_find_mountpoint(void) \ const char *name##__mountpoint(void) \
{ \ { \
return fs__find_mountpoint(idx); \ return fs__mountpoint(idx); \
} }
FIND_MOUNTPOINT(sysfs, FS__SYSFS); FS__MOUNTPOINT(sysfs, FS__SYSFS);
#ifndef __PERF_FS #ifndef __PERF_FS
#define __PERF_FS #define __PERF_FS
const char *sysfs_find_mountpoint(void); const char *sysfs__mountpoint(void);
#endif /* __PERF_FS */ #endif /* __PERF_FS */
...@@ -77,9 +77,8 @@ static int pmu_format(const char *name, struct list_head *format) ...@@ -77,9 +77,8 @@ static int pmu_format(const char *name, struct list_head *format)
{ {
struct stat st; struct stat st;
char path[PATH_MAX]; char path[PATH_MAX];
const char *sysfs; const char *sysfs = sysfs__mountpoint();
sysfs = sysfs_find_mountpoint();
if (!sysfs) if (!sysfs)
return -1; return -1;
...@@ -166,9 +165,8 @@ static int pmu_aliases(const char *name, struct list_head *head) ...@@ -166,9 +165,8 @@ static int pmu_aliases(const char *name, struct list_head *head)
{ {
struct stat st; struct stat st;
char path[PATH_MAX]; char path[PATH_MAX];
const char *sysfs; const char *sysfs = sysfs__mountpoint();
sysfs = sysfs_find_mountpoint();
if (!sysfs) if (!sysfs)
return -1; return -1;
...@@ -212,11 +210,10 @@ static int pmu_type(const char *name, __u32 *type) ...@@ -212,11 +210,10 @@ static int pmu_type(const char *name, __u32 *type)
{ {
struct stat st; struct stat st;
char path[PATH_MAX]; char path[PATH_MAX];
const char *sysfs;
FILE *file; FILE *file;
int ret = 0; int ret = 0;
const char *sysfs = sysfs__mountpoint();
sysfs = sysfs_find_mountpoint();
if (!sysfs) if (!sysfs)
return -1; return -1;
...@@ -241,11 +238,10 @@ static int pmu_type(const char *name, __u32 *type) ...@@ -241,11 +238,10 @@ static int pmu_type(const char *name, __u32 *type)
static void pmu_read_sysfs(void) static void pmu_read_sysfs(void)
{ {
char path[PATH_MAX]; char path[PATH_MAX];
const char *sysfs;
DIR *dir; DIR *dir;
struct dirent *dent; struct dirent *dent;
const char *sysfs = sysfs__mountpoint();
sysfs = sysfs_find_mountpoint();
if (!sysfs) if (!sysfs)
return; return;
...@@ -270,11 +266,10 @@ static struct cpu_map *pmu_cpumask(const char *name) ...@@ -270,11 +266,10 @@ static struct cpu_map *pmu_cpumask(const char *name)
{ {
struct stat st; struct stat st;
char path[PATH_MAX]; char path[PATH_MAX];
const char *sysfs;
FILE *file; FILE *file;
struct cpu_map *cpus; struct cpu_map *cpus;
const char *sysfs = sysfs__mountpoint();
sysfs = sysfs_find_mountpoint();
if (!sysfs) if (!sysfs)
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment