struct sys_dev *find_driver_devices(const char *bus, const char *driver)
{
/* search sysfs for devices driven by 'driver' */
- char path[292];
- char link[256];
- char *c;
+ char path[PATH_MAX];
+ char link[PATH_MAX];
+ char *c, *p;
DIR *driver_dir;
struct dirent *de;
struct sys_dev *head = NULL;
if (devpath_to_ll(path, "class", &class) != 0)
continue;
+ /*
+ * Each VMD device (domain) adds separate PCI bus, it is better
+ * to store path as a path to that bus (easier further
+ * determination which NVMe dev is connected to this particular
+ * VMD domain).
+ */
+ if (type == SYS_DEV_VMD) {
+ sprintf(path, "/sys/bus/%s/drivers/%s/%s/domain/device",
+ bus, driver, de->d_name);
+ }
+ p = realpath(path, NULL);
+ if (p == NULL) {
+ pr_err("Unable to get real path for '%s'\n", path);
+ continue;
+ }
+
/* start / add list entry */
if (!head) {
head = xmalloc(sizeof(*head));
list->dev_id = (__u16) dev_id;
list->class = (__u32) class;
list->type = type;
- /* Each VMD device (domain) adds separate PCI bus, it is better to
- * store path as a path to that bus (easier further determination which
- * NVMe dev is connected to this particular VMD domain).
- */
- if (type == SYS_DEV_VMD) {
- sprintf(path, "/sys/bus/%s/drivers/%s/%s/domain/device",
- bus, driver, de->d_name);
- }
- list->path = realpath(path, NULL);
list->next = NULL;
+ list->path = p;
+
if ((list->pci_id = strrchr(list->path, '/')) != NULL)
list->pci_id++;
}
return NULL;
}
+struct sys_dev *device_by_id_and_path(__u16 device_id, const char *path)
+{
+ struct sys_dev *iter;
+
+ for (iter = intel_devices; iter != NULL; iter = iter->next)
+ if ((iter->dev_id == device_id) && strstr(iter->path, path))
+ return iter;
+ return NULL;
+}
+
static int devpath_to_ll(const char *dev_path, const char *entry, unsigned long long *val)
{
char path[strlen(dev_path) + strlen(entry) + 2];
if (__le16_to_cpu(ptr->vendorID) != 0x8086)
return 0;
+ if (get_orom_by_device_id(ptr->deviceID))
+ return 0;
+
for (offset = 0; offset < len; offset += 4) {
const void *mem = start + offset;
errno = 0;
var_data_len = strtoul(buf, NULL, 16);
- if ((errno == ERANGE && (var_data_len == LONG_MAX))
- || (errno != 0 && var_data_len == 0))
+ if ((errno == ERANGE && (var_data_len == LONG_MAX)) ||
+ (errno != 0 && var_data_len == 0))
return 1;
/* get data */