src/dpdk/lib/librte_power/power_acpi_cpufreq.c
static int
power_init_for_setting_freq(struct rte_power_info *pi)
{
	FILE *f;
	char fullpath[PATH_MAX];
	char buf[BUFSIZ];
	uint32_t i, freq;
	char *s;

	snprintf(fullpath, sizeof(fullpath), POWER_SYSFILE_SETSPEED,
			pi->lcore_id);
	f = fopen(fullpath, "rw+");
	FOPEN_OR_ERR_RET(f, -1);

	s = fgets(buf, sizeof(buf), f);
	FOPS_OR_NULL_GOTO(s, out);

	freq = strtoul(buf, NULL, POWER_CONVERT_TO_DECIMAL);
	for (i = 0; i < pi->nb_freqs; i++) {
		if (freq == pi->freqs[i]) {
			pi->curr_idx = i;
			pi->f = f;
			return 0;
		}
	}

out:
	fclose(f);

	return -1;
}
/**
 * It is to fopen the sys file for the future setting the lcore frequency.
 */
It is to fopen the sys file for the future setting the lcore frequency.
It is to fopen the sys file for the future setting the lcore frequency .
static int
power_init_for_setting_freq(struct rte_power_info *pi)
{
	FILE *f;
	char fullpath[PATH_MAX];
	char buf[BUFSIZ];
	uint32_t i, freq;
	char *s;
	snprintf(fullpath, sizeof(fullpath), POWER_SYSFILE_SETSPEED,
			pi->lcore_id);
	f = fopen(fullpath, "rw+");
	FOPEN_OR_ERR_RET(f, -1);
	s = fgets(buf, sizeof(buf), f);
	FOPS_OR_NULL_GOTO(s, out);
	freq = strtoul(buf, NULL, POWER_CONVERT_TO_DECIMAL);
	for (i = 0; i < pi->nb_freqs; i++) {
		if (freq == pi->freqs[i]) {
			pi->curr_idx = i;
			pi->f = f;
			return 0;
		}
	}
out:
	fclose(f);
	return -1;
}
static int power_init_for_setting_freq ( struct rte_power_info * pi ) { FILE * f ; char fullpath [ PATH_MAX ] ; char buf [ BUFSIZ ] ; uint32_t i , freq ; char * s ; snprintf ( fullpath , sizeof ( fullpath ) , POWER_SYSFILE_SETSPEED , pi -> lcore_id ) ; f = fopen ( fullpath , " " ) ; FOPEN_OR_ERR_RET ( f , -1 ) ; s = fgets ( buf , sizeof ( buf ) , f ) ; FOPS_OR_NULL_GOTO ( s , out ) ; freq = strtoul ( buf , NULL , POWER_CONVERT_TO_DECIMAL ) ; for ( i = 0 ; i < pi -> nb_freqs ; i ++ ) { if ( freq == pi -> freqs [ i ] ) { pi -> curr_idx = i ; pi -> f = f ; return 0 ; } } out : fclose ( f ) ; return -1 ; }
It is to fopen the sys file for the future setting the lcore frequency.
It is to fopen the sys file for the future setting the lcore frequency .