ide: fix ide/legacy/gayle.c compilation
[sfrench/cifs-2.6.git] / drivers / ide / legacy / gayle.c
index 0830a021bbb609d4b103dc037239a0f2ec5bc934..b7d81090d5da50e21b221ed4b1fb20a242942c33 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  linux/drivers/ide/legacy/gayle.c -- Amiga Gayle IDE Driver
+ *  Amiga Gayle IDE Driver
  *
  *     Created 9 Jul 1997 by Geert Uytterhoeven
  *
      *  Offsets from one of the above bases
      */
 
-#define GAYLE_DATA     0x00
-#define GAYLE_ERROR    0x06            /* see err-bits */
-#define GAYLE_NSECTOR  0x0a            /* nr of sectors to read/write */
-#define GAYLE_SECTOR   0x0e            /* starting sector */
-#define GAYLE_LCYL     0x12            /* starting cylinder */
-#define GAYLE_HCYL     0x16            /* high byte of starting cyl */
-#define GAYLE_SELECT   0x1a            /* 101dhhhh , d=drive, hhhh=head */
-#define GAYLE_STATUS   0x1e            /* see status-bits */
 #define GAYLE_CONTROL  0x101a
 
-static int gayle_offsets[IDE_NR_PORTS] __initdata = {
-    GAYLE_DATA, GAYLE_ERROR, GAYLE_NSECTOR, GAYLE_SECTOR, GAYLE_LCYL,
-    GAYLE_HCYL, GAYLE_SELECT, GAYLE_STATUS, -1, -1
-};
-
-
     /*
      *  These are at different offsets from the base
      */
@@ -106,16 +92,37 @@ static int gayle_ack_intr_a1200(ide_hwif_t *hwif)
     return 1;
 }
 
+static void __init gayle_setup_ports(hw_regs_t *hw, unsigned long base,
+                                    unsigned long ctl, unsigned long irq_port,
+                                    ide_ack_intr_t *ack_intr)
+{
+       int i;
+
+       memset(hw, 0, sizeof(*hw));
+
+       hw->io_ports[IDE_DATA_OFFSET] = base;
+
+       for (i = 1; i < 8; i++)
+               hw->io_ports[i] = base + 2 + i * 4;
+
+       hw->io_ports[IDE_CONTROL_OFFSET] = ctl;
+       hw->io_ports[IDE_IRQ_OFFSET] = irq_port;
+
+       hw->irq = IRQ_AMIGA_PORTS;
+       hw->ack_intr = ack_intr;
+}
+
     /*
      *  Probe for a Gayle IDE interface (and optionally for an IDE doubler)
      */
 
-void __init gayle_init(void)
+static int __init gayle_init(void)
 {
     int a4000, i;
+    u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
 
     if (!MACH_IS_AMIGA)
-       return;
+       return -ENODEV;
 
     if ((a4000 = AMIGAHW_PRESENT(A4000_IDE)) || AMIGAHW_PRESENT(A1200_IDE))
        goto found;
@@ -125,15 +132,21 @@ void __init gayle_init(void)
                          NULL))
        goto found;
 #endif
-    return;
+    return -ENODEV;
 
 found:
+       printk(KERN_INFO "ide: Gayle IDE controller (A%d style%s)\n",
+                        a4000 ? 4000 : 1200,
+#ifdef CONFIG_BLK_DEV_IDEDOUBLER
+                        ide_doubler ? ", IDE doubler" :
+#endif
+                        "");
+
     for (i = 0; i < GAYLE_NUM_PROBE_HWIFS; i++) {
        unsigned long base, ctrlport, irqport;
        ide_ack_intr_t *ack_intr;
        hw_regs_t hw;
        ide_hwif_t *hwif;
-       int index;
        unsigned long phys_base, res_start, res_n;
 
        if (a4000) {
@@ -160,26 +173,25 @@ found:
        base = (unsigned long)ZTWO_VADDR(phys_base);
        ctrlport = GAYLE_HAS_CONTROL_REG ? (base + GAYLE_CONTROL) : 0;
 
-       ide_setup_ports(&hw, base, gayle_offsets,
-                       ctrlport, irqport, ack_intr,
-//                     &gayle_iops,
-                       IRQ_AMIGA_PORTS);
+       gayle_setup_ports(&hw, base, ctrlport, irqport, ack_intr);
+
+       hwif = ide_find_port(base);
+       if (hwif) {
+           u8 index = hwif->index;
+
+           ide_init_port_data(hwif, index);
+           ide_init_port_hw(hwif, &hw);
 
-       index = ide_register_hw(&hw, 1, &hwif);
-       if (index != -1) {
            hwif->mmio = 1;
-           switch (i) {
-               case 0:
-                   printk("ide%d: Gayle IDE interface (A%d style)\n", index,
-                          a4000 ? 4000 : 1200);
-                   break;
-#ifdef CONFIG_BLK_DEV_IDEDOUBLER
-               case 1:
-                   printk("ide%d: IDE doubler\n", index);
-                   break;
-#endif /* CONFIG_BLK_DEV_IDEDOUBLER */
-           }
+
+           idx[i] = index;
        } else
            release_mem_region(res_start, res_n);
     }
+
+    ide_device_add(idx, NULL);
+
+    return 0;
 }
+
+module_init(gayle_init);