Commit 1ce5ab7c authored by Wyes Karny's avatar Wyes Karny Committed by Shuah Khan
Browse files

cpupower: Add is_valid_path API



Add is_valid_path API to check whether the sysfs file is present or not.

Suggested-by: default avatarGautham R. Shenoy <gautham.shenoy@amd.com>
Reviewed-by: default avatarMario Limonciello <mario.limonciello@amd.com>
Signed-off-by: default avatarWyes Karny <wyes.karny@amd.com>
Tested-by: default avatarPerry Yuan <Perry.Yuan@amd.com>
Acked-by: default avatarHuang Rui <ray.huang@amd.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent a1cf97c2
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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;
+1 −0
Original line number Diff line number Diff line
@@ -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);