]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/ide-probe.c
ide: remove unnecessary MAX_HWIFS checks from ide-probe.c
[linux-2.6-omap-h63xx.git] / drivers / ide / ide-probe.c
index 7578ad48080ff7478ea4cc1d5c82dcf0f8748877..237b9871f80a6708f6169076976f981966e8456a 100644 (file)
@@ -89,16 +89,14 @@ static void ide_disk_init_mult_count(ide_drive_t *drive)
        u8 max_multsect = id[ATA_ID_MAX_MULTSECT] & 0xff;
 
        if (max_multsect) {
-#ifdef CONFIG_IDEDISK_MULTI_MODE
                if ((max_multsect / 2) > 1)
                        id[ATA_ID_MULTSECT] = max_multsect | 0x100;
                else
                        id[ATA_ID_MULTSECT] &= ~0x1ff;
 
                drive->mult_req = id[ATA_ID_MULTSECT] & 0xff;
-#endif
-               if ((id[ATA_ID_MULTSECT] & 0x100) &&
-                   (id[ATA_ID_MULTSECT] & 0xff))
+
+               if (drive->mult_req)
                        drive->special.b.set_multmode = 1;
        }
 }
@@ -118,7 +116,7 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
        ide_hwif_t *hwif = HWIF(drive);
        u16 *id = drive->id;
        char *m = (char *)&id[ATA_ID_PROD];
-       int bswap = 1;
+       int bswap = 1, is_cfa;
 
        /* read 512 bytes of id info */
        hwif->tp_ops->input_data(drive, NULL, id, SECTOR_SIZE);
@@ -214,17 +212,15 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
         * Not an ATAPI device: looks like a "regular" hard disk
         */
 
-       /*
-        * 0x848a = CompactFlash device
-        * These are *not* removable in Linux definition of the term
-        */
-       if (id[ATA_ID_CONFIG] != 0x848a && (id[ATA_ID_CONFIG] & (1 << 7)))
+       is_cfa = ata_id_is_cfa(id);
+
+       /* CF devices are *not* removable in Linux definition of the term */
+       if (is_cfa == 0 && (id[ATA_ID_CONFIG] & (1 << 7)))
                drive->removable = 1;
 
        drive->media = ide_disk;
 
-       printk(KERN_CONT "%s DISK drive\n",
-               (id[ATA_ID_CONFIG] == 0x848a) ? "CFA" : "ATA");
+       printk(KERN_CONT "%s DISK drive\n", is_cfa ? "CFA" : "ATA");
 
        return;
 
@@ -291,17 +287,9 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
        tp_ops->exec_command(hwif, cmd);
 
        timeout = ((cmd == ATA_CMD_ID_ATA) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2;
-       timeout += jiffies;
-       do {
-               if (time_after(jiffies, timeout)) {
-                       /* drive timed-out */
-                       return 1;
-               }
-               /* give drive a breather */
-               msleep(50);
-               s = use_altstatus ? tp_ops->read_altstatus(hwif)
-                                 : tp_ops->read_status(hwif);
-       } while (s & ATA_BUSY);
+
+       if (ide_busy_sleep(hwif, timeout, use_altstatus))
+               return 1;
 
        /* wait for IRQ and ATA_DRQ */
        msleep(50);
@@ -383,19 +371,21 @@ static int try_to_identify (ide_drive_t *drive, u8 cmd)
        return retval;
 }
 
-static int ide_busy_sleep(ide_hwif_t *hwif)
+int ide_busy_sleep(ide_hwif_t *hwif, unsigned long timeout, int altstatus)
 {
-       unsigned long timeout = jiffies + WAIT_WORSTCASE;
        u8 stat;
 
+       timeout += jiffies;
+
        do {
-               msleep(50);
-               stat = hwif->tp_ops->read_status(hwif);
+               msleep(50);     /* give drive a breather */
+               stat = altstatus ? hwif->tp_ops->read_altstatus(hwif)
+                                : hwif->tp_ops->read_status(hwif);
                if ((stat & ATA_BUSY) == 0)
                        return 0;
        } while (time_before(jiffies, timeout));
 
-       return 1;
+       return 1;       /* drive timed-out */
 }
 
 static u8 ide_read_device(ide_drive_t *drive)
@@ -489,7 +479,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
                        SELECT_DRIVE(drive);
                        msleep(50);
                        tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET);
-                       (void)ide_busy_sleep(hwif);
+                       (void)ide_busy_sleep(hwif, WAIT_WORSTCASE, 0);
                        rc = try_to_identify(drive, cmd);
                }
 
@@ -529,7 +519,7 @@ static void enable_nest (ide_drive_t *drive)
        msleep(50);
        tp_ops->exec_command(hwif, ATA_EXABYTE_ENABLE_NEST);
 
-       if (ide_busy_sleep(hwif)) {
+       if (ide_busy_sleep(hwif, WAIT_WORSTCASE, 0)) {
                printk(KERN_CONT "failed (timeout)\n");
                return;
        }
@@ -542,11 +532,6 @@ static void enable_nest (ide_drive_t *drive)
                printk(KERN_CONT "failed (status = 0x%02x)\n", stat);
        else
                printk(KERN_CONT "success\n");
-
-       /* if !(success||timed-out) */
-       if (do_probe(drive, ATA_CMD_ID_ATA) >= 2)
-               /* look for ATAPI device */
-               (void)do_probe(drive, ATA_CMD_ID_ATAPI);
 }
 
 /**
@@ -574,7 +559,7 @@ static inline u8 probe_for_drive (ide_drive_t *drive)
         *      Also note that 0 everywhere means "can't do X"
         */
  
-       drive->id = kzalloc(SECTOR_WORDS *4, GFP_KERNEL);
+       drive->id = kzalloc(SECTOR_SIZE, GFP_KERNEL);
        drive->id_read = 0;
        if(drive->id == NULL)
        {
@@ -586,19 +571,22 @@ static inline u8 probe_for_drive (ide_drive_t *drive)
        strcpy(m, "UNKNOWN");
 
        /* skip probing? */
-       if (!drive->noprobe)
-       {
+       if (!drive->noprobe) {
+retry:
                /* if !(success||timed-out) */
                if (do_probe(drive, ATA_CMD_ID_ATA) >= 2)
                        /* look for ATAPI device */
                        (void)do_probe(drive, ATA_CMD_ID_ATAPI);
+
                if (!drive->present)
                        /* drive not found */
                        return 0;
 
-               if (strstr(m, "E X A B Y T E N E S T"))
+               if (strstr(m, "E X A B Y T E N E S T")) {
                        enable_nest(drive);
-       
+                       goto retry;
+               }
+
                /* identification failed? */
                if (!drive->id_read) {
                        if (drive->media == ide_disk) {
@@ -859,7 +847,6 @@ static void ide_port_tune_devices(ide_hwif_t *hwif)
        }
 }
 
-#if MAX_HWIFS > 1
 /*
  * save_match() is used to simplify logic in init_irq() below.
  *
@@ -884,7 +871,6 @@ static void save_match(ide_hwif_t *hwif, ide_hwif_t *new, ide_hwif_t **match)
        if (!m || m->irq != hwif->irq) /* don't undo a prior perfect match */
                *match = new;
 }
-#endif /* MAX_HWIFS > 1 */
 
 /*
  * init request queue
@@ -1039,14 +1025,9 @@ static int init_irq (ide_hwif_t *hwif)
        ide_hwgroup_t *hwgroup;
        ide_hwif_t *match = NULL;
 
-
-       BUG_ON(in_interrupt());
-       BUG_ON(irqs_disabled());        
-       BUG_ON(hwif == NULL);
-
        mutex_lock(&ide_cfg_mtx);
        hwif->hwgroup = NULL;
-#if MAX_HWIFS > 1
+
        /*
         * Group up with any other hwifs that share our irq(s).
         */
@@ -1071,7 +1052,7 @@ static int init_irq (ide_hwif_t *hwif)
                        }
                }
        }
-#endif /* MAX_HWIFS > 1 */
+
        /*
         * If we are still without a hwgroup, then form a new one
         */
@@ -1118,7 +1099,8 @@ static int init_irq (ide_hwif_t *hwif)
                sa = IRQF_SHARED;
 #endif /* __mc68000__ */
 
-               if (IDE_CHIPSET_IS_PCI(hwif->chipset))
+               if (hwif->chipset == ide_pci || hwif->chipset == ide_cmd646 ||
+                   hwif->chipset == ide_ali14xx)
                        sa = IRQF_SHARED;
 
                if (io_ports->ctl_addr)
@@ -1346,8 +1328,6 @@ static void hwif_register_devices(ide_hwif_t *hwif)
                if (!drive->present)
                        continue;
 
-               ide_add_generic_settings(drive);
-
                snprintf(dev->bus_id, BUS_ID_SIZE, "%u.%u", hwif->index, i);
                dev->parent = &hwif->gendev;
                dev->bus = &ide_bus_type;
@@ -1531,19 +1511,14 @@ static int ide_find_port_slot(const struct ide_port_info *d)
         * ports 0x1f0/0x170 (the ide0/ide1 defaults).
         */
        mutex_lock(&ide_cfg_mtx);
-       if (MAX_HWIFS == 1) {
-               if (ide_indexes == 0 && i == 0)
-                       idx = 1;
+       if (bootable) {
+               if ((ide_indexes | i) != (1 << MAX_HWIFS) - 1)
+                       idx = ffz(ide_indexes | i);
        } else {
-               if (bootable) {
-                       if ((ide_indexes | i) != (1 << MAX_HWIFS) - 1)
-                               idx = ffz(ide_indexes | i);
-               } else {
-                       if ((ide_indexes | 3) != (1 << MAX_HWIFS) - 1)
-                               idx = ffz(ide_indexes | 3);
-                       else if ((ide_indexes & 3) != 3)
-                               idx = ffz(ide_indexes);
-               }
+               if ((ide_indexes | 3) != (1 << MAX_HWIFS) - 1)
+                       idx = ffz(ide_indexes | 3);
+               else if ((ide_indexes & 3) != 3)
+                       idx = ffz(ide_indexes);
        }
        if (idx >= 0)
                ide_indexes |= (1 << idx);
@@ -1604,8 +1579,10 @@ struct ide_host *ide_host_alloc_all(const struct ide_port_info *d,
        if (hws[0])
                host->dev[0] = hws[0]->dev;
 
-       if (d)
+       if (d) {
+               host->init_chipset = d->init_chipset;
                host->host_flags = d->host_flags;
+       }
 
        return host;
 }