static __u16 devpath_to_vendor(const char *dev_path);
-void free_sys_dev(struct sys_dev **list)
+static void free_sys_dev(struct sys_dev **list)
{
while (*list) {
struct sys_dev *next = (*list)->next;
static struct sys_dev *intel_devices=NULL;
+static time_t valid_time = 0;
static enum sys_dev_type device_type_by_id(__u16 device_id)
{
{
struct sys_dev *ahci, *isci;
+ if (valid_time > time(0) - 10)
+ return intel_devices;
+
+ if (intel_devices)
+ free_sys_dev(&intel_devices);
+
isci = find_driver_devices("pci", "isci");
ahci = find_driver_devices("pci", "ahci");
elem = elem->next;
elem->next = isci;
}
- return ahci;
+ intel_devices = ahci;
+ valid_time = time(0);
+ return intel_devices;
}
/*
check_env("IMSM_TEST_SCU_EFI"))
return NULL;
-
- if (intel_devices != NULL)
- free_sys_dev(&intel_devices);
-
- intel_devices = find_intel_devices();
+ find_intel_devices();
if (intel_devices == NULL)
return NULL;
scan_adapter_roms(scan);
probe_roms_exit();
- if (intel_devices != NULL)
- free_sys_dev(&intel_devices);
- intel_devices = NULL;
-
if (populated_orom[hba_id])
return &imsm_orom[hba_id];
return NULL;
char *diskfd_to_devpath(int fd);
struct sys_dev *find_driver_devices(const char *bus, const char *driver);
struct sys_dev *find_intel_devices(void);
-void free_sys_dev(struct sys_dev **list);
const struct imsm_orom *find_imsm_capability(enum sys_dev_type hba_id);
const struct imsm_orom *find_imsm_orom(void);
int disk_attached_to_hba(int fd, const char *hba_path);
static struct sys_dev* find_disk_attached_hba(int fd, const char *devname)
{
- struct sys_dev *list, *elem, *prev;
+ struct sys_dev *list, *elem;
char *disk_path;
if ((list = find_intel_devices()) == NULL)
else
disk_path = diskfd_to_devpath(fd);
- if (!disk_path) {
- free_sys_dev(&list);
+ if (!disk_path)
return 0;
- }
- for (prev = NULL, elem = list; elem; prev = elem, elem = elem->next) {
- if (path_attached_to_hba(disk_path, elem->path)) {
- if (prev == NULL)
- list = list->next;
- else
- prev->next = elem->next;
- elem->next = NULL;
- if (disk_path != devname)
- free(disk_path);
- free_sys_dev(&list);
+ for (elem = list; elem; elem = elem->next)
+ if (path_attached_to_hba(disk_path, elem->path))
return elem;
- }
- }
+
if (disk_path != devname)
free(disk_path);
- free_sys_dev(&list);
return NULL;
}
else
result = 0;
}
- free_sys_dev(&list);
return result;
}
if (verbose > 0)
pr_err("no active Intel(R) RAID "
"controller found.\n");
- free_sys_dev(&list);
return 2;
} else if (verbose > 0)
print_found_intel_controllers(list);
pr_err("no active Intel(R) RAID "
"controller found under %s\n",controller_path);
- free_sys_dev(&list);
return result;
}
if (verbose > 0)
pr_err("IMSM_DETAIL_PLATFORM_ERROR=NO_INTEL_DEVICES\n");
result = 2;
- free_sys_dev(&list);
return result;
}
" Mixing devices attached to multiple controllers "
"is not allowed.\n");
}
- free_sys_dev(&hba_name);
return 2;
}
super->orom = find_imsm_capability(hba_name->type);
- free_sys_dev(&hba_name);
if (!super->orom)
return 3;
return 0;
dprintf("path: %s hba: %s attached: %s\n",
path, (hba) ? hba->path : "NULL", drv);
free(path);
- if (hba)
- free_sys_dev(&hba);
}
return drv;
}