]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/ide/ide.c
ide: move ide_arm_init() call from init_ide_data() to ide_init()
[mirror_ubuntu-bionic-kernel.git] / drivers / ide / ide.c
index c6d4f630e18a4fd44b6b98438aa3770f28085774..77af743425e813cd695dd17f92a209ee5bc5c162 100644 (file)
@@ -116,7 +116,7 @@ EXPORT_SYMBOL(ide_hwifs);
 /*
  * Do not even *think* about calling this!
  */
-static void init_hwif_data(ide_hwif_t *hwif, unsigned int index)
+void ide_init_port_data(ide_hwif_t *hwif, unsigned int index)
 {
        unsigned int unit;
 
@@ -159,6 +159,7 @@ static void init_hwif_data(ide_hwif_t *hwif, unsigned int index)
                init_completion(&drive->gendev_rel_comp);
        }
 }
+EXPORT_SYMBOL_GPL(ide_init_port_data);
 
 static void init_hwif_default(ide_hwif_t *hwif, unsigned int index)
 {
@@ -210,16 +211,13 @@ static void __init init_ide_data (void)
        /* Initialise all interface structures */
        for (index = 0; index < MAX_HWIFS; ++index) {
                hwif = &ide_hwifs[index];
-               init_hwif_data(hwif, index);
+               ide_init_port_data(hwif, index);
                init_hwif_default(hwif, index);
 #if !defined(CONFIG_PPC32) || !defined(CONFIG_PCI)
                hwif->irq =
                        ide_init_default_irq(hwif->io_ports[IDE_DATA_OFFSET]);
 #endif
        }
-#ifdef CONFIG_IDE_ARM
-       ide_arm_init();
-#endif
 }
 
 /**
@@ -414,8 +412,6 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif)
        hwif->cds                       = tmp_hwif->cds;
 #endif
 
-       hwif->fixup                     = tmp_hwif->fixup;
-
        hwif->set_pio_mode              = tmp_hwif->set_pio_mode;
        hwif->set_dma_mode              = tmp_hwif->set_dma_mode;
        hwif->mdma_filter               = tmp_hwif->mdma_filter;
@@ -433,16 +429,13 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif)
        hwif->atapi_input_bytes         = tmp_hwif->atapi_input_bytes;
        hwif->atapi_output_bytes        = tmp_hwif->atapi_output_bytes;
 
+       hwif->dma_host_set              = tmp_hwif->dma_host_set;
        hwif->dma_setup                 = tmp_hwif->dma_setup;
        hwif->dma_exec_cmd              = tmp_hwif->dma_exec_cmd;
        hwif->dma_start                 = tmp_hwif->dma_start;
        hwif->ide_dma_end               = tmp_hwif->ide_dma_end;
-       hwif->ide_dma_on                = tmp_hwif->ide_dma_on;
-       hwif->dma_off_quietly           = tmp_hwif->dma_off_quietly;
        hwif->ide_dma_test_irq          = tmp_hwif->ide_dma_test_irq;
        hwif->ide_dma_clear_irq         = tmp_hwif->ide_dma_clear_irq;
-       hwif->dma_host_on               = tmp_hwif->dma_host_on;
-       hwif->dma_host_off              = tmp_hwif->dma_host_off;
        hwif->dma_lost_irq              = tmp_hwif->dma_lost_irq;
        hwif->dma_timeout               = tmp_hwif->dma_timeout;
 
@@ -614,7 +607,7 @@ void ide_unregister(unsigned int index)
        tmp_hwif = *hwif;
 
        /* restore hwif data to pristine status */
-       init_hwif_data(hwif, index);
+       ide_init_port_data(hwif, index);
        init_hwif_default(hwif, index);
 
        ide_hwif_restore(hwif, &tmp_hwif);
@@ -680,24 +673,34 @@ void ide_setup_ports (    hw_regs_t *hw,
  */
 }
 
+void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw)
+{
+       memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports));
+       hwif->irq = hw->irq;
+       hwif->noprobe = 0;
+       hwif->chipset = hw->chipset;
+       hwif->gendev.parent = hw->dev;
+       hwif->ack_intr = hw->ack_intr;
+}
+EXPORT_SYMBOL_GPL(ide_init_port_hw);
+
 /**
  *     ide_register_hw         -       register IDE interface
  *     @hw: hardware registers
- *     @fixup: fixup function
- *     @initializing: set while initializing built-in drivers
+ *     @quirkproc: quirkproc function
  *     @hwifp: pointer to returned hwif
  *
  *     Register an IDE interface, specifying exactly the registers etc.
- *     Set init=1 iff calling before probes have taken place.
  *
  *     Returns -1 on error.
  */
 
-int ide_register_hw(hw_regs_t *hw, void (*fixup)(ide_hwif_t *),
-                   int initializing, ide_hwif_t **hwifp)
+int ide_register_hw(hw_regs_t *hw, void (*quirkproc)(ide_drive_t *),
+                   ide_hwif_t **hwifp)
 {
        int index, retry = 1;
        ide_hwif_t *hwif;
+       u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
 
        do {
                for (index = 0; index < MAX_HWIFS; ++index) {
@@ -709,8 +712,7 @@ int ide_register_hw(hw_regs_t *hw, void (*fixup)(ide_hwif_t *),
                        hwif = &ide_hwifs[index];
                        if (hwif->hold)
                                continue;
-                       if ((!hwif->present && !hwif->mate && !initializing) ||
-                           (!hwif->io_ports[IDE_DATA_OFFSET] && initializing))
+                       if (!hwif->present && hwif->mate == NULL)
                                goto found;
                }
                for (index = 0; index < MAX_HWIFS; index++)
@@ -721,29 +723,23 @@ found:
        if (hwif->present)
                ide_unregister(index);
        else if (!hwif->hold) {
-               init_hwif_data(hwif, index);
+               ide_init_port_data(hwif, index);
                init_hwif_default(hwif, index);
        }
        if (hwif->present)
                return -1;
-       memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports));
-       hwif->irq = hw->irq;
-       hwif->noprobe = 0;
-       hwif->fixup = fixup;
-       hwif->chipset = hw->chipset;
-       hwif->gendev.parent = hw->dev;
-       hwif->ack_intr = hw->ack_intr;
 
-       if (initializing == 0) {
-               u8 idx[4] = { index, 0xff, 0xff, 0xff };
+       ide_init_port_hw(hwif, hw);
+       hwif->quirkproc = quirkproc;
 
-               ide_device_add(idx);
-       }
+       idx[0] = index;
+
+       ide_device_add(idx);
 
        if (hwifp)
                *hwifp = hwif;
 
-       return (initializing || hwif->present) ? index : -1;
+       return hwif->present ? index : -1;
 }
 
 EXPORT_SYMBOL(ide_register_hw);
@@ -836,7 +832,7 @@ int set_using_dma(ide_drive_t *drive, int arg)
        if (!drive->id || !(drive->id->capability & 1))
                goto out;
 
-       if (hwif->ide_dma_on == NULL)
+       if (hwif->dma_host_set == NULL)
                goto out;
 
        err = -EBUSY;
@@ -1066,7 +1062,7 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device
                        ide_init_hwif_ports(&hw, (unsigned long) args[0],
                                            (unsigned long) args[1], NULL);
                        hw.irq = args[2];
-                       if (ide_register_hw(&hw, NULL, 0, NULL) == -1)
+                       if (ide_register_hw(&hw, NULL, NULL) == -1)
                                return -EIO;
                        return 0;
                }
@@ -1775,6 +1771,9 @@ static int __init ide_init(void)
 
        proc_ide_create();
 
+#ifdef CONFIG_IDE_ARM
+       ide_arm_init();
+#endif
 #ifdef CONFIG_BLK_DEV_ALI14XX
        if (probe_ali14xx)
                (void)ali14xx_init();