patch-2.4.13 linux/drivers/pnp/isapnp.c

Next file: linux/drivers/s390/block/dasd.c
Previous file: linux/drivers/pcmcia/sa1100_yopy.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.12/linux/drivers/pnp/isapnp.c linux/drivers/pnp/isapnp.c
@@ -87,6 +87,7 @@
 MODULE_PARM_DESC(isapnp_reserve_io, "ISA Plug & Play - reserve I/O region(s) - port,size");
 MODULE_PARM(isapnp_reserve_mem, "1-16i");
 MODULE_PARM_DESC(isapnp_reserve_mem, "ISA Plug & Play - reserve memory region(s) - address,size");
+MODULE_LICENSE("GPL");
 
 #define _PIDXR		0x279
 #define _PNPWRP		0xa79
@@ -1673,8 +1674,8 @@
 	}
 	isapnp_for_each_dev(dev) {
 		if (dev->active) {
-			if (dev->irq_resource[0].start == irq ||
-			    dev->irq_resource[1].start == irq)
+			if ((dev->irq_resource[0].flags && dev->irq_resource[0].start == irq) ||
+			    (dev->irq_resource[1].flags && dev->irq_resource[1].start == irq))
 				return 1;
 		}
 	}
@@ -1763,7 +1764,8 @@
 	}
 	isapnp_for_each_dev(dev) {
 		if (dev->active) {
-			if (dev->dma_resource[0].start == dma || dev->dma_resource[1].start == dma)
+			if ((dev->dma_resource[0].flags && dev->dma_resource[0].start == dma) ||
+			    (dev->dma_resource[1].flags && dev->dma_resource[1].start == dma))
 				return 1;
 		}
 	}
@@ -1784,6 +1786,10 @@
 
 static int isapnp_valid_dma(struct isapnp_cfgtmp *cfg, int idx)
 {
+	/* DMA priority: this table is good for i386 */
+	static unsigned short xtab[16] = {
+		1, 3, 5, 6, 7, 0, 2, 4
+	};
 	int err, i;
 	unsigned long *value1, *value2;
 	struct isapnp_dma *dma;
@@ -1799,15 +1805,16 @@
       	value1 = &cfg->result.dma_resource[idx].start;
       	value2 = &cfg->result.dma_resource[idx].end;
 	if (cfg->result.dma_resource[idx].flags & IORESOURCE_AUTO) {
-		for (i = 0; i < 8 && !(dma->map & (1<<i)); i++);
+		for (i = 0; i < 8 && !(dma->map & (1<<xtab[i])); i++);
 		if (i >= 8)
 			return -ENOENT;
 		cfg->result.dma_resource[idx].flags &= ~IORESOURCE_AUTO;
-		if (!isapnp_check_dma(cfg, *value1 = *value2 = i, idx))
+		if (!isapnp_check_dma(cfg, *value1 = *value2 = xtab[i], idx))
 			return 0;
 	}
 	do {
-		for (i = *value1 + 1; i < 8 && !(dma->map & (1<<i)); i++);
+		for (i = 0; i < 8 && xtab[i] != *value1; i++);
+		for (i++; i < 8 && !(dma->map & (1<<xtab[i])); i++);
 		if (i >= 8) {
 			if (dma->res && dma->res->alt) {
 				if ((err = isapnp_alternative_switch(cfg, dma->res, dma->res->alt))<0)
@@ -1816,7 +1823,7 @@
 			}
 			return -ENOENT;
 		} else {
-			*value1 = *value2 = i;
+			*value1 = *value2 = xtab[i];
 		}
 	} while (isapnp_check_dma(cfg, *value1, idx));
 	return 0;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)