[PATCH v1 2/4] cmd: Add a sysinfo command

Marek Vasut marek.vasut at mailbox.org
Sat Jun 17 02:41:45 CEST 2023


On 6/16/23 17:21, Detlev Casanova wrote:

[...]

> +static int do_sysinfo_id(struct cmd_tbl *cmdtp, int flag, int argc,
> +			 char *const argv[])
> +{
> +	struct udevice *dev;
> +	u32 board_id;
> +	char board_id_str[5] = { '\0' };
> +	int ret = get_sysinfo(&dev);
> +
> +	if (ret)
> +		return ret;
> +
> +	ret = sysinfo_get_int(dev,
> +			      SYSINFO_ID_BOARD_ID,
> +			      &board_id);
> +
> +	if (ret) {
> +		debug("Cannot get sysinfo int: %d\n", ret);
> +		return ret;
> +	}
> +
> +	sprintf(board_id_str, "0x%02x", board_id);
> +	if (argc == 2)
> +		env_set(argv[1], board_id_str);

env_set_hex()

> +	else
> +		printf("%s\n", board_id_str);

printf(...%02x...

> +	return 0;
> +}
> +
> +static int do_sysinfo_revision(struct cmd_tbl *cmdtp, int flag, int argc,
> +			       char *const argv[])
> +{
> +	struct udevice *dev;
> +	char rev[4];
> +	int ret = get_sysinfo(&dev);
> +
> +	if (ret)
> +		return ret;
> +
> +	ret = sysinfo_get_str(dev,
> +			      SYSINFO_ID_BOARD_REVISION,
> +			      4,
> +			      rev);
> +
> +	if (ret) {
> +		debug("Cannot get sysinfo str: %d\n", ret);
> +		return ret;

Commands always return CMD_RET_* , not errno .


More information about the U-Boot mailing list