Source
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* sysfs.c sysfs ABI access functions for TMON program
*
* Copyright (C) 2013 Intel Corporation. All rights reserved.
*
* Author: Jacob Pan <jacob.jun.pan@linux.intel.com>
*/
struct tmon_platform_data ptdata;
const char *trip_type_name[] = {
"critical",
"hot",
"passive",
"active",
};
int sysfs_set_ulong(char *path, char *filename, unsigned long val)
{
FILE *fd;
int ret = -1;
char filepath[256];
snprintf(filepath, 256, "%s/%s", path, filename);
fd = fopen(filepath, "w");
if (!fd) {
syslog(LOG_ERR, "Err: open %s: %s\n", __func__, filepath);
return ret;
}
ret = fprintf(fd, "%lu", val);
fclose(fd);
return 0;
}
/* history of thermal data, used for control algo */
struct thermal_data_record trec[NR_THERMAL_RECORDS];
int cur_thermal_record; /* index to the trec array */
static int sysfs_get_ulong(char *path, char *filename, unsigned long *p_ulong)
{
FILE *fd;
int ret = -1;
char filepath[256];
snprintf(filepath, 256, "%s/%s", path, filename);