cpumf: Convert S390_CPUMF_XXX to util_path_sysfs()

Use util_path_sysfs() to form a fully qualified sysfs file name
for files S390_CPUMF_CF, S390_CPUMF_CFDIAG, S390_CPUMF_SF,
S390_SYSFS_PAI_CRYPTO and S390_SYSFS_PAI_EXT.
No functional change.

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Thomas Richter
2025-04-07 15:23:19 +02:00
committed by Jan Höppner
parent 8c1ffd8989
commit fed79474e4
4 changed files with 23 additions and 21 deletions
+3 -6
View File
@@ -1,4 +1,4 @@
/* Copyright IBM Corp. 2022
/* Copyright IBM Corp. 2022, 2025
*
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
@@ -18,16 +18,13 @@
int libcpumf_pmutype(const char *dirname)
{
int ret = -1;
FILE *file;
char *fn;
int ret;
ret = asprintf(&fn, "%s/type", dirname);
if (ret == -1) /* No memory, errno set */
return ret;
fn = util_path_sysfs("%s/type", dirname);
file = fopen(fn, "r");
free(fn);
ret = -1; /* Errno set on file open error */
if (file) {
/* Read out a single number from that file */
if (fscanf(file, "%u", &ret) != 1)
+14 -9
View File
@@ -144,23 +144,28 @@ bool libcpumf_sfb_info(unsigned long *min, unsigned long *max)
return rc;
}
static bool libcpumf_have_pai_sysfs(char *p)
{
char *path;
bool ret;
path = util_path_sysfs(p);
ret = util_path_exists(path);
free(path);
return ret;
}
bool libcpumf_have_pai_crypto(void)
{
struct stat statbuf;
return (stat(S390_SYSFS_PAI_CRYPTO, &statbuf) == -1) ? false : true;
return libcpumf_have_pai_sysfs(S390_SYSFS_PAI_CRYPTO);
}
bool libcpumf_have_pai_ext(void)
{
struct stat statbuf;
return (stat(S390_SYSFS_PAI_EXT, &statbuf) == -1) ? false : true;
return libcpumf_have_pai_sysfs(S390_SYSFS_PAI_EXT);
}
bool libcpumf_have_pai_nnpa(void)
{
struct stat statbuf;
return (stat(S390_SYSFS_PAI_NNPA, &statbuf) == -1) ? false : true;
return libcpumf_have_pai_sysfs(S390_SYSFS_PAI_NNPA);
}