aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-02 13:56:39 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-02 13:56:39 -0500
commit9e016a719209d95338e314b46c3012cc7feaaeec (patch)
treecc19b160cfb6210385fbf29890351f9ca2ba73df /drivers/ide/ide.c
parentf82c2b171905b6d5af92395d8159546351ab602f (diff)
ide: add ide_deprecated_find_port() helper
* Factor out code for finding ide_hwifs[] slot from ide_register_hw() to ide_deprecated_find_port(). * Convert bast-ide, ide-cs and delkin_cb host drivers to use ide_device_add() instead of ide_register_hw() (while at it drop doing "ide_unregister()" loop which tries to unregister _all_ IDE interfaces if useable ide_hwifs[] slot cannot be find). This patch leaves us with only two ide_register_hw() users: - drivers/macintosh/mediabay.c - drivers/ide/ide.c Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide.c')
-rw-r--r--drivers/ide/ide.c41
1 files changed, 29 insertions, 12 deletions
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 166acd513d5b..d42216b52a7b 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -683,6 +683,31 @@ void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw)
683} 683}
684EXPORT_SYMBOL_GPL(ide_init_port_hw); 684EXPORT_SYMBOL_GPL(ide_init_port_hw);
685 685
686ide_hwif_t *ide_deprecated_find_port(unsigned long base)
687{
688 ide_hwif_t *hwif;
689 int i;
690
691 for (i = 0; i < MAX_HWIFS; i++) {
692 hwif = &ide_hwifs[i];
693 if (hwif->io_ports[IDE_DATA_OFFSET] == base)
694 goto found;
695 }
696
697 for (i = 0; i < MAX_HWIFS; i++) {
698 hwif = &ide_hwifs[i];
699 if (hwif->hold)
700 continue;
701 if (!hwif->present && hwif->mate == NULL)
702 goto found;
703 }
704
705 hwif = NULL;
706found:
707 return hwif;
708}
709EXPORT_SYMBOL_GPL(ide_deprecated_find_port);
710
686/** 711/**
687 * ide_register_hw - register IDE interface 712 * ide_register_hw - register IDE interface
688 * @hw: hardware registers 713 * @hw: hardware registers
@@ -702,18 +727,10 @@ int ide_register_hw(hw_regs_t *hw, void (*quirkproc)(ide_drive_t *),
702 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 727 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
703 728
704 do { 729 do {
705 for (index = 0; index < MAX_HWIFS; ++index) { 730 hwif = ide_deprecated_find_port(hw->io_ports[IDE_DATA_OFFSET]);
706 hwif = &ide_hwifs[index]; 731 index = hwif->index;
707 if (hwif->io_ports[IDE_DATA_OFFSET] == hw->io_ports[IDE_DATA_OFFSET]) 732 if (hwif)
708 goto found; 733 goto found;
709 }
710 for (index = 0; index < MAX_HWIFS; ++index) {
711 hwif = &ide_hwifs[index];
712 if (hwif->hold)
713 continue;
714 if (!hwif->present && hwif->mate == NULL)
715 goto found;
716 }
717 for (index = 0; index < MAX_HWIFS; index++) 734 for (index = 0; index < MAX_HWIFS; index++)
718 ide_unregister(index, 1, 1); 735 ide_unregister(index, 1, 1);
719 } while (retry--); 736 } while (retry--);