ide: add 'init_default' and 'restore' arguments to ide_unregister()

* Add 'init_default' (flag for calling init_hwif_default()) and 'restore'
  (flag for calling ide_hwif_restore()) arguments to ide_unregister().

* Update ide_unregister() users to set 'init_default' and 'restore' flags.

* No need to set 'init_default' flag in ide_register_hw() if the setup done
  by init_hwif_default() is going to be overridden by ide_init_port_hw().

* No need to set 'init_default' and 'restore' flags in cleanup_module().

There should be no functionality changes caused by this patch.
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent ead741df
...@@ -76,7 +76,7 @@ static void __devexit rapide_remove(struct expansion_card *ec) ...@@ -76,7 +76,7 @@ static void __devexit rapide_remove(struct expansion_card *ec)
ecard_set_drvdata(ec, NULL); ecard_set_drvdata(ec, NULL);
ide_unregister(hwif->index); ide_unregister(hwif->index, 1, 1);
ecard_release_resources(ec); ecard_release_resources(ec);
} }
......
...@@ -60,9 +60,10 @@ static int idepnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id ...@@ -60,9 +60,10 @@ static int idepnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id
static void idepnp_remove(struct pnp_dev * dev) static void idepnp_remove(struct pnp_dev * dev)
{ {
ide_hwif_t *hwif = pnp_get_drvdata(dev); ide_hwif_t *hwif = pnp_get_drvdata(dev);
if (hwif) {
ide_unregister(hwif->index); if (hwif)
} else ide_unregister(hwif->index, 1, 1);
else
printk(KERN_ERR "idepnp: Unable to remove device, please report.\n"); printk(KERN_ERR "idepnp: Unable to remove device, please report.\n");
} }
......
...@@ -499,6 +499,8 @@ void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) ...@@ -499,6 +499,8 @@ void ide_remove_port_from_hwgroup(ide_hwif_t *hwif)
/** /**
* ide_unregister - free an IDE interface * ide_unregister - free an IDE interface
* @index: index of interface (will change soon to a pointer) * @index: index of interface (will change soon to a pointer)
* @init_default: init default hwif flag
* @restore: restore hwif flag
* *
* Perform the final unregister of an IDE interface. At the moment * Perform the final unregister of an IDE interface. At the moment
* we don't refcount interfaces so this will also get split up. * we don't refcount interfaces so this will also get split up.
...@@ -518,7 +520,7 @@ void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) ...@@ -518,7 +520,7 @@ void ide_remove_port_from_hwgroup(ide_hwif_t *hwif)
* This is raving bonkers. * This is raving bonkers.
*/ */
void ide_unregister(unsigned int index) void ide_unregister(unsigned int index, int init_default, int restore)
{ {
ide_drive_t *drive; ide_drive_t *drive;
ide_hwif_t *hwif, *g; ide_hwif_t *hwif, *g;
...@@ -602,8 +604,11 @@ void ide_unregister(unsigned int index) ...@@ -602,8 +604,11 @@ void ide_unregister(unsigned int index)
/* restore hwif data to pristine status */ /* restore hwif data to pristine status */
ide_init_port_data(hwif, index); ide_init_port_data(hwif, index);
if (init_default)
init_hwif_default(hwif, index); init_hwif_default(hwif, index);
if (restore)
ide_hwif_restore(hwif, &tmp_hwif); ide_hwif_restore(hwif, &tmp_hwif);
abort: abort:
...@@ -710,12 +715,12 @@ int ide_register_hw(hw_regs_t *hw, void (*quirkproc)(ide_drive_t *), ...@@ -710,12 +715,12 @@ int ide_register_hw(hw_regs_t *hw, void (*quirkproc)(ide_drive_t *),
goto found; goto found;
} }
for (index = 0; index < MAX_HWIFS; index++) for (index = 0; index < MAX_HWIFS; index++)
ide_unregister(index); ide_unregister(index, 1, 1);
} while (retry--); } while (retry--);
return -1; return -1;
found: found:
if (hwif->present) if (hwif->present)
ide_unregister(index); ide_unregister(index, 0, 1);
else if (!hwif->hold) else if (!hwif->hold)
ide_init_port_data(hwif, index); ide_init_port_data(hwif, index);
...@@ -1058,7 +1063,7 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device ...@@ -1058,7 +1063,7 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device
case HDIO_UNREGISTER_HWIF: case HDIO_UNREGISTER_HWIF:
if (!capable(CAP_SYS_RAWIO)) return -EACCES; if (!capable(CAP_SYS_RAWIO)) return -EACCES;
/* (arg > MAX_HWIFS) checked in function */ /* (arg > MAX_HWIFS) checked in function */
ide_unregister(arg); ide_unregister(arg, 1, 1);
return 0; return 0;
case HDIO_SET_NICE: case HDIO_SET_NICE:
if (!capable(CAP_SYS_ADMIN)) return -EACCES; if (!capable(CAP_SYS_ADMIN)) return -EACCES;
...@@ -1703,7 +1708,7 @@ void __exit cleanup_module (void) ...@@ -1703,7 +1708,7 @@ void __exit cleanup_module (void)
int index; int index;
for (index = 0; index < MAX_HWIFS; ++index) for (index = 0; index < MAX_HWIFS; ++index)
ide_unregister(index); ide_unregister(index, 0, 0);
proc_ide_destroy(); proc_ide_destroy();
......
...@@ -337,7 +337,7 @@ void ide_release(struct pcmcia_device *link) ...@@ -337,7 +337,7 @@ void ide_release(struct pcmcia_device *link)
if (info->ndev) { if (info->ndev) {
/* FIXME: if this fails we need to queue the cleanup somehow /* FIXME: if this fails we need to queue the cleanup somehow
-- need to investigate the required PCMCIA magic */ -- need to investigate the required PCMCIA magic */
ide_unregister(info->hd); ide_unregister(info->hd, 1, 1);
} }
info->ndev = 0; info->ndev = 0;
......
...@@ -122,7 +122,7 @@ static int __devexit plat_ide_remove(struct platform_device *pdev) ...@@ -122,7 +122,7 @@ static int __devexit plat_ide_remove(struct platform_device *pdev)
{ {
ide_hwif_t *hwif = pdev->dev.driver_data; ide_hwif_t *hwif = pdev->dev.driver_data;
ide_unregister(hwif->index); ide_unregister(hwif->index, 1, 1);
return 0; return 0;
} }
......
...@@ -678,7 +678,7 @@ static int au_ide_remove(struct device *dev) ...@@ -678,7 +678,7 @@ static int au_ide_remove(struct device *dev)
ide_hwif_t *hwif = dev_get_drvdata(dev); ide_hwif_t *hwif = dev_get_drvdata(dev);
_auide_hwif *ahwif = &auide_hwif; _auide_hwif *ahwif = &auide_hwif;
ide_unregister(hwif->index); ide_unregister(hwif->index, 1, 1);
iounmap((void *)ahwif->regbase); iounmap((void *)ahwif->regbase);
......
...@@ -99,7 +99,8 @@ delkin_cb_remove (struct pci_dev *dev) ...@@ -99,7 +99,8 @@ delkin_cb_remove (struct pci_dev *dev)
ide_hwif_t *hwif = pci_get_drvdata(dev); ide_hwif_t *hwif = pci_get_drvdata(dev);
if (hwif) if (hwif)
ide_unregister(hwif->index); ide_unregister(hwif->index, 1, 1);
pci_disable_device(dev); pci_disable_device(dev);
} }
......
...@@ -736,7 +736,7 @@ static void __devexit scc_remove(struct pci_dev *dev) ...@@ -736,7 +736,7 @@ static void __devexit scc_remove(struct pci_dev *dev)
hwif->dmatable_cpu = NULL; hwif->dmatable_cpu = NULL;
} }
ide_unregister(hwif->index); ide_unregister(hwif->index, 1, 1);
hwif->chipset = ide_unknown; hwif->chipset = ide_unknown;
iounmap((void*)ports->dma); iounmap((void*)ports->dma);
......
...@@ -595,7 +595,7 @@ static void media_bay_step(int i) ...@@ -595,7 +595,7 @@ static void media_bay_step(int i)
if (bay->cd_index >= 0) { if (bay->cd_index >= 0) {
printk(KERN_DEBUG "Unregistering mb %d ide, index:%d\n", i, printk(KERN_DEBUG "Unregistering mb %d ide, index:%d\n", i,
bay->cd_index); bay->cd_index);
ide_unregister(bay->cd_index); ide_unregister(bay->cd_index, 1, 1);
bay->cd_index = -1; bay->cd_index = -1;
} }
if (bay->cd_retry) { if (bay->cd_retry) {
......
...@@ -1208,7 +1208,7 @@ static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {} ...@@ -1208,7 +1208,7 @@ static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {}
void ide_remove_port_from_hwgroup(ide_hwif_t *); void ide_remove_port_from_hwgroup(ide_hwif_t *);
extern int ide_hwif_request_regions(ide_hwif_t *hwif); extern int ide_hwif_request_regions(ide_hwif_t *hwif);
extern void ide_hwif_release_regions(ide_hwif_t* hwif); extern void ide_hwif_release_regions(ide_hwif_t* hwif);
extern void ide_unregister (unsigned int index); void ide_unregister(unsigned int, int, int);
void ide_register_region(struct gendisk *); void ide_register_region(struct gendisk *);
void ide_unregister_region(struct gendisk *); void ide_unregister_region(struct gendisk *);
......
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