Browse Source

Add compare function for global IRQ list

Serj Kalichev 10 years ago
parent
commit
ce5c1e4ca3
3 changed files with 13 additions and 2 deletions
  1. 1 1
      birq.c
  2. 5 1
      irq.h
  3. 7 0
      irq_parse.c

+ 1 - 1
birq.c

@@ -127,7 +127,7 @@ int main(int argc, char **argv)
 	sigaction(SIGQUIT, &sig_act, NULL);
 
 	/* Prepare data structures */
-	irqs = lub_list_new(NULL);
+	irqs = lub_list_new(irq_list_compare);
 
 	/* Main loop */
 	while (!sigterm) {

+ 5 - 1
irq.h

@@ -1,13 +1,17 @@
 #ifndef _irq_h
 #define _irq_h
 
-struct irq_t {
+struct irq_s {
 	int irq;
 	char *desc; /* IRQ text description */
 };
+typedef struct irq_s irq_t;
 
 #define SYSFS_PCI_PATH "/sys/bus/pci/devices"
 
+/* Compare function for global IRQ list */
+int irq_list_compare(const void *first, const void *second);
+
 /* IRQ list functions */
 int irqs_populate(lub_list_t *irqs);
 

+ 7 - 0
irq_parse.c

@@ -12,6 +12,13 @@
 #include "lub/list.h"
 #include "irq.h"
 
+int irq_list_compare(const void *first, const void *second)
+{
+	const irq_t *f = (const irq_t *)first;
+	const irq_t *s = (const irq_t *)second;
+	return (f->irq - s->irq);
+}
+
 static int irqs_populate_pci(lub_list_t *irqs)
 {
 	DIR *dir;