Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-rc-fixes-2.6
[safe/jmp/linux-2.6] / drivers / ide / ide-probe.c
index c5f71ac..3a2a9a3 100644 (file)
@@ -31,8 +31,6 @@
  *                     valid after probe time even with noprobe
  */
 
-#undef REALLY_SLOW_IO          /* most systems can safely undef this */
-
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/string.h>
@@ -146,7 +144,7 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
        local_irq_enable();
        ide_fix_driveid(id);
 
-#if defined (CONFIG_SCSI_EATA_DMA) || defined (CONFIG_SCSI_EATA_PIO) || defined (CONFIG_SCSI_EATA)
+#if defined (CONFIG_SCSI_EATA_PIO) || defined (CONFIG_SCSI_EATA)
        /*
         * EATA SCSI controllers do a hardware ATA emulation:
         * Ignore them if there is a driver for them available.
@@ -156,7 +154,7 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
                printk("%s: EATA SCSI HBA %.10s\n", drive->name, id->model);
                goto err_misc;
        }
-#endif /* CONFIG_SCSI_EATA_DMA || CONFIG_SCSI_EATA_PIO */
+#endif /* CONFIG_SCSI_EATA || CONFIG_SCSI_EATA_PIO */
 
        /*
         *  WIN_IDENTIFY returns little-endian info,
@@ -576,11 +574,11 @@ static inline u8 probe_for_drive (ide_drive_t *drive)
                        /* look for ATAPI device */
                        (void) do_probe(drive, WIN_PIDENTIFY);
                }
-               if (strstr(drive->id->model, "E X A B Y T E N E S T"))
-                       enable_nest(drive);
                if (!drive->present)
                        /* drive not found */
                        return 0;
+               if (strstr(drive->id->model, "E X A B Y T E N E S T"))
+                       enable_nest(drive);
        
                /* identification failed? */
                if (!drive->id_read) {
@@ -623,6 +621,8 @@ static void hwif_release_dev (struct device *dev)
 
 static void hwif_register (ide_hwif_t *hwif)
 {
+       int ret;
+
        /* register with global device tree */
        strlcpy(hwif->gendev.bus_id,hwif->name,BUS_ID_SIZE);
        hwif->gendev.driver_data = hwif;
@@ -634,7 +634,10 @@ static void hwif_register (ide_hwif_t *hwif)
                        hwif->gendev.parent = NULL;
        }
        hwif->gendev.release = hwif_release_dev;
-       device_register(&hwif->gendev);
+       ret = device_register(&hwif->gendev);
+       if (ret < 0)
+               printk(KERN_WARNING "IDE: %s: device_register error: %d\n",
+                       __FUNCTION__, ret);
 }
 
 static int wait_hwif_ready(ide_hwif_t *hwif)
@@ -714,7 +717,7 @@ EXPORT_SYMBOL_GPL(ide_undecoded_slave);
  * This routine only knows how to look for drive units 0 and 1
  * on an interface, so any setting of MAX_DRIVES > 2 won't work here.
  */
-static void probe_hwif(ide_hwif_t *hwif)
+static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif))
 {
        unsigned int unit;
        unsigned long flags;
@@ -817,6 +820,9 @@ static void probe_hwif(ide_hwif_t *hwif)
                return;
        }
 
+       if (fixup)
+               fixup(hwif);
+
        for (unit = 0; unit < MAX_DRIVES; ++unit) {
                ide_drive_t *drive = &hwif->drives[unit];
 
@@ -848,11 +854,11 @@ static void probe_hwif(ide_hwif_t *hwif)
                                 * things, if not checked and cleared.
                                 *   PARANOIA!!!
                                 */
-                               hwif->ide_dma_off_quietly(drive);
+                               hwif->dma_off_quietly(drive);
 #ifdef CONFIG_IDEDMA_ONLYDISK
                                if (drive->media == ide_disk)
 #endif
-                                       hwif->ide_dma_check(drive);
+                                       ide_set_dma(drive);
                        }
                }
        }
@@ -871,10 +877,7 @@ static int hwif_init(ide_hwif_t *hwif);
 
 int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif))
 {
-       probe_hwif(hwif);
-
-       if (fixup)
-               fixup(hwif);
+       probe_hwif(hwif, fixup);
 
        if (!hwif_init(hwif)) {
                printk(KERN_INFO "%s: failed to initialize IDE interface\n",
@@ -884,13 +887,19 @@ int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)
 
        if (hwif->present) {
                u16 unit = 0;
+               int ret;
+
                for (unit = 0; unit < MAX_DRIVES; ++unit) {
                        ide_drive_t *drive = &hwif->drives[unit];
                        /* For now don't attach absent drives, we may
                           want them on default or a new "empty" class
                           for hotplug reprobing ? */
                        if (drive->present) {
-                               device_register(&drive->gendev);
+                               ret = device_register(&drive->gendev);
+                               if (ret < 0)
+                                       printk(KERN_WARNING "IDE: %s: "
+                                               "device_register error: %d\n",
+                                               __FUNCTION__, ret);
                        }
                }
        }
@@ -936,7 +945,7 @@ static void save_match(ide_hwif_t *hwif, ide_hwif_t *new, ide_hwif_t **match)
  */
 static int ide_init_queue(ide_drive_t *drive)
 {
-       request_queue_t *q;
+       struct request_queue *q;
        ide_hwif_t *hwif = HWIF(drive);
        int max_sectors = 256;
        int max_sg_entries = PRD_ENTRIES;
@@ -989,10 +998,6 @@ static int ide_init_queue(ide_drive_t *drive)
        /* needs drive->queue to be set */
        ide_toggle_bounce(drive, 1);
 
-       /* enable led activity for disk drives only */
-       if (drive->media == ide_disk && hwif->led_act)
-               blk_queue_activity_fn(q, hwif->led_act, drive);
-
        return 0;
 }
 
@@ -1004,7 +1009,7 @@ static int ide_init_queue(ide_drive_t *drive)
  * and irq serialization situations.  This is somewhat complex because
  * it handles static as well as dynamic (PCMCIA) IDE interfaces.
  *
- * The SA_INTERRUPT in sa_flags means ide_intr() is always entered with
+ * The IRQF_DISABLED in sa_flags means ide_intr() is always entered with
  * interrupts completely disabled.  This can be bad for interrupt latency,
  * but anything else has led to problems on some machines.  We re-enable
  * interrupts as much as we can safely do in most places.
@@ -1020,7 +1025,7 @@ static int init_irq (ide_hwif_t *hwif)
        BUG_ON(irqs_disabled());        
        BUG_ON(hwif == NULL);
 
-       down(&ide_cfg_sem);
+       mutex_lock(&ide_cfg_mtx);
        hwif->hwgroup = NULL;
 #if MAX_HWIFS > 1
        /*
@@ -1068,14 +1073,14 @@ static int init_irq (ide_hwif_t *hwif)
                hwgroup->hwif->next = hwif;
                spin_unlock_irq(&ide_lock);
        } else {
-               hwgroup = kmalloc_node(sizeof(ide_hwgroup_t), GFP_KERNEL,
+               hwgroup = kmalloc_node(sizeof(ide_hwgroup_t),
+                                       GFP_KERNEL | __GFP_ZERO,
                                        hwif_to_node(hwif->drives[0].hwif));
                if (!hwgroup)
                        goto out_up;
 
                hwif->hwgroup = hwgroup;
 
-               memset(hwgroup, 0, sizeof(ide_hwgroup_t));
                hwgroup->hwif     = hwif->next = hwif;
                hwgroup->rq       = NULL;
                hwgroup->handler  = NULL;
@@ -1090,15 +1095,15 @@ static int init_irq (ide_hwif_t *hwif)
         * Allocate the irq, if not already obtained for another hwif
         */
        if (!match || match->irq != hwif->irq) {
-               int sa = SA_INTERRUPT;
+               int sa = IRQF_DISABLED;
 #if defined(__mc68000__) || defined(CONFIG_APUS)
-               sa = SA_SHIRQ;
+               sa = IRQF_SHARED;
 #endif /* __mc68000__ || CONFIG_APUS */
 
                if (IDE_CHIPSET_IS_PCI(hwif->chipset)) {
-                       sa = SA_SHIRQ;
+                       sa = IRQF_SHARED;
 #ifndef CONFIG_IDEPCI_SHARE_IRQ
-                       sa |= SA_INTERRUPT;
+                       sa |= IRQF_DISABLED;
 #endif /* CONFIG_IDEPCI_SHARE_IRQ */
                }
 
@@ -1149,7 +1154,7 @@ static int init_irq (ide_hwif_t *hwif)
                printk(" (%sed with %s)",
                        hwif->sharing_irq ? "shar" : "serializ", match->name);
        printk("\n");
-       up(&ide_cfg_sem);
+       mutex_unlock(&ide_cfg_mtx);
        return 0;
 out_unlink:
        spin_lock_irq(&ide_lock);
@@ -1172,7 +1177,7 @@ out_unlink:
        }
        spin_unlock_irq(&ide_lock);
 out_up:
-       up(&ide_cfg_sem);
+       mutex_unlock(&ide_cfg_mtx);
        return 1;
 }
 
@@ -1377,6 +1382,9 @@ static int hwif_init(ide_hwif_t *hwif)
 
 done:
        init_gendisk(hwif);
+
+       ide_acpi_init(hwif);
+
        hwif->present = 1;      /* success */
        return 1;
 
@@ -1396,7 +1404,7 @@ int ideprobe_init (void)
 
        for (index = 0; index < MAX_HWIFS; ++index)
                if (probe[index])
-                       probe_hwif(&ide_hwifs[index]);
+                       probe_hwif(&ide_hwifs[index], NULL);
        for (index = 0; index < MAX_HWIFS; ++index)
                if (probe[index])
                        hwif_init(&ide_hwifs[index]);
@@ -1409,10 +1417,19 @@ int ideprobe_init (void)
                        if (hwif->chipset == ide_unknown || hwif->chipset == ide_forced)
                                hwif->chipset = ide_generic;
                        for (unit = 0; unit < MAX_DRIVES; ++unit)
-                               if (hwif->drives[unit].present)
-                                       device_register(&hwif->drives[unit].gendev);
+                               if (hwif->drives[unit].present) {
+                                       int ret = device_register(
+                                               &hwif->drives[unit].gendev);
+                                       if (ret < 0)
+                                               printk(KERN_WARNING "IDE: %s: "
+                                                       "device_register error: %d\n",
+                                                       __FUNCTION__, ret);
+                               }
                }
        }
+       for (index = 0; index < MAX_HWIFS; ++index)
+               if (probe[index])
+                       ide_proc_register_port(&ide_hwifs[index]);
        return 0;
 }