/* Unregister an IB device. All clients will receive a remove callback.  */
void ib_unregister_device(struct ib_device *device)
/* Unregister an IB device. All clients will receive a remove callback.  */
void ib_unregister_device(struct ib_device *device)
{
	struct ib_client *client;
	struct ib_client_data *context, *tmp;
	unsigned long flags;
	mutex_lock(&device_mutex);
	list_for_each_entry_reverse(client, &client_list, list)
		if (client->remove)
			client->remove(device);
	list_del(&device->core_list);
	kfree(device->gid_tbl_len);
	kfree(device->pkey_tbl_len);
	mutex_unlock(&device_mutex);
	ib_device_unregister_sysfs(device);
	spin_lock_irqsave(&device->client_data_lock, flags);
	list_for_each_entry_safe(context, tmp, &device->client_data_list, list)
		kfree(context);
	spin_unlock_irqrestore(&device->client_data_lock, flags);
	device->reg_state = IB_DEV_UNREGISTERED;
}