diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2012-03-02 16:46:39 -0800 |
---|---|---|
committer | Stephen Hemminger <shemminger@vyatta.com> | 2012-03-03 09:56:10 -0800 |
commit | 6f0d227c17e898f5c1a0e015bd3275f56ae23a19 (patch) | |
tree | 9f40b2f18710e1fee144cc9cff686e18fe6a47cb /src/pirq.c | |
parent | d86431f9a431288b3b9d0bed26303a13cc1875b5 (diff) | |
download | vyatta-biosdevname-6f0d227c17e898f5c1a0e015bd3275f56ae23a19.tar.gz vyatta-biosdevname-6f0d227c17e898f5c1a0e015bd3275f56ae23a19.zip |
Update to biosdevname 0.3.11
Manual merge from http://linux.dell.com/biosdevname/biosdevname-0.3.11/
(cherry picked from commit 79066f1bdcb77fa8cfca2d98464257e1e436b58d)
Diffstat (limited to 'src/pirq.c')
-rw-r--r-- | src/pirq.c | 31 |
1 files changed, 25 insertions, 6 deletions
@@ -18,21 +18,28 @@ #include <sys/mman.h> #include "pirq.h" +extern int nopirq; + /* If unknown, use INT_MAX so they get sorted last */ -int pirq_pci_dev_to_slot(struct routing_table *table, int bus, int dev) +int pirq_pci_dev_to_slot(struct routing_table *table, int domain, int bus, int dev) { int i, num_slots; struct slot_entry *slot; if (!table) return INT_MAX; + if (domain != 0) /* can't represent non-zero domains in PIRQ */ + return INT_MAX; num_slots = (table->size - 32) / sizeof(*slot); for (i=0; i<num_slots; i++) { slot = &table->slot[i]; if (slot->bus == bus && - PCI_DEVICE(slot->device) == dev) + PCI_DEVICE(slot->device) == dev) { + if (slot->slot >= '1' && slot->slot <= '9') + return slot->slot - '0'; return slot->slot; + } } return INT_MAX; } @@ -47,8 +54,13 @@ struct routing_table * pirq_alloc_read_table() int i; void *mem; off_t offset=0L; - int fd=open("/dev/mem", O_RDONLY); + int fd; + /* Skip PIRQ table parsing */ + if (nopirq) { + return NULL; + } + fd = open("/dev/mem", O_RDONLY); if(fd==-1) return NULL; @@ -63,9 +75,16 @@ struct routing_table * pirq_alloc_read_table() table = (struct routing_table *)(mem+offset); size = table->size; /* quick sanity checks */ + if (size == 0) { + table = NULL; + break; + } /* Version must be 1.0 */ - if (! (table->version >> 8)==1 && - (table->version && 0xFF) == 0) break; + if (!((table->version >> 8) == 1 && + (table->version & 0xFF) == 0)) { + table = NULL; + break; + } table = malloc(size); if (!table) break; @@ -123,7 +142,7 @@ pirq_unparse_routing_table(struct routing_table *table) printf("Bus : %x\n", table->router_bus); printf("DevFn : %x\n", table->router_devfn); printf("Exclusive IRQs : %x\n", table->exclusive_irqs); - printf("Compatable Router: %x\n", table->compatable_router); + printf("Compatible Router: %x\n", table->compatable_router); num_slots = (table->size - 32) / sizeof(*slot); slot = &table->slot[0]; |