When compiling the kernel with -Werror, compilation dies in ide-pci.c with 'unused variable dma_base'. The variable is only used if CONFIG_BLK_DEV_IDEDMA is defined, and unused otherwise. Attached is a patch to refactor setup_host_channel() into two functions, setup_host_channel() and setup_channel_dma(), which is only implemented if CONFIG_BLK_DEV_IDEDMA is defined, and is empty otherwise. Since dma_base is only declared and used in setup_channel_dma, the warning is silenced. Patch is against 2.5.25 and compiles fine. It does not change behaviour in any way, only a code cleanup. Comments appreciated. --- linux-2.5.25-vanilla/drivers/ide/ide-pci.c Sat Jul 6 02:42:33 2002 +++ linux-2.5.25-mx/drivers/ide/ide-pci.c Mon Jul 15 12:05:23 2002 @@ -158,6 +158,87 @@ return 0; } +#ifdef CONFIG_BLK_DEV_IDEDMA +/* + * Setup DMA transfers on the channel. + */ +static void __init setup_channel_dma(struct pci_dev *dev, + struct ata_pci_device* d, + int autodma, + struct ata_channel *ch) +{ + unsigned long dma_base; + + if (d->flags & ATA_F_NOADMA) + autodma = 0; + + if (autodma) + ch->autodma = 1; + + if (!((d->flags & ATA_F_DMA) || ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && (dev->class & 0x80)))) + return; + + /* + * Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space: + */ + dma_base = pci_resource_start(dev, 4); + if (dma_base) { + /* PDC20246, PDC20262, HPT343, & HPT366 */ + if ((ch->unit == ATA_PRIMARY) && d->extra) { + request_region(dma_base + 16, d->extra, dev->name); + ch->dma_extra = d->extra; + } + + /* If we are on the second channel, the dma base address will + * be one entry away from the primary interface. + */ + if (ch->unit == ATA_SECONDARY) + dma_base += 8; + + if (d->flags & ATA_F_SIMPLEX) { + outb(inb(dma_base + 2) & 0x60, dma_base + 2); + if (inb(dma_base + 2) & 0x80) + printk(KERN_INFO "%s: simplex device: DMA forced\n", dev->name); + } else { + /* If the device claims "simplex" DMA, this means only + * one of the two interfaces can be trusted with DMA at + * any point in time. So we should enable DMA only on + * one of the two interfaces. + */ + if ((inb(dma_base + 2) & 0x80)) { + if ((!ch->drives[0].present && !ch->drives[1].present) || + ch->unit == ATA_SECONDARY) { + printk(KERN_INFO "%s: simplex device: DMA disabled\n", dev->name); + dma_base = 0; + } + } + } + } else { + printk(KERN_INFO "%s: %s Bus-Master DMA was disabled by BIOS\n", + ch->name, dev->name); + + return; + } + + /* The function below will check itself whatever there is something to + * be done or not. We don't have therefore to care whatever it was + * already enabled by the primary channel run. + */ + pci_set_master(dev); + if (d->init_dma) + d->init_dma(ch, dma_base); + else + ata_init_dma(ch, dma_base); +} +#else +static void __init setup_channel_dma(struct pci_dev *dev, + struct ata_pci_device* d, + int autodma, + struct ata_channel *ch) +{ +} +#endif /* CONFIG_BLK_DEV_IDEDMA */ + /* * Setup a particular port on an ATA host controller. * @@ -171,7 +252,6 @@ int autodma) { unsigned long base = 0; - unsigned long dma_base; unsigned long ctl = 0; ide_pci_enablebit_t *e = &(d->enablebits[port]); struct ata_channel *ch; @@ -264,71 +344,11 @@ if (d->ata66_check) ch->udma_four = d->ata66_check(ch); } - -#ifdef CONFIG_BLK_DEV_IDEDMA - /* - * Setup DMA transfers on the channel. - */ - if (d->flags & ATA_F_NOADMA) - autodma = 0; - - if (autodma) - ch->autodma = 1; - - if (!((d->flags & ATA_F_DMA) || ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && (dev->class & 0x80)))) - goto no_dma; - /* - * Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space: - */ - dma_base = pci_resource_start(dev, 4); - if (dma_base) { - /* PDC20246, PDC20262, HPT343, & HPT366 */ - if ((ch->unit == ATA_PRIMARY) && d->extra) { - request_region(dma_base + 16, d->extra, dev->name); - ch->dma_extra = d->extra; - } - - /* If we are on the second channel, the dma base address will - * be one entry away from the primary interface. - */ - if (ch->unit == ATA_SECONDARY) - dma_base += 8; - - if (d->flags & ATA_F_SIMPLEX) { - outb(inb(dma_base + 2) & 0x60, dma_base + 2); - if (inb(dma_base + 2) & 0x80) - printk(KERN_INFO "%s: simplex device: DMA forced\n", dev->name); - } else { - /* If the device claims "simplex" DMA, this means only - * one of the two interfaces can be trusted with DMA at - * any point in time. So we should enable DMA only on - * one of the two interfaces. - */ - if ((inb(dma_base + 2) & 0x80)) { - if ((!ch->drives[0].present && !ch->drives[1].present) || - ch->unit == ATA_SECONDARY) { - printk(KERN_INFO "%s: simplex device: DMA disabled\n", dev->name); - dma_base = 0; - } - } - } - } else { - printk(KERN_INFO "%s: %s Bus-Master DMA was disabled by BIOS\n", - ch->name, dev->name); - - goto no_dma; - } - - /* The function below will check itself whatever there is something to - * be done or not. We don't have therefore to care whatever it was - * already enabled by the primary channel run. + + /* + * Setup DMA transfers on the channel (if CONFIG_BLK_DEV_IDEDMA is defined) */ - pci_set_master(dev); - if (d->init_dma) - d->init_dma(ch, dma_base); - else - ata_init_dma(ch, dma_base); -#endif + setup_channel_dma(dev, d, autodma, ch); no_dma: /* Call chipset-specific routine for each enabled channel. */ -- http://vipe.technion.ac.il/~mulix/ http://syscalltrack.sf.net/