aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ide/ide-probe.c18
-rw-r--r--drivers/ide/ide.c22
-rw-r--r--drivers/ide/ppc/pmac.c3
-rw-r--r--drivers/macintosh/mediabay.c17
-rw-r--r--include/asm-powerpc/mediabay.h6
-rw-r--r--include/linux/ide.h6
6 files changed, 50 insertions, 22 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index f3ee098b69c7..468c4ac4181d 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1494,3 +1494,21 @@ int ide_device_add(u8 idx[4], const struct ide_port_info *d)
1494 return ide_device_add_all(idx_all, d); 1494 return ide_device_add_all(idx_all, d);
1495} 1495}
1496EXPORT_SYMBOL_GPL(ide_device_add); 1496EXPORT_SYMBOL_GPL(ide_device_add);
1497
1498void ide_port_scan(ide_hwif_t *hwif)
1499{
1500 ide_port_cable_detect(hwif);
1501 ide_port_init_devices(hwif);
1502
1503 if (ide_probe_port(hwif) < 0)
1504 return;
1505
1506 hwif->present = 1;
1507
1508 ide_port_tune_devices(hwif);
1509 ide_acpi_port_init_devices(hwif);
1510 ide_port_setup_devices(hwif);
1511 hwif_register_devices(hwif);
1512 ide_proc_port_register_devices(hwif);
1513}
1514EXPORT_SYMBOL_GPL(ide_port_scan);
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 47c44d15ad4a..a8b5b08dd6e2 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -502,7 +502,7 @@ void ide_remove_port_from_hwgroup(ide_hwif_t *hwif)
502} 502}
503 503
504/* Called with ide_lock held. */ 504/* Called with ide_lock held. */
505static void ide_port_unregister_devices(ide_hwif_t *hwif) 505static void __ide_port_unregister_devices(ide_hwif_t *hwif)
506{ 506{
507 int i; 507 int i;
508 508
@@ -518,6 +518,18 @@ static void ide_port_unregister_devices(ide_hwif_t *hwif)
518 } 518 }
519} 519}
520 520
521void ide_port_unregister_devices(ide_hwif_t *hwif)
522{
523 mutex_lock(&ide_cfg_mtx);
524 spin_lock_irq(&ide_lock);
525 __ide_port_unregister_devices(hwif);
526 hwif->present = 0;
527 ide_port_init_devices_data(hwif);
528 spin_unlock_irq(&ide_lock);
529 mutex_unlock(&ide_cfg_mtx);
530}
531EXPORT_SYMBOL_GPL(ide_port_unregister_devices);
532
521/** 533/**
522 * ide_unregister - free an IDE interface 534 * ide_unregister - free an IDE interface
523 * @index: index of interface (will change soon to a pointer) 535 * @index: index of interface (will change soon to a pointer)
@@ -558,7 +570,7 @@ void ide_unregister(unsigned int index, int init_default, int restore)
558 hwif = &ide_hwifs[index]; 570 hwif = &ide_hwifs[index];
559 if (!hwif->present) 571 if (!hwif->present)
560 goto abort; 572 goto abort;
561 ide_port_unregister_devices(hwif); 573 __ide_port_unregister_devices(hwif);
562 hwif->present = 0; 574 hwif->present = 0;
563 575
564 spin_unlock_irq(&ide_lock); 576 spin_unlock_irq(&ide_lock);
@@ -648,8 +660,8 @@ EXPORT_SYMBOL_GPL(ide_init_port_hw);
648 * Returns -1 on error. 660 * Returns -1 on error.
649 */ 661 */
650 662
651int ide_register_hw(hw_regs_t *hw, void (*quirkproc)(ide_drive_t *), 663static int ide_register_hw(hw_regs_t *hw, void (*quirkproc)(ide_drive_t *),
652 ide_hwif_t **hwifp) 664 ide_hwif_t **hwifp)
653{ 665{
654 int index, retry = 1; 666 int index, retry = 1;
655 ide_hwif_t *hwif; 667 ide_hwif_t *hwif;
@@ -683,8 +695,6 @@ found:
683 return hwif->present ? index : -1; 695 return hwif->present ? index : -1;
684} 696}
685 697
686EXPORT_SYMBOL(ide_register_hw);
687
688/* 698/*
689 * Locks for IDE setting functionality 699 * Locks for IDE setting functionality
690 */ 700 */
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index d9ca52e6cdab..7889f5f5c49a 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1088,7 +1088,8 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw)
1088 if (np->parent && np->parent->name 1088 if (np->parent && np->parent->name
1089 && strcasecmp(np->parent->name, "media-bay") == 0) { 1089 && strcasecmp(np->parent->name, "media-bay") == 0) {
1090#ifdef CONFIG_PMAC_MEDIABAY 1090#ifdef CONFIG_PMAC_MEDIABAY
1091 media_bay_set_ide_infos(np->parent, pmif->regbase, pmif->irq, hwif->index); 1091 media_bay_set_ide_infos(np->parent, pmif->regbase, pmif->irq,
1092 hwif);
1092#endif /* CONFIG_PMAC_MEDIABAY */ 1093#endif /* CONFIG_PMAC_MEDIABAY */
1093 pmif->mediabay = 1; 1094 pmif->mediabay = 1;
1094 if (!bidp) 1095 if (!bidp)
diff --git a/drivers/macintosh/mediabay.c b/drivers/macintosh/mediabay.c
index bd8a1d14b45d..82add26cc665 100644
--- a/drivers/macintosh/mediabay.c
+++ b/drivers/macintosh/mediabay.c
@@ -79,6 +79,7 @@ struct media_bay_info {
79 int sleeping; 79 int sleeping;
80 struct semaphore lock; 80 struct semaphore lock;
81#ifdef CONFIG_BLK_DEV_IDE_PMAC 81#ifdef CONFIG_BLK_DEV_IDE_PMAC
82 ide_hwif_t *cd_port;
82 void __iomem *cd_base; 83 void __iomem *cd_base;
83 int cd_irq; 84 int cd_irq;
84 int cd_retry; 85 int cd_retry;
@@ -448,7 +449,7 @@ int check_media_bay_by_base(unsigned long base, int what)
448} 449}
449 450
450int media_bay_set_ide_infos(struct device_node* which_bay, unsigned long base, 451int media_bay_set_ide_infos(struct device_node* which_bay, unsigned long base,
451 int irq, int index) 452 int irq, ide_hwif_t *hwif)
452{ 453{
453 int i; 454 int i;
454 455
@@ -456,10 +457,11 @@ int media_bay_set_ide_infos(struct device_node* which_bay, unsigned long base,
456 struct media_bay_info* bay = &media_bays[i]; 457 struct media_bay_info* bay = &media_bays[i];
457 458
458 if (bay->mdev && which_bay == bay->mdev->ofdev.node) { 459 if (bay->mdev && which_bay == bay->mdev->ofdev.node) {
459 int timeout = 5000; 460 int timeout = 5000, index = hwif->index;
460 461
461 down(&bay->lock); 462 down(&bay->lock);
462 463
464 bay->cd_port = hwif;
463 bay->cd_base = (void __iomem *) base; 465 bay->cd_base = (void __iomem *) base;
464 bay->cd_irq = irq; 466 bay->cd_irq = irq;
465 467
@@ -551,15 +553,10 @@ static void media_bay_step(int i)
551 bay->timer = 0; 553 bay->timer = 0;
552 bay->state = mb_up; 554 bay->state = mb_up;
553 if (bay->cd_index < 0) { 555 if (bay->cd_index < 0) {
554 hw_regs_t hw;
555
556 printk("mediabay %d, registering IDE...\n", i); 556 printk("mediabay %d, registering IDE...\n", i);
557 pmu_suspend(); 557 pmu_suspend();
558 ide_init_hwif_ports(&hw, (unsigned long) bay->cd_base, (unsigned long) 0, NULL); 558 ide_port_scan(bay->cd_port);
559 hw.irq = bay->cd_irq; 559 bay->cd_index = bay->cd_port->index;
560 hw.chipset = ide_pmac;
561 bay->cd_index =
562 ide_register_hw(&hw, NULL, NULL);
563 pmu_resume(); 560 pmu_resume();
564 } 561 }
565 if (bay->cd_index == -1) { 562 if (bay->cd_index == -1) {
@@ -589,7 +586,7 @@ static void media_bay_step(int i)
589 if (bay->cd_index >= 0) { 586 if (bay->cd_index >= 0) {
590 printk(KERN_DEBUG "Unregistering mb %d ide, index:%d\n", i, 587 printk(KERN_DEBUG "Unregistering mb %d ide, index:%d\n", i,
591 bay->cd_index); 588 bay->cd_index);
592 ide_unregister(bay->cd_index, 1, 1); 589 ide_port_unregister_devices(bay->cd_port);
593 bay->cd_index = -1; 590 bay->cd_index = -1;
594 } 591 }
595 if (bay->cd_retry) { 592 if (bay->cd_retry) {
diff --git a/include/asm-powerpc/mediabay.h b/include/asm-powerpc/mediabay.h
index de83fe196309..df111c362a7f 100644
--- a/include/asm-powerpc/mediabay.h
+++ b/include/asm-powerpc/mediabay.h
@@ -22,10 +22,14 @@ int check_media_bay(struct device_node *which_bay, int what);
22/* Number of bays in the machine or 0 */ 22/* Number of bays in the machine or 0 */
23extern int media_bay_count; 23extern int media_bay_count;
24 24
25#ifdef CONFIG_BLK_DEV_IDE_PMAC
26#include <linux/ide.h>
27
25int check_media_bay_by_base(unsigned long base, int what); 28int check_media_bay_by_base(unsigned long base, int what);
26/* called by IDE PMAC host driver to register IDE controller for media bay */ 29/* called by IDE PMAC host driver to register IDE controller for media bay */
27int media_bay_set_ide_infos(struct device_node *which_bay, unsigned long base, 30int media_bay_set_ide_infos(struct device_node *which_bay, unsigned long base,
28 int irq, int index); 31 int irq, ide_hwif_t *hwif);
32#endif
29 33
30#endif /* __KERNEL__ */ 34#endif /* __KERNEL__ */
31#endif /* _PPC_MEDIABAY_H */ 35#endif /* _PPC_MEDIABAY_H */
diff --git a/include/linux/ide.h b/include/linux/ide.h
index f9449ecd79d9..9aaad7e70593 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -189,10 +189,6 @@ struct hwif_s * ide_find_port(unsigned long);
189void ide_init_port_data(struct hwif_s *, unsigned int); 189void ide_init_port_data(struct hwif_s *, unsigned int);
190void ide_init_port_hw(struct hwif_s *, hw_regs_t *); 190void ide_init_port_hw(struct hwif_s *, hw_regs_t *);
191 191
192struct ide_drive_s;
193int ide_register_hw(hw_regs_t *, void (*)(struct ide_drive_s *),
194 struct hwif_s **);
195
196static inline void ide_std_init_ports(hw_regs_t *hw, 192static inline void ide_std_init_ports(hw_regs_t *hw,
197 unsigned long io_addr, 193 unsigned long io_addr,
198 unsigned long ctl_addr) 194 unsigned long ctl_addr)
@@ -1204,6 +1200,8 @@ void ide_undecoded_slave(ide_drive_t *);
1204 1200
1205int ide_device_add_all(u8 *idx, const struct ide_port_info *); 1201int ide_device_add_all(u8 *idx, const struct ide_port_info *);
1206int ide_device_add(u8 idx[4], const struct ide_port_info *); 1202int ide_device_add(u8 idx[4], const struct ide_port_info *);
1203void ide_port_unregister_devices(ide_hwif_t *);
1204void ide_port_scan(ide_hwif_t *);
1207 1205
1208static inline void *ide_get_hwifdata (ide_hwif_t * hwif) 1206static inline void *ide_get_hwifdata (ide_hwif_t * hwif)
1209{ 1207{