]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/pci/cmd640.c
Merge branches 'topic/fix/misc' and 'topic/fix/hda' into for-linus
[linux-2.6-omap-h63xx.git] / drivers / ide / pci / cmd640.c
index 1ad1e23e310577c2875994fe421e969d6c61ab55..e4306647d00d6782e8db72d40d82827bb085044f 100644 (file)
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/delay.h>
-#include <linux/hdreg.h>
 #include <linux/ide.h>
 #include <linux/init.h>
 
@@ -180,11 +179,6 @@ static u8 recovery_counts[4] = {16, 16, 16, 16}; /* Recovery count (encoded) */
 
 static DEFINE_SPINLOCK(cmd640_lock);
 
-/*
- * These are initialized to point at the devices we control
- */
-static ide_hwif_t  *cmd_hwif0, *cmd_hwif1;
-
 /*
  * Interface to access cmd640x registers
  */
@@ -380,6 +374,21 @@ static void cmd640_dump_regs(void)
 }
 #endif
 
+static void __set_prefetch_mode(ide_drive_t *drive, int mode)
+{
+       if (mode) {     /* want prefetch on? */
+#if CMD640_PREFETCH_MASKS
+               drive->dev_flags |= IDE_DFLAG_NO_UNMASK;
+               drive->dev_flags &= ~IDE_DFLAG_UNMASK;
+#endif
+               drive->dev_flags &= ~IDE_DFLAG_NO_IO_32BIT;
+       } else {
+               drive->dev_flags &= ~IDE_DFLAG_NO_UNMASK;
+               drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT;
+               drive->io_32bit = 0;
+       }
+}
+
 #ifndef CONFIG_BLK_DEV_CMD640_ENHANCED
 /*
  * Check whether prefetch is on for a drive,
@@ -389,19 +398,10 @@ static void __init check_prefetch(ide_drive_t *drive, unsigned int index)
 {
        u8 b = get_cmd640_reg(prefetch_regs[index]);
 
-       if (b & prefetch_masks[index]) {        /* is prefetch off? */
-               drive->no_unmask = 0;
-               drive->no_io_32bit = 1;
-               drive->io_32bit = 0;
-       } else {
-#if CMD640_PREFETCH_MASKS
-               drive->no_unmask = 1;
-               drive->unmask = 0;
-#endif
-               drive->no_io_32bit = 0;
-       }
+       __set_prefetch_mode(drive, (b & prefetch_masks[index]) ? 0 : 1);
 }
 #else
+
 /*
  * Sets prefetch mode for a drive.
  */
@@ -413,19 +413,11 @@ static void set_prefetch_mode(ide_drive_t *drive, unsigned int index, int mode)
 
        spin_lock_irqsave(&cmd640_lock, flags);
        b = __get_cmd640_reg(reg);
-       if (mode) {     /* want prefetch on? */
-#if CMD640_PREFETCH_MASKS
-               drive->no_unmask = 1;
-               drive->unmask = 0;
-#endif
-               drive->no_io_32bit = 0;
+       __set_prefetch_mode(drive, mode);
+       if (mode)
                b &= ~prefetch_masks[index];    /* enable prefetch */
-       } else {
-               drive->no_unmask = 0;
-               drive->no_io_32bit = 1;
-               drive->io_32bit = 0;
+       else
                b |= prefetch_masks[index];     /* disable prefetch */
-       }
        __put_cmd640_reg(reg, b);
        spin_unlock_irqrestore(&cmd640_lock, flags);
 }
@@ -476,10 +468,10 @@ static void program_drive_counts(ide_drive_t *drive, unsigned int index)
         */
        if (index > 1) {
                ide_hwif_t *hwif = drive->hwif;
-               ide_drive_t *peer = &hwif->drives[!drive->select.b.unit];
+               ide_drive_t *peer = &hwif->drives[!(drive->dn & 1)];
                unsigned int mate = index ^ 1;
 
-               if (peer->present) {
+               if (peer->dev_flags & IDE_DFLAG_PRESENT) {
                        if (setup_count < setup_counts[mate])
                                setup_count = setup_counts[mate];
                        if (active_count < active_counts[mate])
@@ -615,7 +607,7 @@ static void cmd640_set_pio_mode(ide_drive_t *drive, const u8 pio)
 
 static void cmd640_init_dev(ide_drive_t *drive)
 {
-       unsigned int i = drive->hwif->channel * 2 + drive->select.b.unit;
+       unsigned int i = drive->hwif->channel * 2 + (drive->dn & 1);
 
 #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
        /*
@@ -634,7 +626,7 @@ static void cmd640_init_dev(ide_drive_t *drive)
         */
        check_prefetch(drive, i);
        printk(KERN_INFO DRV_NAME ": drive%d timings/prefetch(%s) preserved\n",
-                                 i, drive->no_io_32bit ? "off" : "on");
+               i, (drive->dev_flags & IDE_DFLAG_NO_IO_32BIT) ? "off" : "on");
 #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
 }
 
@@ -717,8 +709,7 @@ static int __init cmd640x_init(void)
        int second_port_cmd640 = 0, rc;
        const char *bus_type, *port2;
        u8 b, cfr;
-       u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
-       hw_regs_t hw[2];
+       hw_regs_t hw[2], *hws[] = { NULL, NULL, NULL, NULL };
 
        if (cmd640_vlb && probe_for_cmd640_vlb()) {
                bus_type = "VLB";
@@ -781,15 +772,10 @@ static int __init cmd640x_init(void)
        printk(KERN_INFO "cmd640: buggy cmd640%c interface on %s, config=0x%02x"
                         "\n", 'a' + cmd640_chip_version - 1, bus_type, cfr);
 
-       cmd_hwif0 = ide_find_port();
-
        /*
         * Initialize data for primary port
         */
-       if (cmd_hwif0) {
-               ide_init_port_hw(cmd_hwif0, &hw[0]);
-               idx[0] = cmd_hwif0->index;
-       }
+       hws[0] = &hw[0];
 
        /*
         * Ensure compatibility by always using the slowest timings
@@ -829,13 +815,9 @@ static int __init cmd640x_init(void)
        /*
         * Initialize data for secondary cmd640 port, if enabled
         */
-       if (second_port_cmd640) {
-               cmd_hwif1 = ide_find_port();
-               if (cmd_hwif1) {
-                       ide_init_port_hw(cmd_hwif1, &hw[1]);
-                       idx[1] = cmd_hwif1->index;
-               }
-       }
+       if (second_port_cmd640)
+               hws[1] = &hw[1];
+
        printk(KERN_INFO "cmd640: %sserialized, secondary interface %s\n",
                         second_port_cmd640 ? "" : "not ", port2);
 
@@ -843,9 +825,7 @@ static int __init cmd640x_init(void)
        cmd640_dump_regs();
 #endif
 
-       ide_device_add(idx, &cmd640_port_info);
-
-       return 1;
+       return ide_host_add(&cmd640_port_info, hws, NULL);
 }
 
 module_param_named(probe_vlb, cmd640_vlb, bool, 0);