Merge branch 'core/topology' of git://git.kernel.org/pub/scm/linux/kernel/git/tip...
[pandora-kernel.git] / drivers / ide / ide.c
index 78e49e8..300431d 100644 (file)
@@ -287,7 +287,7 @@ EXPORT_SYMBOL_GPL(ide_port_unregister_devices);
 
 /**
  *     ide_unregister          -       free an IDE interface
- *     @index: index of interface (will change soon to a pointer)
+ *     @hwif: IDE interface
  *
  *     Perform the final unregister of an IDE interface. At the moment
  *     we don't refcount interfaces so this will also get split up.
@@ -307,24 +307,22 @@ EXPORT_SYMBOL_GPL(ide_port_unregister_devices);
  *     This is raving bonkers.
  */
 
-void ide_unregister(unsigned int index)
+void ide_unregister(ide_hwif_t *hwif)
 {
-       ide_hwif_t *hwif, *g;
+       ide_hwif_t *g;
        ide_hwgroup_t *hwgroup;
        int irq_count = 0;
 
-       BUG_ON(index >= MAX_HWIFS);
-
        BUG_ON(in_interrupt());
        BUG_ON(irqs_disabled());
+
        mutex_lock(&ide_cfg_mtx);
-       spin_lock_irq(&ide_lock);
-       hwif = &ide_hwifs[index];
-       if (!hwif->present)
-               goto abort;
-       __ide_port_unregister_devices(hwif);
-       hwif->present = 0;
 
+       spin_lock_irq(&ide_lock);
+       if (hwif->present) {
+               __ide_port_unregister_devices(hwif);
+               hwif->present = 0;
+       }
        spin_unlock_irq(&ide_lock);
 
        ide_proc_unregister_port(hwif);
@@ -354,16 +352,15 @@ void ide_unregister(unsigned int index)
        blk_unregister_region(MKDEV(hwif->major, 0), MAX_DRIVES<<PARTN_BITS);
        kfree(hwif->sg_table);
        unregister_blkdev(hwif->major, hwif->name);
-       spin_lock_irq(&ide_lock);
 
        if (hwif->dma_base)
                ide_release_dma_engine(hwif);
 
+       spin_lock_irq(&ide_lock);
        /* restore hwif data to pristine status */
-       ide_init_port_data(hwif, index);
-
-abort:
+       ide_init_port_data(hwif, hwif->index);
        spin_unlock_irq(&ide_lock);
+
        mutex_unlock(&ide_cfg_mtx);
 }
 
@@ -371,7 +368,7 @@ EXPORT_SYMBOL(ide_unregister);
 
 void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw)
 {
-       memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports));
+       memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports));
        hwif->irq = hw->irq;
        hwif->chipset = hw->chipset;
        hwif->gendev.parent = hw->dev;
@@ -567,7 +564,7 @@ static int generic_ide_suspend(struct device *dev, pm_message_t mesg)
        if (!(drive->dn % 2))
                ide_acpi_get_timing(hwif);
 
-       memset(&rq, 0, sizeof(rq));
+       blk_rq_init(NULL, &rq);
        memset(&rqpm, 0, sizeof(rqpm));
        memset(&args, 0, sizeof(args));
        rq.cmd_type = REQ_TYPE_PM_SUSPEND;
@@ -605,7 +602,7 @@ static int generic_ide_resume(struct device *dev)
 
        ide_acpi_exec_tfs(drive);
 
-       memset(&rq, 0, sizeof(rq));
+       blk_rq_init(NULL, &rq);
        memset(&rqpm, 0, sizeof(rqpm));
        memset(&args, 0, sizeof(args));
        rq.cmd_type = REQ_TYPE_PM_RESUME;
@@ -1097,13 +1094,6 @@ struct bus_type ide_bus_type = {
 
 EXPORT_SYMBOL_GPL(ide_bus_type);
 
-static void ide_port_class_release(struct device *portdev)
-{
-       ide_hwif_t *hwif = dev_get_drvdata(portdev);
-
-       put_device(&hwif->gendev);
-}
-
 int ide_vlb_clk;
 EXPORT_SYMBOL_GPL(ide_vlb_clk);
 
@@ -1308,7 +1298,6 @@ static int __init ide_init(void)
                ret = PTR_ERR(ide_port_class);
                goto out_port_class;
        }
-       ide_port_class->dev_release = ide_port_class_release;
 
        init_ide_data();
 
@@ -1349,11 +1338,6 @@ int __init init_module (void)
 
 void __exit cleanup_module (void)
 {
-       int index;
-
-       for (index = 0; index < MAX_HWIFS; ++index)
-               ide_unregister(index);
-
        proc_ide_destroy();
 
        class_destroy(ide_port_class);