/* get the size of a given (TPM) NV area  */
static int get_tpm_nv_size(struct udevice *tpm, uint32_t index, uint32_t *size)
/* get the size of a given (TPM) NV area  */
static int get_tpm_nv_size(struct udevice *tpm, uint32_t index, uint32_t *size)
{
	uint32_t err;
	uint8_t info[72];
	uint8_t *ptr;
	uint16_t v16;
	err = tpm_get_capability(tpm, TPM_CAP_NV_INDEX, index,
				 info, sizeof(info));
	if (err) {
		printf("tpm_get_capability(CAP_NV_INDEX, %08x) failed: %u\n",
		       index, err);
		return 1;
	}
	ptr = info + 6;
	v16 = get_unaligned_be16(ptr);
	ptr += 2 + v16 + 1 + 20;
	v16 = get_unaligned_be16(ptr);
	ptr += 2 + v16 + 1 + 20;
	ptr += 6 + 3;
	*size = get_unaligned_be32(ptr);
	return 0;
}