Skip to content

Commit

Permalink
cpupower: Add is_valid_path API
Browse files Browse the repository at this point in the history
Add is_valid_path API to check whether the sysfs file is present or not.

Suggested-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Wyes Karny <wyes.karny@amd.com>
Tested-by: Perry Yuan <Perry.Yuan@amd.com>
Acked-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
  • Loading branch information
Wyes Karny authored and Shuah Khan committed Jul 18, 2023
1 parent a1cf97c commit 1ce5ab7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tools/power/cpupower/lib/cpupower.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
#include "cpupower.h"
#include "cpupower_intern.h"

int is_valid_path(const char *path)
{
if (access(path, F_OK) == -1)
return 0;
return 1;
}

unsigned int cpupower_read_sysfs(const char *path, char *buf, size_t buflen)
{
ssize_t numread;
Expand Down
1 change: 1 addition & 0 deletions tools/power/cpupower/lib/cpupower_intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@

#define SYSFS_PATH_MAX 255

int is_valid_path(const char *path);
unsigned int cpupower_read_sysfs(const char *path, char *buf, size_t buflen);
unsigned int cpupower_write_sysfs(const char *path, char *buf, size_t buflen);

0 comments on commit 1ce5ab7

Please sign in to comment.