/* We unregister by all the data we used to register instead of by pointer to the @entry array because we might have used the same table for a bunch of IDs (for example). */
int uwb_est_unregister(u8 type, u8 event_high, u16 vendor, u16 product, const struct uwb_est_entry *entry, size_t entries)
/* We unregister by all the data we used to register instead of by pointer to the @entry array because we might have used the same table for a bunch of IDs (for example). */
int uwb_est_unregister(u8 type, u8 event_high, u16 vendor, u16 product, const struct uwb_est_entry *entry, size_t entries)
{
	unsigned long flags;
	unsigned itr;
	struct uwb_est est_cmp = {
		.type_event_high = type << 8 | event_high,
		.vendor = vendor,
		.product = product,
		.entry = entry,
		.entries = entries
	};
	write_lock_irqsave(&uwb_est_lock, flags);
	for (itr = 0; itr < uwb_est_used; itr++)
		if (!memcmp(&uwb_est[itr], &est_cmp, sizeof(est_cmp)))
			goto found;
	write_unlock_irqrestore(&uwb_est_lock, flags);
	return -ENOENT;
found:
	if (itr < uwb_est_used - 1)
		memmove(&uwb_est[itr], &uwb_est[itr+1], uwb_est_used - itr - 1);
	uwb_est_used--;
	write_unlock_irqrestore(&uwb_est_lock, flags);
	return 0;
}