/* Iterates over the entire list first, freeing all the values, then frees the list itself. Returns 0 on success or -EINVAL if the key can't be found.  */
int scsi_dev_info_remove_list(int key)
/* Iterates over the entire list first, freeing all the values, then frees the list itself. Returns 0 on success or -EINVAL if the key can't be found.  */
int scsi_dev_info_remove_list(int key)
{
	struct list_head *lh, *lh_next;
	struct scsi_dev_info_list_table *devinfo_table =
		scsi_devinfo_lookup_by_key(key);
	if (IS_ERR(devinfo_table))
		return -EINVAL;
	list_del(&devinfo_table->node);
	list_for_each_safe(lh, lh_next, &devinfo_table->scsi_dev_info_list) {
		struct scsi_dev_info_list *devinfo;
		devinfo = list_entry(lh, struct scsi_dev_info_list,
				     dev_info_list);
		kfree(devinfo);
	}
	kfree(devinfo_table);
	return 0;
}