ide: make /proc/ide/ optional
[linux-drm-fsl-dcu.git] / drivers / ide / ide.c
index b3c0818c5c6c592eefa9289b0e2cbe1492bf73a3..7a96f6f074941367cfc3c9e48100409c335a3eeb 100644 (file)
 #define        REVISION        "Revision: 7.00alpha2"
 #define        VERSION         "Id: ide.c 7.00a2 20020906"
 
-#undef REALLY_SLOW_IO          /* most systems can safely undef this */
-
 #define _IDE_C                 /* Tell ide.h it's really us */
 
 #include <linux/module.h>
@@ -179,11 +177,7 @@ DECLARE_MUTEX(ide_cfg_sem);
 static int ide_scan_direction; /* THIS was formerly 2.2.x pci=reverse */
 #endif
 
-#ifdef CONFIG_IDEDMA_AUTO
 int noautodma = 0;
-#else
-int noautodma = 1;
-#endif
 
 EXPORT_SYMBOL(noautodma);
 
@@ -222,9 +216,6 @@ static void init_hwif_data(ide_hwif_t *hwif, unsigned int index)
        hwif->bus_state = BUSSTATE_ON;
 
        hwif->atapi_dma = 0;            /* disable all atapi dma */ 
-       hwif->ultra_mask = 0x80;        /* disable all ultra */
-       hwif->mwdma_mask = 0x80;        /* disable all mwdma */
-       hwif->swdma_mask = 0x80;        /* disable all swdma */
 
        init_completion(&hwif->gendev_rel_comp);
 
@@ -359,7 +350,7 @@ static int ide_system_bus_speed(void)
        return system_bus_speed;
 }
 
-#ifdef CONFIG_PROC_FS
+#ifdef CONFIG_IDE_PROC_FS
 struct proc_dir_entry *proc_ide_root;
 #endif
 
@@ -486,6 +477,7 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif)
 
        hwif->tuneproc                  = tmp_hwif->tuneproc;
        hwif->speedproc                 = tmp_hwif->speedproc;
+       hwif->udma_filter               = tmp_hwif->udma_filter;
        hwif->selectproc                = tmp_hwif->selectproc;
        hwif->reset_poll                = tmp_hwif->reset_poll;
        hwif->pre_reset                 = tmp_hwif->pre_reset;
@@ -1130,17 +1122,40 @@ static int set_io_32bit(ide_drive_t *drive, int arg)
 static int set_using_dma (ide_drive_t *drive, int arg)
 {
 #ifdef CONFIG_BLK_DEV_IDEDMA
+       ide_hwif_t *hwif = drive->hwif;
+       int err = -EPERM;
+
        if (!drive->id || !(drive->id->capability & 1))
-               return -EPERM;
-       if (HWIF(drive)->ide_dma_check == NULL)
-               return -EPERM;
+               goto out;
+
+       if (hwif->ide_dma_check == NULL)
+               goto out;
+
+       err = -EBUSY;
+       if (ide_spin_wait_hwgroup(drive))
+               goto out;
+       /*
+        * set ->busy flag, unlock and let it ride
+        */
+       hwif->hwgroup->busy = 1;
+       spin_unlock_irq(&ide_lock);
+
+       err = 0;
+
        if (arg) {
-               if (ide_set_dma(drive))
-                       return -EIO;
-               if (HWIF(drive)->ide_dma_on(drive)) return -EIO;
+               if (ide_set_dma(drive) || hwif->ide_dma_on(drive))
+                       err = -EIO;
        } else
                ide_dma_off(drive);
-       return 0;
+
+       /*
+        * lock, clear ->busy flag and unlock before leaving
+        */
+       spin_lock_irq(&ide_lock);
+       hwif->hwgroup->busy = 0;
+       spin_unlock_irq(&ide_lock);
+out:
+       return err;
 #else
        return -EPERM;
 #endif
@@ -1486,23 +1501,23 @@ static int __init match_parm (char *s, const char *keywords[], int vals[], int m
 }
 
 #ifdef CONFIG_BLK_DEV_ALI14XX
-static int __initdata probe_ali14xx;
+extern int probe_ali14xx;
 extern int ali14xx_init(void);
 #endif
 #ifdef CONFIG_BLK_DEV_UMC8672
-static int __initdata probe_umc8672;
+extern int probe_umc8672;
 extern int umc8672_init(void);
 #endif
 #ifdef CONFIG_BLK_DEV_DTC2278
-static int __initdata probe_dtc2278;
+extern int probe_dtc2278;
 extern int dtc2278_init(void);
 #endif
 #ifdef CONFIG_BLK_DEV_HT6560B
-static int __initdata probe_ht6560b;
+extern int probe_ht6560b;
 extern int ht6560b_init(void);
 #endif
 #ifdef CONFIG_BLK_DEV_QD65XX
-static int __initdata probe_qd65xx;
+extern int probe_qd65xx;
 extern int qd65xx_init(void);
 #endif
 
@@ -1580,7 +1595,7 @@ static int __init ide_setup(char *s)
         */
        if (s[0] == 'h' && s[1] == 'd' && s[2] >= 'a' && s[2] <= max_drive) {
                const char *hd_words[] = {
-                       "none", "noprobe", "nowerr", "cdrom", "serialize",
+                       "none", "noprobe", "nowerr", "cdrom", "minus5",
                        "autotune", "noautotune", "minus8", "swapdata", "bswap",
                        "noflush", "remap", "remap63", "scsi", NULL };
                unit = s[2] - 'a';
@@ -1608,9 +1623,6 @@ static int __init ide_setup(char *s)
                                drive->ready_stat = 0;
                                hwif->noprobe = 0;
                                goto done;
-                       case -5: /* "serialize" */
-                               printk(" -- USE \"ide%d=serialize\" INSTEAD", hw);
-                               goto do_serialize;
                        case -6: /* "autotune" */
                                drive->autotune = IDE_TUNE_AUTO;
                                goto obsolete_option;
@@ -1671,7 +1683,7 @@ static int __init ide_setup(char *s)
                 * (-8, -9, -10) are reserved to ease the hardcoding.
                 */
                static const char *ide_words[] = {
-                       "noprobe", "serialize", "autotune", "noautotune", 
+                       "noprobe", "serialize", "minus3", "minus4",
                        "reset", "dma", "ata66", "minus8", "minus9",
                        "minus10", "four", "qd65xx", "ht6560b", "cmd640_vlb",
                        "dtc2278", "umc8672", "ali14xx", NULL };
@@ -1742,12 +1754,17 @@ static int __init ide_setup(char *s)
                                hwif->chipset = mate->chipset = ide_4drives;
                                mate->irq = hwif->irq;
                                memcpy(mate->io_ports, hwif->io_ports, sizeof(hwif->io_ports));
-                               goto do_serialize;
+                               hwif->mate = mate;
+                               mate->mate = hwif;
+                               hwif->serialized = mate->serialized = 1;
+                               goto obsolete_option;
                        }
 #endif /* CONFIG_BLK_DEV_4DRIVES */
                        case -10: /* minus10 */
                        case -9: /* minus9 */
                        case -8: /* minus8 */
+                       case -4:
+                       case -3:
                                goto bad_option;
                        case -7: /* ata66 */
 #ifdef CONFIG_BLK_DEV_IDEPCI
@@ -1762,16 +1779,7 @@ static int __init ide_setup(char *s)
                        case -5: /* "reset" */
                                hwif->reset = 1;
                                goto obsolete_option;
-                       case -4: /* "noautotune" */
-                               hwif->drives[0].autotune = IDE_TUNE_NOAUTO;
-                               hwif->drives[1].autotune = IDE_TUNE_NOAUTO;
-                               goto obsolete_option;
-                       case -3: /* "autotune" */
-                               hwif->drives[0].autotune = IDE_TUNE_AUTO;
-                               hwif->drives[1].autotune = IDE_TUNE_AUTO;
-                               goto obsolete_option;
                        case -2: /* "serialize" */
-                       do_serialize:
                                hwif->mate = &ide_hwifs[hw^1];
                                hwif->mate->mate = hwif;
                                hwif->serialized = hwif->mate->serialized = 1;
@@ -1840,8 +1848,8 @@ static void __init probe_for_hwifs (void)
 #endif /* CONFIG_BLK_DEV_CMD640 */
 #ifdef CONFIG_BLK_DEV_IDE_PMAC
        {
-               extern void pmac_ide_probe(void);
-               pmac_ide_probe();
+               extern int pmac_ide_probe(void);
+               (void)pmac_ide_probe();
        }
 #endif /* CONFIG_BLK_DEV_IDE_PMAC */
 #ifdef CONFIG_BLK_DEV_GAYLE
@@ -1884,7 +1892,7 @@ static void __init probe_for_hwifs (void)
 
 void ide_register_subdriver(ide_drive_t *drive, ide_driver_t *driver)
 {
-#ifdef CONFIG_PROC_FS
+#ifdef CONFIG_IDE_PROC_FS
        ide_add_proc_entries(drive->proc, driver->proc, drive);
 #endif
 }
@@ -1906,8 +1914,8 @@ EXPORT_SYMBOL(ide_register_subdriver);
 void ide_unregister_subdriver(ide_drive_t *drive, ide_driver_t *driver)
 {
        unsigned long flags;
-       
-#ifdef CONFIG_PROC_FS
+
+#ifdef CONFIG_IDE_PROC_FS
        ide_remove_proc_entries(drive->proc, driver->proc);
 #endif
        down(&ide_setting_sem);
@@ -1952,6 +1960,8 @@ static char *media_string(ide_drive_t *drive)
                return "tape";
        case ide_floppy:
                return "floppy";
+       case ide_optical:
+               return "optical";
        default:
                return "UNKNOWN";
        }
@@ -2059,7 +2069,7 @@ static int __init ide_init(void)
 
        init_ide_data();
 
-#ifdef CONFIG_PROC_FS
+#ifdef CONFIG_IDE_PROC_FS
        proc_ide_root = proc_mkdir("ide", NULL);
 #endif
 
@@ -2089,9 +2099,8 @@ static int __init ide_init(void)
        probe_for_hwifs();
        initializing = 0;
 
-#ifdef CONFIG_PROC_FS
        proc_ide_create();
-#endif
+
        return 0;
 }
 
@@ -2131,9 +2140,7 @@ void __exit cleanup_module (void)
        pnpide_exit();
 #endif
 
-#ifdef CONFIG_PROC_FS
        proc_ide_destroy();
-#endif
 
        bus_unregister(&ide_bus_type);
 }