/* Note that this assumes the output buffer always has enough space. */
static size_t reg2hex(const struct xtensa_register *reg, char *hex)
/* Note that this assumes the output buffer always has enough space. */
static size_t reg2hex(const struct xtensa_register *reg, char *hex)
{
	uint8_t *bin = (uint8_t *)&reg->val;
	size_t binlen = reg->byte_size;
	for (size_t i = 0; i < binlen; i++) {
		if (hex2char(bin[i] >> 4, &hex[2 * i]) < 0) {
			return 0;
		}
		if (hex2char(bin[i] & 0xf, &hex[2 * i + 1]) < 0) {
			return 0;
		}
	}
	return 2 * binlen;
}