Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a29f6576 authored by Shahar S Matityahu's avatar Shahar S Matityahu Committed by Luca Coelho
Browse files

iwlwifi: add iwl_tlv_array_len()



Allows to easily calculate array length at the end of a TLV.

Signed-off-by: default avatarShahar S Matityahu <shahar.s.matityahu@intel.com>
Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
parent 94b952b5
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -972,4 +972,19 @@ struct iwl_fw_cmd_version {
	u8 notif_ver;
} __packed;

static inline size_t _iwl_tlv_array_len(const struct iwl_ucode_tlv *tlv,
					size_t fixed_size, size_t var_size)
{
	size_t var_len = le32_to_cpu(tlv->length) - fixed_size;

	if (WARN_ON(var_len % var_size))
		return 0;

	return var_len / var_size;
}

#define iwl_tlv_array_len(_tlv_ptr, _struct_ptr, _memb)			\
	_iwl_tlv_array_len((_tlv_ptr), sizeof(*(_struct_ptr)),		\
			   sizeof(_struct_ptr->_memb[0]))

#endif  /* __iwl_fw_file_h__ */