/* @tlv_hdr: pointer to the TLV @tlv_type: type of the TLV we are looking for @tlv_size: expected size of the TLV we are looking for (if -1, don't check the size). This includes the header Returns: 0 if the TLV matches < 0 if it doesn't match at all > 0 total TLV + payload size, if the type matches, but not the size  */
static ssize_t i2400m_tlv_match(const struct i2400m_tlv_hdr *tlv, enum i2400m_tlv tlv_type, ssize_t tlv_size)
/* @tlv_hdr: pointer to the TLV @tlv_type: type of the TLV we are looking for @tlv_size: expected size of the TLV we are looking for (if -1, don't check the size). This includes the header Returns: 0 if the TLV matches < 0 if it doesn't match at all > 0 total TLV + payload size, if the type matches, but not the size  */
static ssize_t i2400m_tlv_match(const struct i2400m_tlv_hdr *tlv, enum i2400m_tlv tlv_type, ssize_t tlv_size)
{
	if (le16_to_cpu(tlv->type) != tlv_type)
		return -1;
	if (tlv_size != -1
	    && le16_to_cpu(tlv->length) + sizeof(*tlv) != tlv_size) {
		size_t size = le16_to_cpu(tlv->length) + sizeof(*tlv);
		printk(KERN_WARNING "W: tlv type 0x%x mismatched because of "
		       "size (got %zu vs %zu expected)\n",
		       tlv_type, size, tlv_size);
		return size;
	}
	return 0;
}