Commit 10cba765 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz Committed by Linus Torvalds

[PATCH] ide.c: use less stack in ide_unregister()

From: Chris Wedgwood <cw@f00f.org>

Seperate function, cruft removed and old_hwif
renamed to something less confusing.
parent 7b4ac0ae
......@@ -585,6 +585,102 @@ void ide_hwif_release_regions(ide_hwif_t *hwif)
EXPORT_SYMBOL(ide_hwif_release_regions);
/* restore hwif to a sane state */
static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif)
{
hwif->hwgroup = tmp_hwif->hwgroup;
hwif->gendev.parent = tmp_hwif->gendev.parent;
hwif->proc = tmp_hwif->proc;
hwif->major = tmp_hwif->major;
hwif->straight8 = tmp_hwif->straight8;
hwif->bus_state = tmp_hwif->bus_state;
hwif->atapi_dma = tmp_hwif->atapi_dma;
hwif->ultra_mask = tmp_hwif->ultra_mask;
hwif->mwdma_mask = tmp_hwif->mwdma_mask;
hwif->swdma_mask = tmp_hwif->swdma_mask;
hwif->chipset = tmp_hwif->chipset;
hwif->hold = tmp_hwif->hold;
#ifdef CONFIG_BLK_DEV_IDEPCI
hwif->pci_dev = tmp_hwif->pci_dev;
hwif->cds = tmp_hwif->cds;
#endif
hwif->identify = tmp_hwif->identify;
hwif->tuneproc = tmp_hwif->tuneproc;
hwif->speedproc = tmp_hwif->speedproc;
hwif->selectproc = tmp_hwif->selectproc;
hwif->reset_poll = tmp_hwif->reset_poll;
hwif->pre_reset = tmp_hwif->pre_reset;
hwif->resetproc = tmp_hwif->resetproc;
hwif->intrproc = tmp_hwif->intrproc;
hwif->maskproc = tmp_hwif->maskproc;
hwif->quirkproc = tmp_hwif->quirkproc;
hwif->busproc = tmp_hwif->busproc;
hwif->ata_input_data = tmp_hwif->ata_input_data;
hwif->ata_output_data = tmp_hwif->ata_output_data;
hwif->atapi_input_bytes = tmp_hwif->atapi_input_bytes;
hwif->atapi_output_bytes = tmp_hwif->atapi_output_bytes;
hwif->ide_dma_read = tmp_hwif->ide_dma_read;
hwif->ide_dma_write = tmp_hwif->ide_dma_write;
hwif->ide_dma_begin = tmp_hwif->ide_dma_begin;
hwif->ide_dma_end = tmp_hwif->ide_dma_end;
hwif->ide_dma_check = tmp_hwif->ide_dma_check;
hwif->ide_dma_on = tmp_hwif->ide_dma_on;
hwif->ide_dma_off_quietly = tmp_hwif->ide_dma_off_quietly;
hwif->ide_dma_test_irq = tmp_hwif->ide_dma_test_irq;
hwif->ide_dma_host_on = tmp_hwif->ide_dma_host_on;
hwif->ide_dma_host_off = tmp_hwif->ide_dma_host_off;
hwif->ide_dma_verbose = tmp_hwif->ide_dma_verbose;
hwif->ide_dma_lostirq = tmp_hwif->ide_dma_lostirq;
hwif->ide_dma_timeout = tmp_hwif->ide_dma_timeout;
hwif->OUTB = tmp_hwif->OUTB;
hwif->OUTBSYNC = tmp_hwif->OUTBSYNC;
hwif->OUTW = tmp_hwif->OUTW;
hwif->OUTL = tmp_hwif->OUTL;
hwif->OUTSW = tmp_hwif->OUTSW;
hwif->OUTSL = tmp_hwif->OUTSL;
hwif->INB = tmp_hwif->INB;
hwif->INW = tmp_hwif->INW;
hwif->INL = tmp_hwif->INL;
hwif->INSW = tmp_hwif->INSW;
hwif->INSL = tmp_hwif->INSL;
hwif->mmio = tmp_hwif->mmio;
hwif->rqsize = tmp_hwif->rqsize;
hwif->no_lba48 = tmp_hwif->no_lba48;
#ifndef CONFIG_BLK_DEV_IDECS
hwif->irq = tmp_hwif->irq;
#endif
hwif->dma_base = tmp_hwif->dma_base;
hwif->dma_master = tmp_hwif->dma_master;
hwif->dma_command = tmp_hwif->dma_command;
hwif->dma_vendor1 = tmp_hwif->dma_vendor1;
hwif->dma_status = tmp_hwif->dma_status;
hwif->dma_vendor3 = tmp_hwif->dma_vendor3;
hwif->dma_prdtable = tmp_hwif->dma_prdtable;
hwif->dma_extra = tmp_hwif->dma_extra;
hwif->config_data = tmp_hwif->config_data;
hwif->select_data = tmp_hwif->select_data;
hwif->autodma = tmp_hwif->autodma;
hwif->udma_four = tmp_hwif->udma_four;
hwif->no_dsc = tmp_hwif->no_dsc;
hwif->hwif_data = tmp_hwif->hwif_data;
}
/**
* ide_unregister - free an ide interface
* @index: index of interface (will change soon to a pointer)
......@@ -606,18 +702,22 @@ EXPORT_SYMBOL(ide_hwif_release_regions);
* Unregister restores the hwif structures to the default state.
* This is raving bonkers.
*/
void ide_unregister (unsigned int index)
void ide_unregister(unsigned int index)
{
ide_drive_t *drive;
ide_hwif_t *hwif, *g;
ide_hwif_t *hwif, *g, *tmp_hwif;
ide_hwgroup_t *hwgroup;
int irq_count = 0, unit, i;
ide_hwif_t old_hwif;
if (index >= MAX_HWIFS)
BUG();
BUG_ON(index >= MAX_HWIFS);
tmp_hwif = kmalloc(sizeof(*tmp_hwif), GFP_KERNEL|__GFP_NOFAIL);
if (!tmp_hwif) {
printk(KERN_ERR "%s: unable to allocate memory\n", __FUNCTION__);
return;
}
BUG_ON(in_interrupt());
BUG_ON(irqs_disabled());
down(&ide_cfg_sem);
......@@ -634,7 +734,7 @@ void ide_unregister (unsigned int index)
drive->dead = 1;
}
hwif->present = 0;
spin_unlock_irq(&ide_lock);
for (unit = 0; unit < MAX_DRIVES; ++unit) {
......@@ -643,7 +743,7 @@ void ide_unregister (unsigned int index)
continue;
DRIVER(drive)->cleanup(drive);
}
#ifdef CONFIG_PROC_FS
destroy_proc_ide_drives(hwif);
#endif
......@@ -763,122 +863,20 @@ void ide_unregister (unsigned int index)
hwif->dma_prdtable = 0;
}
old_hwif = *hwif;
/* copy original settings */
*tmp_hwif = *hwif;
init_hwif_data(hwif, index); /* restore hwif data to pristine status */
/* restore hwif data to pristine status */
init_hwif_data(hwif, index);
init_hwif_default(hwif, index);
hwif->hwgroup = old_hwif.hwgroup;
hwif->gendev.parent = old_hwif.gendev.parent;
hwif->proc = old_hwif.proc;
hwif->major = old_hwif.major;
// hwif->index = old_hwif.index;
// hwif->channel = old_hwif.channel;
hwif->straight8 = old_hwif.straight8;
hwif->bus_state = old_hwif.bus_state;
hwif->atapi_dma = old_hwif.atapi_dma;
hwif->ultra_mask = old_hwif.ultra_mask;
hwif->mwdma_mask = old_hwif.mwdma_mask;
hwif->swdma_mask = old_hwif.swdma_mask;
hwif->chipset = old_hwif.chipset;
hwif->hold = old_hwif.hold;
#ifdef CONFIG_BLK_DEV_IDEPCI
hwif->pci_dev = old_hwif.pci_dev;
hwif->cds = old_hwif.cds;
#endif /* CONFIG_BLK_DEV_IDEPCI */
#if 0
hwif->hwifops = old_hwif.hwifops;
#else
hwif->identify = old_hwif.identify;
hwif->tuneproc = old_hwif.tuneproc;
hwif->speedproc = old_hwif.speedproc;
hwif->selectproc = old_hwif.selectproc;
hwif->reset_poll = old_hwif.reset_poll;
hwif->pre_reset = old_hwif.pre_reset;
hwif->resetproc = old_hwif.resetproc;
hwif->intrproc = old_hwif.intrproc;
hwif->maskproc = old_hwif.maskproc;
hwif->quirkproc = old_hwif.quirkproc;
hwif->busproc = old_hwif.busproc;
#endif
#if 0
hwif->pioops = old_hwif.pioops;
#else
hwif->ata_input_data = old_hwif.ata_input_data;
hwif->ata_output_data = old_hwif.ata_output_data;
hwif->atapi_input_bytes = old_hwif.atapi_input_bytes;
hwif->atapi_output_bytes = old_hwif.atapi_output_bytes;
#endif
ide_hwif_restore(hwif, tmp_hwif);
#if 0
hwif->dmaops = old_hwif.dmaops;
#else
hwif->ide_dma_read = old_hwif.ide_dma_read;
hwif->ide_dma_write = old_hwif.ide_dma_write;
hwif->ide_dma_begin = old_hwif.ide_dma_begin;
hwif->ide_dma_end = old_hwif.ide_dma_end;
hwif->ide_dma_check = old_hwif.ide_dma_check;
hwif->ide_dma_on = old_hwif.ide_dma_on;
hwif->ide_dma_off_quietly = old_hwif.ide_dma_off_quietly;
hwif->ide_dma_test_irq = old_hwif.ide_dma_test_irq;
hwif->ide_dma_host_on = old_hwif.ide_dma_host_on;
hwif->ide_dma_host_off = old_hwif.ide_dma_host_off;
hwif->ide_dma_verbose = old_hwif.ide_dma_verbose;
hwif->ide_dma_lostirq = old_hwif.ide_dma_lostirq;
hwif->ide_dma_timeout = old_hwif.ide_dma_timeout;
#endif
#if 0
hwif->iops = old_hwif.iops;
#else
hwif->OUTB = old_hwif.OUTB;
hwif->OUTBSYNC = old_hwif.OUTBSYNC;
hwif->OUTW = old_hwif.OUTW;
hwif->OUTL = old_hwif.OUTL;
hwif->OUTSW = old_hwif.OUTSW;
hwif->OUTSL = old_hwif.OUTSL;
hwif->INB = old_hwif.INB;
hwif->INW = old_hwif.INW;
hwif->INL = old_hwif.INL;
hwif->INSW = old_hwif.INSW;
hwif->INSL = old_hwif.INSL;
#endif
hwif->mmio = old_hwif.mmio;
hwif->rqsize = old_hwif.rqsize;
hwif->no_lba48 = old_hwif.no_lba48;
#ifndef CONFIG_BLK_DEV_IDECS
hwif->irq = old_hwif.irq;
#endif /* CONFIG_BLK_DEV_IDECS */
hwif->dma_base = old_hwif.dma_base;
hwif->dma_master = old_hwif.dma_master;
hwif->dma_command = old_hwif.dma_command;
hwif->dma_vendor1 = old_hwif.dma_vendor1;
hwif->dma_status = old_hwif.dma_status;
hwif->dma_vendor3 = old_hwif.dma_vendor3;
hwif->dma_prdtable = old_hwif.dma_prdtable;
hwif->dma_extra = old_hwif.dma_extra;
hwif->config_data = old_hwif.config_data;
hwif->select_data = old_hwif.select_data;
hwif->autodma = old_hwif.autodma;
hwif->udma_four = old_hwif.udma_four;
hwif->no_dsc = old_hwif.no_dsc;
hwif->hwif_data = old_hwif.hwif_data;
abort:
spin_unlock_irq(&ide_lock);
up(&ide_cfg_sem);
kfree(tmp_hwif);
}
EXPORT_SYMBOL(ide_unregister);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment