int read_sysfs_int(const char *sys_pfx, const char *node) { int fd, val; fd = open_sysfs(sys_pfx, node, O_RDONLY); val = read_sysfs_int_fd(fd, sys_pfx, node); close(fd); return val; }
int read_sysfs_int(const char *sys_pfx, const char *postfix, const char *node) { extern int errno; int fd, val; fd = open_sysfs(sys_pfx, postfix, node, O_RDONLY); val = read_sysfs_int_fd(fd, sys_pfx, postfix, node); close(fd); return val; }
void write_sysfs_val(const char *sys_pfx, const char *node, int val) { int fd, len; char buf[SYSFS_MAX_INT]; fd = open_sysfs(sys_pfx, node, O_RDWR); len = snprintf(buf, sizeof(buf), "%d", val); if (write(fd, buf, len) < 0) { fprintf(stderr, "unable to write to %s%s %s\n", sys_pfx, node, strerror(errno)); close(fd); abort(); } close(fd); }