当前位置: 首页>>代码示例>>C++>>正文


C++ CHECK_NULL_ARG函数代码示例

本文整理汇总了C++中CHECK_NULL_ARG函数的典型用法代码示例。如果您正苦于以下问题:C++ CHECK_NULL_ARG函数的具体用法?C++ CHECK_NULL_ARG怎么用?C++ CHECK_NULL_ARG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CHECK_NULL_ARG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: opp_set

/* ------------------------------------------------------------------------*//**
 * @FUNCTION		opp_set
 * @BRIEF		change OPP of a given voltage domain.
 * @RETURNS		0 in case of success
 *			OMAPCONF_ERR_ARG
 *			OMAPCONF_ERR_CPU
 *			OMAPCONF_ERR_NOT_AVAILABLE
 * @param[in]		voltdm: voltage domain name (as defined in voltdm.h)
 * @param[in]		opp: name of OPP to be set (as defined in opp.h)
 * @DESCRIPTION		change OPP of a given voltage domain.
 *//*------------------------------------------------------------------------ */
int opp_set(const char *voltdm, const char *opp)
{
	int vdd_id, opp_id;

	CHECK_NULL_ARG(voltdm, OMAPCONF_ERR_ARG);
	CHECK_NULL_ARG(opp, OMAPCONF_ERR_ARG);

	opp_init();

	vdd_id = voltdm_s2id(voltdm);
	if (vdd_id < 0)
		return OMAPCONF_ERR_ARG;

	opp_id = opp_s2id(opp);
	if (opp_id < 0)
		return OMAPCONF_ERR_ARG;

	if (cpu_is_omap44xx()) {
		return opp44xx_set((voltdm44xx_id) vdd_id, (opp44xx_id) opp_id);
	} else if (cpu_is_omap54xx()) {
		return opp54xx_set((voltdm54xx_id) vdd_id, (opp54xx_id) opp_id);
	} else {
		fprintf(stderr,
			"omapconf: %s(): cpu not supported!!!\n", __func__);
		return OMAPCONF_ERR_CPU;
	}
}
开发者ID:bcousson,项目名称:omapconf,代码行数:38,代码来源:opp.c

示例2: main_i2c_read

/* ------------------------------------------------------------------------*//**
 * @FUNCTION		main_i2c_read
 * @BRIEF		read given data from given address of given device of
 *			given I2C bus
 * @RETURNS		0 in case of success
 *			OMAPCONF_ERR_ARG
 *			OMAPCONF_ERR_NOT_AVAILABLE
 *			OMAPCONF_ERR_REG_ACCESS
 * @param[in]		argc: shell input argument number
 *			argc must be 5
 * @param[in]		argv: shell input argument(s)
 *			argv[2] = i2cbus: I2C bus number
 *			argv[3] = address: I2C device address
 *			argv[4] = daddress: I2C device register address
 * @DESCRIPTION		read given data from given address of given device of
 *			given I2C bus
 *//*------------------------------------------------------------------------ */
static int main_i2c_read(int argc, char *argv[])
{
	unsigned int i2cbus, chip_address, data_address;
	unsigned int data;
	int ret;

	CHECK_NULL_ARG(argv, OMAPCONF_ERR_ARG);

	/* Retrieve arguments */
	if (argc != 5)
		goto main_i2c_read_err;
	ret = sscanf(argv[2], "%u", &i2cbus);
	if (ret != 1)
		goto main_i2c_read_err;
	ret = sscanf(argv[3], "0x%x", &chip_address);
	if (ret != 1)
		goto main_i2c_read_err;
	ret = sscanf(argv[4], "0x%x", &data_address);
	if (ret != 1)
		goto main_i2c_read_err;

	ret = i2cget(i2cbus, chip_address, data_address, &data);
	if (ret == 0)
		printf("0x%02x\n", data);
	return ret;

main_i2c_read_err:
	printf(
		"Usage: omapconf i2c read 'i2cbus' 0x'chip-address' 0x'data-address'\n");
	printf("  'i2cbus' is decimal value.\n");
	printf("  'chip-address' & 'data-address' are hexadecimal values.\n");
	printf("  Warning: prefix '0x' is mandatory.\n");
	return OMAPCONF_ERR_ARG;
}
开发者ID:KunYi,项目名称:omapconf,代码行数:51,代码来源:omapconf.c

示例3: srcfg_read_file_content

/**
 * @brief Reads complete content of a file referenced by the descriptor 'fd' into the memory.
 * Caller is responsible for deallocation of the memory block returned through the output argument 'out'.
 * Returns SR_ERR_OK in case of success, error code otherwise.
 */
static int
srcfg_read_file_content(int fd, char **out)
{
    int rc = SR_ERR_OK;
    size_t size = EXPECTED_MAX_INPUT_FILE_SIZE;
    unsigned cur = 0;
    ssize_t n = 0;
    char *buffer = NULL;

    CHECK_NULL_ARG(out);

    buffer = malloc(size);
    CHECK_NULL_NOMEM_GOTO(buffer, rc, fail);

    do {
        if (size == cur + 1) {
            size <<= 1;
            char *new_buffer = realloc(buffer, size);
            CHECK_NULL_NOMEM_GOTO(new_buffer, rc, fail);
            buffer = new_buffer;
        }
        n = read(fd, buffer + cur, size - cur - 1);
        CHECK_NOT_MINUS1_LOG_GOTO(n, rc, SR_ERR_INTERNAL, fail,
                                  "Read operation failed: %s.", sr_strerror_safe(errno));
        cur += n;
    } while (0 < n);

    buffer[cur] = '\0';
    *out = buffer;
    return rc;

fail:
    free(buffer);
    return rc;
}
开发者ID:eqvinox,项目名称:sysrepo,代码行数:40,代码来源:sysrepocfg.c

示例4: voltdm_s2id

/* ------------------------------------------------------------------------*//**
 * @FUNCTION		voltdm_s2id
 * @BRIEF		convert voltage domain provided as a string
 *			(as defined in voltdm.h) into a plaftorm-specific
 *			voltage domain ID (integer).
 * @RETURNS		plaftorm-specific voltage domain ID (> 0) if success
 *			OMAPCONF_ERR_CPU
 *			OMAPCONF_ERR_ARG
 * @param[in]		voltdm: voltage domain name (as defined in voltdm.h)
 * @DESCRIPTION		convert voltage domain provided as a string
 *			(as defined in voltdm.h) into a plaftorm-specific
 *			voltage domain ID (integer).
 *//*------------------------------------------------------------------------ */
int voltdm_s2id(const char *voltdm)
{
	CHECK_NULL_ARG(voltdm, OMAPCONF_ERR_ARG);

	if (cpu_is_omap44xx()) {
		if (strcmp(voltdm, VDD_WKUP) == 0)
			return (int) OMAP4_LDO_WKUP;
		else if (strcmp(voltdm, VDD_MPU) == 0)
			return (int) OMAP4_VDD_MPU;
		else if (strcmp(voltdm, VDD_IVA) == 0)
			return (int) OMAP4_VDD_IVA;
		else if (strcmp(voltdm, VDD_CORE) == 0)
			return (int) OMAP4_VDD_CORE;
		else
			return OMAPCONF_ERR_ARG;
	} else if (cpu_is_omap54xx()) {
		if (strcmp(voltdm, VDD_WKUP) == 0)
			return (int) VDD54XX_WKUP;
		else if (strcmp(voltdm, VDD_MPU) == 0)
			return (int) VDD54XX_MPU;
		else if (strcmp(voltdm, VDD_MM) == 0)
			return (int) VDD54XX_MM;
		else if (strcmp(voltdm, VDD_CORE) == 0)
			return (int) VDD54XX_CORE;
		else
			return OMAPCONF_ERR_ARG;
	} else {
		fprintf(stderr,
			"omapconf: %s(): cpu not supported!!!\n", __func__);
		return OMAPCONF_ERR_CPU;
	}
}
开发者ID:bcousson,项目名称:omapconf,代码行数:45,代码来源:voltdm.c

示例5: spwrm_get_current

/**
 * @brief           Measure the current consumption of a given spring.
 * @return          current consumption of a given spring (in microamps)
 * warning          'spring' index starts at 1, not 0.
 * @param[in]       spring: selected spring ([1..SPRING_COUNT])
 * @param[out]      uA: selected spring current measurement, in microamps)
 */
int spwrm_get_current(uint8_t spring, int32_t *uA)
{
    int ret;
    uint8_t adc, chan;
    uint32_t spin, uV;

    CHECK_SPRING(spring);
    CHECK_NULL_ARG(uA);

    adc = spwrm_get_adc_device(spring);
    chan = spwrm_get_adc_channel(spring);
    spin = spwrm_get_sign_pin(spring);
    *uA = 0;

    ret = adc_get_data(adc, chan, &uV);
    if (ret) {
        dbg_error("%s(): failed to get %s data! (%d)\n", __func__,
                  spwrm_get_name(spring), ret);
        return ret;
    }
    /* Convert to uV */
    uV = adc_get_uV(uV);
    /* Get data sign */
    if (stm32_gpioread(spin) == 0) {
        dbg_verbose("%s(): pin=0 => sign=-\n", __func__);
        *uA = -((int32_t) max9929f_get_Iload(uV));
    } else {
        dbg_verbose("%s(): pin=1 => sign=+\n", __func__);
        *uA = (int32_t) max9929f_get_Iload(uV);
    }
    dbg_verbose("%s(): measured voltage=%uuV => current=%duA\n",
                __func__, uV, *uA);

    return 0;
}
开发者ID:alexlotw,项目名称:nuttx,代码行数:42,代码来源:up_spring_pm.c

示例6: voltdm_nominal_voltage_get

/* ------------------------------------------------------------------------*//**
 * @FUNCTION		voltdm_nominal_voltage_get
 * @BRIEF		return the nominal voltage supplied to a voltage domain.
 * @RETURNS		nominal voltage in micro-volt (> 0) in case of success
 *			OMAPCONF_ERR_CPU
 *			OMAPCONF_ERR_ARG
 * @param[in]		voltdm: voltage domain name (as defined in voltdm.h)
 * @DESCRIPTION		return the nominal voltage supplied to a voltage domain.
 *			In case SmartReflex AVS Class3 is enabled,
 *			it may differ from the current supplied voltage.
 *//*------------------------------------------------------------------------ */
int voltdm_nominal_voltage_get(const char *voltdm)
{
	int id;
	int uvolt;

	CHECK_NULL_ARG(voltdm, OMAPCONF_ERR_ARG);

	voltdm_init();

	id = voltdm_s2id(voltdm);
	if (id < 0) {
		uvolt = OMAPCONF_ERR_ARG;
	} else if (cpu_is_omap44xx()) {
		uvolt = v2uv(voltdm44xx_nominal_voltage_get(
			(voltdm44xx_id) id));
	} else if (cpu_is_omap54xx()) {
		uvolt = v2uv(voltdm54xx_nominal_voltage_get(
			(voltdm54xx_id) id));
	} else {
		fprintf(stderr,
			"omapconf: %s(): cpu not supported!!!\n", __func__);
		uvolt = OMAPCONF_ERR_CPU;
	}

	dprintf("%s(%s) = %duV\n", __func__, voltdm, uvolt);
	return uvolt;
}
开发者ID:bcousson,项目名称:omapconf,代码行数:38,代码来源:voltdm.c

示例7: dpll_lock_freq_calc

/* ------------------------------------------------------------------------*//**
 * @FUNCTION		dpll_lock_freq_calc
 * @BRIEF		compute DPLL lock frequency (in MHz)
 * @RETURNS		lock frequency in case of success (in MHz)
 *			0.0 in case of error.
 * @param[in]		settings: DPLL settings with fields
 *			regm4xen, fref, MN.M, MN.N INITIALIZED
 * @DESCRIPTION		compute DPLL lock frequency (in MHz)
 *//*------------------------------------------------------------------------ */
double dpll_lock_freq_calc(dpll_settings *settings)
{
	CHECK_NULL_ARG(settings, 0.0);

	if (settings->type == DPLL_TYPE_A) {
		if (settings->regm4xen == 0)
			settings->fdpll =
				(settings->fref * 2.0 * (double) (settings->MN).M) /
				((double) (settings->MN).N + 1.0);
		else
			settings->fdpll =
				(settings->fref * 8.0 * (double) (settings->MN).M) /
				((double) (settings->MN).N + 1.0);
		dprintf("%s(%u): type=A regm4xen=%u fref=%lfMHz M=%u N=%u => "
			"fdpll=%lfMHz\n", __func__, settings->id,
			settings->regm4xen, settings->fref, (settings->MN).M,
			(settings->MN).N, settings->fdpll);
	} else {
		settings->fdpll =
			(settings->fref * (double) (settings->MN).M) /
			((double) (settings->MN).N + 1.0);
		dprintf("%s(%u): type=B fref=%lfMHz M=%u N=%u => "
			"fdpll=%lfMHz\n", __func__, settings->id,
			settings->fref, (settings->MN).M,
			(settings->MN).N, settings->fdpll);
	}

	return settings->fdpll;
}
开发者ID:bcousson,项目名称:omapconf,代码行数:38,代码来源:dpll.c

示例8: sr54xx_export

/* ------------------------------------------------------------------------*//**
 * @FUNCTION		sr54xx_export
 * @BRIEF		export module register content to file, in XML format.
 * @RETURNS		0 in case of success
 *			OMAPCONF_ERR_CPU
 *			OMAPCONF_ERR_ARG
 *			OMAPCONF_ERR_REG_ACCESS
 * @param[in,out]	fp: output file stream (opened for write operations)
 * @param[in]		id: SR module ID
 * @DESCRIPTION		export module register content to file, in XML format.
 *//*------------------------------------------------------------------------ */
int sr54xx_export(FILE *fp, sr54xx_mod_id id)
{
	reg **mod;
	unsigned int i;

	CHECK_CPU(54xx, OMAPCONF_ERR_CPU);
	CHECK_NULL_ARG(fp, OMAPCONF_ERR_ARG);
	CHECK_ARG_LESS_THAN(id, SR54XX_MODS_COUNT, OMAPCONF_ERR_ARG);

	if (!sr54xx_is_enabled(id)) {
		printf("%s export: module not running, skipping "
			"registers export.\n", sr54xx_mod_name_get(id));
		return 0;
	}

	mod = sr54xx_mods[id];

	fprintf(fp, "          <submodule id=\"%u\" name=\"%s\">\n",
		id, sr54xx_mod_name_get(id));

	for (i = 0; i < OMAP5430_SMARTREFLEX_CORE_MOD_REGCOUNT; i++)
		fprintf(fp, "            <register id=\"%u\" name=\"%s\" "
			"addr=\"0x%08X\" data=\"0x%08X\" />\n", i,
			(mod[i])->name, (mod[i])->addr, reg_read(mod[i]));

	fprintf(fp, "          </submodule>\n");

	return 0;
}
开发者ID:bcousson,项目名称:omapconf,代码行数:40,代码来源:sr54xx.c

示例9: powerdm_has_last_power_state

/* ------------------------------------------------------------------------*//**
 * @FUNCTION		powerdm_has_last_power_state
 * @BRIEF		return 1 if power domain has LASTPOWERSTATEENTERED
 * @RETURNS		1 if power domain has a LASTPOWERSTATEENTERED bitfield.
 *			0 if not available or in case of error.
 * @param[in]		powerdm: power domain name
 * @DESCRIPTION		return 1 if power domain has LASTPOWERSTATEENTERED
 *			in PM_xyz_PWRSTST register (not all power domains
 *			feature it).
 *			Return 0 if not available or in case of error.
 *			Does not make any access to any register.
 *//*------------------------------------------------------------------------ */
unsigned int powerdm_has_last_power_state(const char *powerdm)
{
	int ret;
	powerdm_info data;

	CHECK_NULL_ARG(powerdm, 0);

	ret = _powerdm_info_get(powerdm, &data);
	if (ret != 0) {
		dprintf("%s(%s): could not retrieve powerdm_info struct!\n",
			__func__, powerdm);
		return 0;
	}

	if ((data.properties & PWRDM_HAS_LAST_STATE) != 0) {
		dprintf("%s(%s): HAS LASTPOWERSTATEENTERED bitfield\n",
			__func__, powerdm);
		return 1;
	} else {
		dprintf(
			"%s(%s): does NOT have LASTPOWERSTATEENTERED bitfield\n",
			__func__, powerdm);
		return 0;
	}
}
开发者ID:IngenicC,项目名称:omapconf,代码行数:37,代码来源:powerdomain.c

示例10: voltdm_voltage_get

/* ------------------------------------------------------------------------*//**
 * @FUNCTION		voltdm_voltage_get
 * @BRIEF		return the current voltage supplied to a voltage domain.
 * @RETURNS		supplied voltage in micro-volt (> 0) in case of success
 *			OMAPCONF_ERR_CPU
 *			OMAPCONF_ERR_ARG
 *			OMAPCONF_ERR_REG_ACCESS
 *			OMAPCONF_ERR_NOT_AVAILABLE
 *			OMAPCONF_ERR_INTERNAL
 * @param[in]		voltdm: voltage domain name (as defined in voltdm.h)
 * @DESCRIPTION		return the current voltage supplied to a voltage domain.
 *//*------------------------------------------------------------------------ */
int voltdm_voltage_get(const char *voltdm)
{
	int id, ret;
	double volt;

	CHECK_NULL_ARG(voltdm, OMAPCONF_ERR_ARG);

	voltdm_init();

	id = voltdm_s2id(voltdm);
	if (id < 0)
		return (double) OMAPCONF_ERR_ARG;

	if (cpu_is_omap44xx()) {
		ret = voltdm44xx_get_voltage((voltdm44xx_id) id, &volt);
		if (ret < 0)
			return (double) ret;
		else
			return v2uv(volt);
	} else if (cpu_is_omap54xx()) {
		return v2uv(voltdm54xx_voltage_get((voltdm54xx_id) id));
	} else {
		fprintf(stderr,
			"omapconf: %s(): cpu not supported!!!\n", __func__);
		return (double) OMAPCONF_ERR_CPU;
	}
}
开发者ID:bcousson,项目名称:omapconf,代码行数:39,代码来源:voltdm.c

示例11: powerdm_in_transition

/* ------------------------------------------------------------------------*//**
 * @FUNCTION		powerdm_in_transition
 * @BRIEF		return 1 if a power transition is ongoing
 *			on a given power domain
 * @RETURNS		1 if a power transition is ongoing
 *			0 if NO power transition is ongoing (or error)
 * @param[in]		powerdm: power domain name
 * @DESCRIPTION		return 1 if a power transition is ongoing
 *			on a given power domain
 *//*------------------------------------------------------------------------ */
unsigned int powerdm_in_transition(const char *powerdm)
{
	int in_transition;
	reg *pm_pwrstst;

	CHECK_NULL_ARG(powerdm, 0);

	pm_pwrstst = powerdm_pwrstst_reg_get(powerdm);
	if (pm_pwrstst == NULL) {
		dprintf("%s(%s): PM_PWRSTST==NULL!\n", __func__, powerdm);
		return 0;
	}

	in_transition = pwrdm_in_transition(pm_pwrstst);
	#ifdef PWRDM_DEBUG
	if (in_transition)
		printf("%s(%s): power transition ONGOING.\n",
			__func__, powerdm);
	else
		printf("%s(%s): NO power transition ongoing.\n",
			__func__, powerdm);
	#endif

	return in_transition;
}
开发者ID:IngenicC,项目名称:omapconf,代码行数:35,代码来源:powerdomain.c

示例12: CHECK_NULL_ARG

/* ------------------------------------------------------------------------*//**
 * @FUNCTION		cpu_die_id_get
 * @BRIEF		return OMAP DIE ID (4x 32-bit integers, string).
 * @RETURNS		OMAP DIE ID string (as "DIEID3-DIEID2-DIEID1-DIEID0")
 *			NULL in case of error
 * @param[in,out]	die_id_3: DIE ID (part 3, MSB)
 * @param[in,out]	die_id_2: DIE ID (part 2)
 * @param[in,out]	die_id_1: DIE ID (part 1)
 * @param[in,out]	die_id_0: DIE ID (part 0, LSB)
 * @param[in,out]	die_id: DIE ID string ("DIEID3-DIEID2-DIEID1-DIEID0")
 * @DESCRIPTION		return OMAP DIE ID (4x 32-bit integers, string).
 *//*------------------------------------------------------------------------ */
char *cpu_die_id_get(unsigned int *die_id_3, unsigned int *die_id_2,
	unsigned int *die_id_1, unsigned int *die_id_0,
	char die_id[CPU_DIE_ID_LENGTH])
{
	CHECK_NULL_ARG(die_id, NULL);

	if (mem_read(CONTROL_STD_FUSE_DIE_ID_3, die_id_3) != 0)
		return NULL;
	dprintf("%s(): die_id_3 = 0x%08X\n", __func__, *die_id_3);
	if (mem_read(CONTROL_STD_FUSE_DIE_ID_2, die_id_2) != 0)
		return NULL;
	dprintf("%s(): die_id_2 = 0x%08X\n", __func__, *die_id_2);
	if (mem_read(CONTROL_STD_FUSE_DIE_ID_1, die_id_1) != 0)
		return NULL;
	dprintf("%s(): die_id_1 = 0x%08X\n", __func__, *die_id_1);
	if (mem_read(CONTROL_STD_FUSE_DIE_ID_0, die_id_0) != 0)
		return NULL;
	dprintf("%s(): die_id_0 = 0x%08X\n", __func__, *die_id_0);

	sprintf(die_id, "%08X-%08X-%08X-%08X",
		*die_id_3, *die_id_2, *die_id_1, *die_id_0);
	dprintf("%s(): die_id = %s\n", __func__, die_id);

	return die_id;
}
开发者ID:fturgis,项目名称:omapconf,代码行数:37,代码来源:cpuinfo.c

示例13: prm54xx_import

/* ------------------------------------------------------------------------*//**
 * @FUNCTION		prm54xx_import
 * @BRIEF		import OMAP PRM registers from XML file
 * @RETURNS		0 in case of success
 *			OMAPCONF_ERR_ARG
 *			OMAPCONF_ERR_UNEXPECTED
 * @param[in,out]	fp: XML import file descriptor
 * @param[in]		id: CM module ID
 * @DESCRIPTION		import OMAP PRM registers from XML file,
 *			generated with lib54xx_export().
 *//*------------------------------------------------------------------------ */
int prm54xx_import(FILE *fp, prm54xx_mod_id id)
{
	reg **mod;
	char line[256], sline[256];
	char *xml_entry;
	int ret, i, n;

	CHECK_NULL_ARG(fp, OMAPCONF_ERR_ARG);
	CHECK_ARG_LESS_THAN(id, PRM54XX_MODS_COUNT, OMAPCONF_ERR_ARG);

	if (cpu_revision_get() == REV_ES1_0)
		mod = prm54xxes1_mods[id];
	else
		mod = prm54xx_mods[id];
	rewind(fp);

	/* Search for the PRM module tag */
	sprintf(sline, "<submodule id=\"%u\" name=\"%s\">",
		id, prm54xx_mod_name_get(id));
	while (fgets(line, sizeof(line), fp) != NULL) {
		if (strstr(line, sline) == NULL)
			continue;
		/* Import register content */
		for (i = 0; mod[i] != NULL; i++) {
			if (fgets(line, sizeof(line), fp) == NULL)
				return OMAPCONF_ERR_UNEXPECTED;
			line[strlen(line) - 1] = '\0'; /* remove ending '\n' */
			xml_entry = strstr(line, "<"); /* remove spaces */

			dprintf("%s(%u (%s)): xml_entry=%s\n", __func__, id,
				prm54xx_mod_name_get(id), xml_entry);

			/* Check register id is correct */
			ret = sscanf(xml_entry, "<register id=\"%u\" %s",
				&n, sline);
			if (ret != 2) {
				dprintf("%s(%u (%s)): could not get id\n",
					__func__, id, prm54xx_mod_name_get(id));
				return OMAPCONF_ERR_UNEXPECTED;
			}
			if (n != i) {
				dprintf(
					"%s(%u (%s)): register id does not match! (n=%u, i=%u)\n",
					__func__, id,
					prm54xx_mod_name_get(id), n, i);
				return OMAPCONF_ERR_UNEXPECTED;
			}

			ret = reg_xml_import(mod[i], xml_entry);
			if (ret != 0)
				return ret;
		}
		dprintf("%s(%u (%s)): all registers imported.\n", __func__, id,
			prm54xx_mod_name_get(id));
		break;
	}

	return 0;
}
开发者ID:IngenicC,项目名称:omapconf,代码行数:70,代码来源:prm54xx.c

示例14: main_dra7xx_show

/* ------------------------------------------------------------------------*//**
 * @FUNCTION		main_dra7xx_show
 * @BRIEF		show some DRA7 information,
 *			which category is found in argv
 * @RETURNS		0 in case of success
 *			OMAPCONF_ERR_CPU
 *			OMAPCONF_ERR_ARG in case of incorrect format
 * @param[in]		argc: shell input argument number
 * @param[in]		argv: shell input argument(s)
 * @DESCRIPTION		show some DRA7 information,
 *			which category is found in argv
 *//*------------------------------------------------------------------------ */
int main_dra7xx_show(int argc, char *argv[])
{
	CHECK_NULL_ARG(argv, OMAPCONF_ERR_ARG);

	if (argc < 1) {
		help(HELP_USAGE);
		return OMAPCONF_ERR_ARG;
	} else if (strcmp(argv[0], "hwtemp") == 0) {
		if (argc == 1) {
			return hwtemp_sensor_show(stdout, "all");
		} else if (argc == 2) {
			if (strcmp(argv[1], "all") == 0)
				return hwtemp_sensor_show(stdout, argv[1]);
			else if (hwtemp_sensor_is_available(argv[1]) != 0)
				return hwtemp_sensor_show(stdout, argv[1]);
			else
				return err_arg_msg_show(HELP_HWTEMPERATURE);
		} else {
			return err_arg_too_many_msg_show(HELP_HWTEMPERATURE);
		}
	} else if (strcmp(argv[0], "temp") == 0) {
		if (argc == 1) {
			return temp_sensor_show(stdout, "all");
		} else if (argc == 2) {
			if (strcmp(argv[1], "all") == 0)
				return temp_sensor_show(stdout, argv[1]);
			else if (hwtemp_sensor_is_available(argv[1]) != 0)
				return temp_sensor_show(stdout, argv[1]);
			else
				return err_arg_msg_show(HELP_TEMPERATURE);
		} else {
			return err_arg_too_many_msg_show(HELP_TEMPERATURE);
		}
	} else if (strcmp(argv[0], "dpll") == 0) {
		if (argc == 1) {
			return dpll_dra7xx_show(stdout);
		} else if (argc == 2) {
			if (strcmp(argv[1], "cfg") == 0)
				return dpll_dra7xx_show(stdout);
			else
				return err_arg_msg_show(HELP_DPLL);
		} else {
			return err_arg_too_many_msg_show(HELP_DPLL);
		}
	} else if (strcmp(argv[0], "opp") == 0) {
		if (argc == 1)
			return opp_show(stdout);
		else
			return err_arg_too_many_msg_show(HELP_SOC_OPP);
	} else if (strncmp(argv[0], "mcasp", 5) == 0) {
		if (argc == 1) {
			return dra7xx_mcasp_show(stdout, argc, argv);
		} else {
			return err_arg_too_many_msg_show(HELP_MCASP);
		}
	} else {
		return err_unknown_argument_msg_show(argv[0]);
	}
}
开发者ID:edenhill,项目名称:omapconf,代码行数:71,代码来源:main_dra7xx.c

示例15: cm54xx_export

/* ------------------------------------------------------------------------*//**
 * @FUNCTION		cm54xx_export
 * @BRIEF		export module register content to file, in XML format.
 * @RETURNS		0 in case of success
 *			OMAPCONF_ERR_CPU
 *			OMAPCONF_ERR_ARG
 *			OMAPCONF_ERR_INTERNAL
 * @param[in,out]	fp: output file stream (opened for write operations)
 * @param[in]		id: CM module ID
 * @DESCRIPTION		export module register content to file, in XML format.
 *//*------------------------------------------------------------------------ */
int cm54xx_export(FILE *fp, cm54xx_mod_id id)
{
	reg **mod;
	unsigned int i;

	CHECK_CPU(54xx, OMAPCONF_ERR_CPU);
	CHECK_NULL_ARG(fp, OMAPCONF_ERR_ARG);
	CHECK_ARG_LESS_THAN(id, CM54XX_MODS_COUNT, OMAPCONF_ERR_ARG);

	if ((cpu_revision_get() != REV_ES1_0) &&
		(id == CM54XX_L4PER_CM_CORE)) {
		fprintf(stderr, "omapconf: %s(): L4_PER does not exist!!!\n",
			__func__);
		return OMAPCONF_ERR_ARG;
	}

	dprintf("%s(): exporting CM %s (%u) module ...\n", __func__,
		cm54xx_mod_name_get(id), id);

	if (cpu_revision_get() == REV_ES1_0)
		mod = cm54xxes1_mods[id];
	else
		mod = cm54xx_mods[id];
	if (mod == NULL) {
		fprintf(stderr, "omapconf: %s(): mod == NULL!!!\n", __func__);
		return OMAPCONF_ERR_INTERNAL;
	}

	if ((id == CM54XX_INSTR_CM_CORE) &&
		!cm54xx_is_profiling_running(CM54XX_INSTR_CM_CORE)) {
		dprintf(
			"%s(%s): CM module is not accessible, don't export registers\n",
			__func__, cm54xx_mod_name_get(id));
		return 0;
	} else if ((id == CM54XX_INSTR_CM_CORE_AON) &&
		!cm54xx_is_profiling_running(CM54XX_INSTR_CM_CORE_AON)) {
		dprintf(
			"%s(%s): CM module is not accessible, don't export registers\n",
			__func__, cm54xx_mod_name_get(id));
		return 0;
	}

	fprintf(fp, "          <submodule id=\"%u\" name=\"%s\">\n",
		id, cm54xx_mod_name_get(id));

	for (i = 0; mod[i] != NULL; i++)
		fprintf(fp,
			"            <register id=\"%u\" name=\"%s\" addr=\"0x%08X\" data=\"0x%08X\" />\n",
			i, reg_name_get(mod[i]), reg_addr_get(mod[i]),
			reg_read(mod[i]));

	fprintf(fp, "          </submodule>\n");
	fflush(fp);

	dprintf("%s(): CM %s (%u) module exported.\n", __func__,
		cm54xx_mod_name_get(id), id);
	return 0;
}
开发者ID:IngenicC,项目名称:omapconf,代码行数:69,代码来源:cm54xx.c


注:本文中的CHECK_NULL_ARG函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。