|
@@ -12,13 +12,17 @@
|
|
|
#include "lub/list.h"
|
|
|
#include "irq.h"
|
|
|
|
|
|
-int irqs_populate(lub_list_t *irqs)
|
|
|
+static int irqs_populate_pci(lub_list_t *irqs)
|
|
|
{
|
|
|
DIR *dir;
|
|
|
+ DIR *msi;
|
|
|
struct dirent *dent;
|
|
|
+ struct dirent *ment;
|
|
|
char path[PATH_MAX];
|
|
|
+ int num;
|
|
|
|
|
|
/* Now we can parse PCI devices only */
|
|
|
+ /* Get info from /sys/bus/pci/devices */
|
|
|
dir = opendir(SYSFS_PCI_PATH);
|
|
|
if (!dir)
|
|
|
return -1;
|
|
@@ -26,8 +30,35 @@ int irqs_populate(lub_list_t *irqs)
|
|
|
if (!strcmp(dent->d_name, ".") ||
|
|
|
!strcmp(dent->d_name, ".."))
|
|
|
continue;
|
|
|
- printf("entry: %s\n", dent->d_name);
|
|
|
+
|
|
|
+ /* Search for MSI IRQs. Since linux-3.2 */
|
|
|
+ sprintf(path, "%s/%s/msi_irqs", SYSFS_PCI_PATH, dent->d_name);
|
|
|
+ if ((msi = opendir(path))) {
|
|
|
+ while((ment = readdir(msi))) {
|
|
|
+ if (!strcmp(ment->d_name, ".") ||
|
|
|
+ !strcmp(ment->d_name, ".."))
|
|
|
+ continue;
|
|
|
+ num = strtol(ment->d_name, NULL, 10);
|
|
|
+ if (!num)
|
|
|
+ continue;
|
|
|
+ printf("%d\n", num);
|
|
|
+ }
|
|
|
+ closedir(msi);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Try to get IRQ number from irq file */
|
|
|
+ sprintf(path, "%s/%s/irq", SYSFS_PCI_PATH, dent->d_name);
|
|
|
}
|
|
|
+ closedir(dir);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+int irqs_populate(lub_list_t *irqs)
|
|
|
+{
|
|
|
+ irqs_populate_pci(irqs);
|
|
|
+// irqs_populate_proc(irqs);
|
|
|
|
|
|
return 0;
|
|
|
}
|