modules/batt_health/sys.c
static bool sys_param_int_set(const char *path, int value)
{
	bool is_success = false;
	ssize_t r;
	char buffer[32];
	int fd = open(path, O_WRONLY);
	if (fd < 0)
		ALOGE("Failed to open %s for writing %d, errno = %d (%s)",
			path, value, errno, strerror(errno));
	else {
		snprintf(buffer, sizeof(buffer) - 1, "%d", value);
		buffer[sizeof(buffer) - 1] = '\0';

		r = write(fd, buffer, strlen(buffer));
		if (r != (ssize_t) strlen(buffer))
			ALOGE("Failed to write %s to file %s, r = %lu, errno = %d (%s)",
				buffer, path, r, errno, strerror(errno));
		else {
			is_success = true;
			ALOGV("Set %s = %s", path, buffer);
		}
		close(fd);
	}

	return(is_success);
}
/* Writes an integer value to a sysfs file */
Writes an integer value to a sysfs file
Writes an integer value to a sysfs file
static bool sys_param_int_set(const char *path, int value)
{
	bool is_success = false;
	ssize_t r;
	char buffer[32];
	int fd = open(path, O_WRONLY);
	if (fd < 0)
		ALOGE("Failed to open %s for writing %d, errno = %d (%s)",
			path, value, errno, strerror(errno));
	else {
		snprintf(buffer, sizeof(buffer) - 1, "%d", value);
		buffer[sizeof(buffer) - 1] = '\0';
		r = write(fd, buffer, strlen(buffer));
		if (r != (ssize_t) strlen(buffer))
			ALOGE("Failed to write %s to file %s, r = %lu, errno = %d (%s)",
				buffer, path, r, errno, strerror(errno));
		else {
			is_success = true;
			ALOGV("Set %s = %s", path, buffer);
		}
		close(fd);
	}
	return(is_success);
}
static bool sys_param_int_set ( const char * path , int value ) { bool is_success = false ; ssize_t r ; char buffer [ 32 ] ; int fd = open ( path , O_WRONLY ) ; if ( fd < 0 ) ALOGE ( " " , path , value , errno , strerror ( errno ) ) ; else { snprintf ( buffer , sizeof ( buffer ) - 1 , " " , value ) ; buffer [ sizeof ( buffer ) - 1 ] = ' \0 ' ; r = write ( fd , buffer , strlen ( buffer ) ) ; if ( r != ( ssize_t ) strlen ( buffer ) ) ALOGE ( " " , buffer , path , r , errno , strerror ( errno ) ) ; else { is_success = true ; ALOGV ( " " , path , buffer ) ; } close ( fd ) ; } return ( is_success ) ; }
Writes an integer value to a sysfs file
Writes an integer value to a sysfs file