PATCH: split up ide-pci.c:setup_host_channel to silence unused variable warning

PATCH: split up ide-pci.c:setup_host_channel to silence unused variable warning

Post by Muli Ben-Yehud » Tue, 16 Jul 2002 18:40:07



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/

  application_pgp-signature_part
< 1K Download
 
 
 

1. PATCH: module.h - silence "statement with no effect" warnings 2.5.53-bk

2.5.53-bk complains about "statement with no effect" in module.h in
multiple files including module.h. This patch shuts it up.

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#                  ChangeSet    1.973   -> 1.974  
#       include/linux/module.h  1.32    -> 1.33  
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------

# get rid of "statement has no effect" warnings from gcc
# --------------------------------------------
#
diff -Nru a/include/linux/module.h b/include/linux/module.h
--- a/include/linux/module.h    Mon Dec 30 14:10:56 2002

        /*
         * Yes, we ignore the retval here, that's why it's deprecated.
         */
-       try_module_get(module);
+       (void)try_module_get(module);
 }


        local_inc(&module->ref[get_cpu()].count);
        put_cpu();
 #else
-       try_module_get(module);
+       (void)try_module_get(module);
 #endif
 }
 #define MOD_INC_USE_COUNT \

--
Muli Ben-Yehuda
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

2. Xwindows programming question.

3. fix warning: unused variable powernow-k6.c

4. broken stack after msgrcv

5. Unused variable warning in ac97_codec.c

6. Upgrading firewall host. Easiest way?

7. GCC: "unused variable" warning not reported

8. cursor keys remap HELP!!!!

9. fix warning: unused variable longrun.c

10. [PATCH][TRIVIAL] cpufreq/longrun.c : eliminate unused variable

11. Solaris 7: Warning: /pci@0,0/pci-ide@7,1/ata@1 (ata1):

12. Solaris 7: "Warning: /pci@0,0/pci-ide@7,1/ata@1 (ata1):"

13. [PATCH][TRIVIAL] cpufreq/powernow-k6.c : eliminate unused variable