aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide.c')
-rw-r--r--drivers/ide/ide.c33
1 files changed, 11 insertions, 22 deletions
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 98bd45e8c175..3ec220b64d0b 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -116,7 +116,7 @@ EXPORT_SYMBOL(ide_hwifs);
116/* 116/*
117 * Do not even *think* about calling this! 117 * Do not even *think* about calling this!
118 */ 118 */
119static void init_hwif_data(ide_hwif_t *hwif, unsigned int index) 119void ide_init_port_data(ide_hwif_t *hwif, unsigned int index)
120{ 120{
121 unsigned int unit; 121 unsigned int unit;
122 122
@@ -159,6 +159,7 @@ static void init_hwif_data(ide_hwif_t *hwif, unsigned int index)
159 init_completion(&drive->gendev_rel_comp); 159 init_completion(&drive->gendev_rel_comp);
160 } 160 }
161} 161}
162EXPORT_SYMBOL_GPL(ide_init_port_data);
162 163
163static void init_hwif_default(ide_hwif_t *hwif, unsigned int index) 164static void init_hwif_default(ide_hwif_t *hwif, unsigned int index)
164{ 165{
@@ -210,7 +211,7 @@ static void __init init_ide_data (void)
210 /* Initialise all interface structures */ 211 /* Initialise all interface structures */
211 for (index = 0; index < MAX_HWIFS; ++index) { 212 for (index = 0; index < MAX_HWIFS; ++index) {
212 hwif = &ide_hwifs[index]; 213 hwif = &ide_hwifs[index];
213 init_hwif_data(hwif, index); 214 ide_init_port_data(hwif, index);
214 init_hwif_default(hwif, index); 215 init_hwif_default(hwif, index);
215#if !defined(CONFIG_PPC32) || !defined(CONFIG_PCI) 216#if !defined(CONFIG_PPC32) || !defined(CONFIG_PCI)
216 hwif->irq = 217 hwif->irq =
@@ -609,7 +610,7 @@ void ide_unregister(unsigned int index)
609 tmp_hwif = *hwif; 610 tmp_hwif = *hwif;
610 611
611 /* restore hwif data to pristine status */ 612 /* restore hwif data to pristine status */
612 init_hwif_data(hwif, index); 613 ide_init_port_data(hwif, index);
613 init_hwif_default(hwif, index); 614 init_hwif_default(hwif, index);
614 615
615 ide_hwif_restore(hwif, &tmp_hwif); 616 ide_hwif_restore(hwif, &tmp_hwif);
@@ -690,29 +691,19 @@ EXPORT_SYMBOL_GPL(ide_init_port_hw);
690 * ide_register_hw - register IDE interface 691 * ide_register_hw - register IDE interface
691 * @hw: hardware registers 692 * @hw: hardware registers
692 * @quirkproc: quirkproc function 693 * @quirkproc: quirkproc function
693 * @initializing: set while initializing built-in drivers
694 * @hwifp: pointer to returned hwif 694 * @hwifp: pointer to returned hwif
695 * 695 *
696 * Register an IDE interface, specifying exactly the registers etc. 696 * Register an IDE interface, specifying exactly the registers etc.
697 * Set init=1 iff calling before probes have taken place.
698 * 697 *
699 * Returns -1 on error. 698 * Returns -1 on error.
700 */ 699 */
701 700
702int ide_register_hw(hw_regs_t *hw, void (*quirkproc)(ide_drive_t *), 701int ide_register_hw(hw_regs_t *hw, void (*quirkproc)(ide_drive_t *),
703 int initializing, ide_hwif_t **hwifp) 702 ide_hwif_t **hwifp)
704{ 703{
705 int index, retry = 1; 704 int index, retry = 1;
706 ide_hwif_t *hwif; 705 ide_hwif_t *hwif;
707 706 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
708 if (initializing) {
709 hwif = ide_find_port(hw->io_ports[IDE_DATA_OFFSET]);
710 if (hwif) {
711 index = hwif->index;
712 goto found;
713 }
714 return -1;
715 }
716 707
717 do { 708 do {
718 for (index = 0; index < MAX_HWIFS; ++index) { 709 for (index = 0; index < MAX_HWIFS; ++index) {
@@ -735,7 +726,7 @@ found:
735 if (hwif->present) 726 if (hwif->present)
736 ide_unregister(index); 727 ide_unregister(index);
737 else if (!hwif->hold) { 728 else if (!hwif->hold) {
738 init_hwif_data(hwif, index); 729 ide_init_port_data(hwif, index);
739 init_hwif_default(hwif, index); 730 init_hwif_default(hwif, index);
740 } 731 }
741 if (hwif->present) 732 if (hwif->present)
@@ -744,16 +735,14 @@ found:
744 ide_init_port_hw(hwif, hw); 735 ide_init_port_hw(hwif, hw);
745 hwif->quirkproc = quirkproc; 736 hwif->quirkproc = quirkproc;
746 737
747 if (initializing == 0) { 738 idx[0] = index;
748 u8 idx[4] = { index, 0xff, 0xff, 0xff };
749 739
750 ide_device_add(idx); 740 ide_device_add(idx);
751 }
752 741
753 if (hwifp) 742 if (hwifp)
754 *hwifp = hwif; 743 *hwifp = hwif;
755 744
756 return (initializing || hwif->present) ? index : -1; 745 return hwif->present ? index : -1;
757} 746}
758 747
759EXPORT_SYMBOL(ide_register_hw); 748EXPORT_SYMBOL(ide_register_hw);
@@ -1076,7 +1065,7 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device
1076 ide_init_hwif_ports(&hw, (unsigned long) args[0], 1065 ide_init_hwif_ports(&hw, (unsigned long) args[0],
1077 (unsigned long) args[1], NULL); 1066 (unsigned long) args[1], NULL);
1078 hw.irq = args[2]; 1067 hw.irq = args[2];
1079 if (ide_register_hw(&hw, NULL, 0, NULL) == -1) 1068 if (ide_register_hw(&hw, NULL, NULL) == -1)
1080 return -EIO; 1069 return -EIO;
1081 return 0; 1070 return 0;
1082 } 1071 }