/* @rceb: event for which we compute the size, it contains a variable length field. @core_size: size of the "non variable" part of the event @offset: place in event where the length of the variable part is stored @buf_size: total length of buffer in which event arrived - we need to make sure we read the offset in memory that is still part of the event  */
static ssize_t hwarc_get_event_size(struct uwb_rc *rc, const struct uwb_rceb *rceb, size_t core_size, size_t offset, const size_t buf_size)
/* @rceb: event for which we compute the size, it contains a variable length field. @core_size: size of the "non variable" part of the event @offset: place in event where the length of the variable part is stored @buf_size: total length of buffer in which event arrived - we need to make sure we read the offset in memory that is still part of the event  */
static ssize_t hwarc_get_event_size(struct uwb_rc *rc, const struct uwb_rceb *rceb, size_t core_size, size_t offset, const size_t buf_size)
{
	ssize_t size = -ENOSPC;
	const void *ptr = rceb;
	size_t type_size = sizeof(__le16);
	struct device *dev = &rc->uwb_dev.dev;
	if (offset + type_size >= buf_size) {
		dev_err(dev, "Not enough data to read extra size of event "
			"0x%02x/%04x/%02x, only got %zu bytes.\n",
			rceb->bEventType, le16_to_cpu(rceb->wEvent),
			rceb->bEventContext, buf_size);
		goto out;
	}
	ptr += offset;
	size = core_size + le16_to_cpu(*(__le16 *)ptr);
out:
	return size;
}