ide-pmac: bugfix for media-bay support rework
Subsystems (3)
PATCH 1/7 ide-pmac: bugfix for media-bay support rework
Fix bug introduced by:
commit 2dde7861afa23cd59db83515cb0b810b92b220aa
Author: Bartlomiej Zolnierkiewicz <[email protected]> Date: Fri Apr 18 00:46:23 2008 +0200
ide: rework PowerMac media-bay support (take 2)
...
[ Yeah, I suck. ]
bay->cd_index shouldn't be changed if IDE devices are not present or retry operations won't happen.
---
first three patches are meant for 2.6.26, the rest for 2.6.27
drivers/macintosh/mediabay.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
drivers/macintosh/mediabay.c +2 -1
@@ -556,7 +556,8 @@ static void media_bay_step(int i)printk ("mediabay %d, registering IDE...\n" , i);pmu_suspend ();ide_port_scan (bay->cd_port); - bay->cd_index = bay->cd_port->index; +if (bay->cd_port->present) + bay->cd_index = bay->cd_port->index;pmu_resume (); }if (bay->cd_index ==-1 ) {
PATCH 2/7 ide-pmac: add ->cable_detect method
Add ->cable_detect method and remove no longer needed pmif->cable_80 flag (there is also no need to mask ->udma_mask now).
This fixes:
- forced ignoring of cable detection (needed for some CF devices & debug)
- cable detection for warm-plug
--- drivers/ide/ppc/pmac.c | 55 +++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 24 deletions(-)
drivers/ide/ppc/pmac.c +31 -24
@@ -57,7 +57,6 @@ typedef struct pmac_ide_hwif {int irq;int kind;int aapl_bus_id; - unsigned cable_80 : 1; unsigned mediabay : 1; unsigned broken_dma : 1; unsigned broken_dma_warn : 1;
@@ -915,10 +914,40 @@ pmac_ide_do_resume(ide_hwif_t *hwif)return 0 ; } +static u8 pmac_ide_cable_detect (ide_hwif_t *hwif) +{ +pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)ide_get_hwifdata (hwif); +struct device_node *np = pmif->node; +const char *cable =of_get_property (np,"cable-type" ,NULL ); + +/* Get cable type from device-tree. */ +if (cable && !strncmp (cable,"80-" ,3 )) +return ATA_CBL_PATA80 ; + +/* +* G5's seem to have incorrect cable type in device-tree. +* Let's assume they have a 80 conductor cable, this seem +* to be always the case unless the user mucked around. +*/ +if (of_device_is_compatible (np,"K2-UATA" ) || +of_device_is_compatible (np,"shasta-ata" )) +return ATA_CBL_PATA80 ; + +return ATA_CBL_PATA40 ; +} +static const struct ide_port_ops pmac_ide_ata6_port_ops = { .set_pio_mode = pmac_ide_set_pio_mode, .set_dma_mode = pmac_ide_set_dma_mode, .selectproc = pmac_ide_kauai_selectproc, + .cable_detect = pmac_ide_cable_detect, +}; + +static const struct ide_port_ops pmac_ide_ata4_port_ops = { + .set_pio_mode = pmac_ide_set_pio_mode, + .set_dma_mode = pmac_ide_set_dma_mode, + .selectproc = pmac_ide_selectproc, + .cable_detect = pmac_ide_cable_detect, };static const struct ide_port_ops pmac_ide_port_ops = {
@@ -959,7 +988,6 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pu8 idx[4 ] = {0xff ,0xff ,0xff ,0xff };struct ide_port_info d = pmac_port_info; - pmif->cable_80 =0 ; pmif->broken_dma = pmif->broken_dma_warn =0 ;if (of_device_is_compatible (np,"shasta-ata" )) { pmif->kind = controller_sh_ata6;
@@ -976,6 +1004,7 @@ pmac_ide_setup_device(pmac_ide_hwif_t *p }else if (of_device_is_compatible (np,"keylargo-ata" )) {if (strcmp (np->name,"ata-4" ) ==0 ) { pmif->kind = controller_kl_ata4; + d.port_ops = &pmac_ide_ata4_port_ops; d.udma_mask =ATA_UDMA4 ; }else pmif->kind = controller_kl_ata3;
@@ -989,22 +1018,6 @@ pmac_ide_setup_device(pmac_ide_hwif_t *p bidp =of_get_property (np,"AAPL,bus-id" ,NULL ); pmif->aapl_bus_id = bidp ? *bidp :0 ; -/* Get cable type from device-tree */ -if (pmif->kind == controller_kl_ata4 || pmif->kind == controller_un_ata6 - || pmif->kind == controller_k2_ata6 - || pmif->kind == controller_sh_ata6) { -const char * cable =of_get_property (np,"cable-type" ,NULL ); -if (cable && !strncmp (cable,"80-" ,3 )) - pmif->cable_80 =1 ; - } -/* G5's seem to have incorrect cable type in device-tree. Let's assume -* they have a 80 conductor cable, this seem to be always the case unless -* the user mucked around -*/ -if (of_device_is_compatible (np,"K2-UATA" ) || -of_device_is_compatible (np,"shasta-ata" )) - pmif->cable_80 =1 ; -/* On Kauai-type controllers, we make sure the FCR is correct */ if (pmif->kauai_fcr) writel(KAUAI_FCR_UATA_MAGIC |
@@ -1050,7 +1063,6 @@ pmac_ide_setup_device(pmac_ide_hwif_t *p hwif->hwif_data = pmif;ide_init_port_hw (hwif, hw); - hwif->cbl = pmif->cable_80 ?ATA_CBL_PATA80 :ATA_CBL_PATA40 ; printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n", hwif->index, model_name[pmif->kind], pmif->aapl_bus_id,
@@ -1067,11 +1079,6 @@ pmac_ide_setup_device(pmac_ide_hwif_t *p } } -#ifdef CONFIG_BLK_DEV_IDEDMA_PMAC -if (pmif->cable_80 ==0 ) - d.udma_mask &=ATA_UDMA2 ; -#endif - idx[0 ] = hwif->index;ide_device_add (idx, &d);
PATCH 3/7 ide-pmac: remove bogus comment about pmac_ide_setup_device()
In reply to Bartlomiej Zolnierkiewicz--- drivers/ide/ppc/pmac.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/ide/ppc/pmac.c +1 -4
@@ -975,10 +975,7 @@ static const struct ide_port_info pmac_p/* * Setup, register & probe an IDE channel driven by this driver, this is -* called by one of the 2 probe functions (macio or PCI). Note that a channel -* that ends up beeing free of any device is not kept around by this driver -* (it is kept in 2.4). This introduce an interface numbering change on some -* rare machines unfortunately, but it's better this way. +* called by one of the 2 probe functions (macio or PCI). */ static int __devinit pmac_ide_setup_device (pmac_ide_hwif_t *pmif,ide_hwif_t *hwif,hw_regs_t *hw)
PATCH 4/7 ide-pmac: media-bay support fixes
In reply to Bartlomiej Zolnierkiewicz* If MB_CD device has already been detected and bay is in mb_up state just change bay's state to mb_ide_resetting and let probing thread do the rest instead of having open-coded waiting for IDE device to become ready in media_bay_set_ide_infos() and doing the probe by ide_device_add().
* Move media_bay_set_ide_infos() call after ide_device_add().
* Use check_media_bay() instead of check_media_bay_by_base(), then remove the latter function.
--- drivers/ide/ppc/pmac.c | 18 ++++++++---------- drivers/macintosh/mediabay.c | 33 +++++---------------------------- include/asm-powerpc/mediabay.h | 1 - 3 files changed, 13 insertions(+), 39 deletions(-)
drivers/ide/ppc/pmac.c +8 -10
@@ -1030,10 +1030,6 @@ pmac_ide_setup_device(pmac_ide_hwif_t *p/* XXX FIXME: Media bay stuff need re-organizing */ if (np->parent && np->parent->name &&strcasecmp (np->parent->name,"media-bay" ) ==0 ) { -#ifdef CONFIG_PMAC_MEDIABAY -media_bay_set_ide_infos (np->parent, pmif->regbase, pmif->irq, - hwif); -#endif /* CONFIG_PMAC_MEDIABAY */ pmif->mediabay =1 ;if (!bidp) pmif->aapl_bus_id =1 ;
@@ -1067,19 +1063,21 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pif (pmif->mediabay) {#ifdef CONFIG_PMAC_MEDIABAY -if (check_media_bay_by_base (pmif->regbase,MB_CD )) { -#else -if (1 ) { +if (check_media_bay (np->parent,MB_CD ) == -ENODEV ) +break ;#endif - hwif->drives[0 ].noprobe =1 ; - hwif->drives[1 ].noprobe =1 ; - } + hwif->drives[0 ].noprobe =1 ; + hwif->drives[1 ].noprobe =1 ; } idx[0 ] = hwif->index;ide_device_add (idx, &d); +#ifdef CONFIG_PMAC_MEDIABAY +media_bay_set_ide_infos (np->parent, pmif->regbase, pmif->irq, hwif); +#endif +return 0 ; }
drivers/macintosh/mediabay.c +5 -28
@@ -433,21 +433,6 @@ int check_media_bay(struct device_node *EXPORT_SYMBOL (check_media_bay);#ifdef CONFIG_BLK_DEV_IDE_PMAC -int check_media_bay_by_base (unsigned long base,int what) -{ -int i; - -for (i=0 ; i<media_bay_count; i++) -if (media_bays[i].mdev && base == (unsigned long ) media_bays[i].cd_base) { -if ((what == media_bays[i].content_id) && media_bays[i].state == mb_up) -return 0 ; - media_bays[i].cd_index =-1 ; -return -EINVAL ; - } - -return -ENODEV ; -} -int media_bay_set_ide_infos (struct device_node * which_bay,unsigned long base,int irq,ide_hwif_t *hwif) {
@@ -457,8 +442,6 @@ int media_bay_set_ide_infos(struct devicstruct media_bay_info * bay = &media_bays[i];if (bay->mdev && which_bay == bay->mdev->ofdev.node) { -int timeout =5000 , index = hwif->index; -down (&bay->lock); bay->cd_port = hwif;
@@ -469,18 +452,12 @@ int media_bay_set_ide_infos(struct devicup (&bay->lock);return 0 ; } -printk (KERN_DEBUG "Registered ide%d for media bay %d\n" , index, i); -do { -if (MB_IDE_READY (i)) { - bay->cd_index = index; -up (&bay->lock); -return 0 ; - } -mdelay (1 ); - }while (--timeout); -printk (KERN_DEBUG "Timeount waiting IDE in bay %d\n" , i); + +/* let probing thread do the rest */ + bay->state = mb_ide_resetting; +up (&bay->lock); -return -ENODEV ; +return 0 ; } }
include/asm-powerpc/mediabay.h +0 -1
@@ -25,7 +25,6 @@ extern int media_bay_count;#ifdef CONFIG_BLK_DEV_IDE_PMAC #include <linux/ide.h> -int check_media_bay_by_base (unsigned long base,int what);/* called by IDE PMAC host driver to register IDE controller for media bay */ int media_bay_set_ide_infos (struct device_node *which_bay,unsigned long base,int irq,ide_hwif_t *hwif);
PATCH 5/7 ide-pmac: store pmif instead of hwif in ->driver_data
In reply to Bartlomiej Zolnierkiewicz* Pass pmif instead of hwif to pmac_ide_do_{suspend,resume}().
* Store pmif instead of hwif in ->driver_data.
* Use dev_get_drvdata() instead of ->hwif_data to obtain pmif.
There should be no functional changes caused by this patch.
--- drivers/ide/ppc/pmac.c | 93 ++++++++++++++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 38 deletions(-)
drivers/ide/ppc/pmac.c +55 -38
@@ -424,7 +424,9 @@ static void pmac_ide_kauai_selectproc(idstatic void pmac_ide_selectproc (ide_drive_t *drive) { -pmac_ide_hwif_t * pmif = (pmac_ide_hwif_t *)HWIF (drive)->hwif_data; +ide_hwif_t *hwif = drive->hwif; +pmac_ide_hwif_t *pmif = + (pmac_ide_hwif_t *)dev_get_drvdata (hwif->gendev.parent);if (pmif ==NULL )return ;
@@ -444,7 +446,9 @@ pmac_ide_selectproc(ide_drive_t *drive)static void pmac_ide_kauai_selectproc (ide_drive_t *drive) { -pmac_ide_hwif_t * pmif = (pmac_ide_hwif_t *)HWIF (drive)->hwif_data; +ide_hwif_t *hwif = drive->hwif; +pmac_ide_hwif_t *pmif = + (pmac_ide_hwif_t *)dev_get_drvdata (hwif->gendev.parent);if (pmif ==NULL )return ;
@@ -465,7 +469,9 @@ pmac_ide_kauai_selectproc(ide_drive_t *dstatic void pmac_ide_do_update_timings (ide_drive_t *drive) { -pmac_ide_hwif_t * pmif = (pmac_ide_hwif_t *)HWIF (drive)->hwif_data; +ide_hwif_t *hwif = drive->hwif; +pmac_ide_hwif_t *pmif = + (pmac_ide_hwif_t *)dev_get_drvdata (hwif->gendev.parent);if (pmif ==NULL )return ;
@@ -493,11 +499,13 @@ static void pmac_outbsync(ide_hwif_t *hwstatic void pmac_ide_set_pio_mode (ide_drive_t *drive,const u8 pio) { +ide_hwif_t *hwif = drive->hwif; +pmac_ide_hwif_t *pmif = + (pmac_ide_hwif_t *)dev_get_drvdata (hwif->gendev.parent);struct ide_timing *tim =ide_timing_find_mode (XFER_PIO_0 + pio);u32 *timings, t;unsigned accessTicks, recTicks;unsigned accessTime, recTime; -pmac_ide_hwif_t * pmif = (pmac_ide_hwif_t *)HWIF (drive)->hwif_data;unsigned int cycle_time;if (pmif ==NULL )
@@ -778,9 +786,11 @@ set_timings_mdma(ide_drive_t *drive, intstatic void pmac_ide_set_dma_mode (ide_drive_t *drive,const u8 speed) { +ide_hwif_t *hwif = drive->hwif; +pmac_ide_hwif_t *pmif = + (pmac_ide_hwif_t *)dev_get_drvdata (hwif->gendev.parent);int unit = (drive->select.b.unit &0x01 );int ret =0 ; -pmac_ide_hwif_t * pmif = (pmac_ide_hwif_t *)HWIF (drive)->hwif_data;u32 *timings, *timings2, tl[2 ]; timings = &pmif->timings[unit];
@@ -852,11 +862,8 @@ sanitize_timings(pmac_ide_hwif_t *pmif)/* Suspend call back, should be called after the child devices * have actually been suspended */ -static int -pmac_ide_do_suspend (ide_hwif_t *hwif) +static int pmac_ide_do_suspend (pmac_ide_hwif_t *pmif) { -pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data; -/* We clear the timings */ pmif->timings[0 ] =0 ; pmif->timings[1 ] =0 ;
@@ -884,11 +891,8 @@ pmac_ide_do_suspend(ide_hwif_t *hwif)/* Resume call back, should be called before the child devices * are resumed */ -static int -pmac_ide_do_resume (ide_hwif_t *hwif) +static int pmac_ide_do_resume (pmac_ide_hwif_t *pmif) { -pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data; -/* Hard reset & re-enable controller (do we really need to reset ? -BenH) */ if (!pmif->mediabay) { ppc_md.feature_call (PMAC_FTR_IDE_RESET , pmif->node, pmif->aapl_bus_id,1 );
@@ -916,7 +920,8 @@ pmac_ide_do_resume(ide_hwif_t *hwif)static u8 pmac_ide_cable_detect (ide_hwif_t *hwif) { -pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)ide_get_hwifdata (hwif); +pmac_ide_hwif_t *pmif = + (pmac_ide_hwif_t *)drv_get_drvdata (hwif->gendev.parent);struct device_node *np = pmif->node;const char *cable =of_get_property (np,"cable-type" ,NULL );
@@ -1054,7 +1059,6 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pdefault_hwif_mmiops (hwif); hwif->OUTBSYNC = pmac_outbsync; - hwif->hwif_data = pmif;ide_init_port_hw (hwif, hw); printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n",
@@ -1162,7 +1166,7 @@ pmac_ide_macio_attach(struct macio_dev * } else pmif->dma_regs =NULL ;#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ -dev_set_drvdata (&mdev->ofdev.dev, hwif); +dev_set_drvdata (&mdev->ofdev.dev, pmif);memset (&hw,0 ,sizeof (hw));pmac_ide_init_ports (&hw, pmif->regbase);
@@ -1193,12 +1197,13 @@ out_free_pmif:static int pmac_ide_macio_suspend (struct macio_dev *mdev,pm_message_t mesg) { -ide_hwif_t *hwif = (ide_hwif_t *)dev_get_drvdata (&mdev->ofdev.dev); -int rc =0 ; +pmac_ide_hwif_t *pmif = + (pmac_ide_hwif_t *)dev_get_drvdata (&mdev->ofdev.dev); +int rc =0 ;if (mesg.event != mdev->ofdev.dev.power.power_state.event && (mesg.event &PM_EVENT_SLEEP )) { - rc =pmac_ide_do_suspend (hwif); + rc =pmac_ide_do_suspend (pmif);if (rc ==0 ) mdev->ofdev.dev.power.power_state = mesg; }
@@ -1209,11 +1214,12 @@ pmac_ide_macio_suspend(struct macio_devstatic int pmac_ide_macio_resume (struct macio_dev *mdev) { -ide_hwif_t *hwif = (ide_hwif_t *)dev_get_drvdata (&mdev->ofdev.dev); -int rc =0 ; - +pmac_ide_hwif_t *pmif = + (pmac_ide_hwif_t *)dev_get_drvdata (&mdev->ofdev.dev); +int rc =0 ; +if (mdev->ofdev.dev.power.power_state.event !=PM_EVENT_ON ) { - rc =pmac_ide_do_resume (hwif); + rc =pmac_ide_do_resume (pmif);if (rc ==0 ) mdev->ofdev.dev.power.power_state =PMSG_ON ; }
@@ -1282,7 +1288,7 @@ pmac_ide_pci_attach(struct pci_dev *pdev pmif->kauai_fcr = base; pmif->irq = pdev->irq; -pci_set_drvdata (pdev, hwif); +pci_set_drvdata (pdev, pmif);memset (&hw,0 ,sizeof (hw));pmac_ide_init_ports (&hw, pmif->regbase);
@@ -1308,9 +1314,9 @@ out_free_pmif:static int pmac_ide_pci_suspend (struct pci_dev *pdev,pm_message_t mesg) { -ide_hwif_t *hwif = (ide_hwif_t *)pci_get_drvdata (pdev); -int rc =0 ; - +pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)pci_get_drvdata (pdev); +int rc =0 ; +if (mesg.event != pdev->dev.power.power_state.event && (mesg.event &PM_EVENT_SLEEP )) { rc =pmac_ide_do_suspend (hwif);
@@ -1324,9 +1330,9 @@ pmac_ide_pci_suspend(struct pci_dev *pdestatic int pmac_ide_pci_resume (struct pci_dev *pdev) { -ide_hwif_t *hwif = (ide_hwif_t *)pci_get_drvdata (pdev); -int rc =0 ; - +pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)pci_get_drvdata (pdev); +int rc =0 ; +if (pdev->dev.power.power_state.event !=PM_EVENT_ON ) { rc =pmac_ide_do_resume (hwif);if (rc ==0 )
@@ -1419,10 +1425,11 @@ out:static int pmac_ide_build_dmatable (ide_drive_t *drive,struct request *rq) { +ide_hwif_t *hwif = drive->hwif; +pmac_ide_hwif_t *pmif = + (pmac_ide_hwif_t *)dev_get_drvdata (hwif->gendev.parent);struct dbdma_cmd *table;int i, count =0 ; -ide_hwif_t *hwif =HWIF (drive); -pmac_ide_hwif_t * pmif = (pmac_ide_hwif_t *)hwif->hwif_data;volatile struct dbdma_regs __iomem *dma = pmif->dma_regs;struct scatterlist *sg;int wr = (rq_data_dir (rq) ==WRITE );
@@ -1518,7 +1525,8 @@ static int pmac_ide_dma_setup(ide_drive_t *drive) {ide_hwif_t *hwif =HWIF (drive); -pmac_ide_hwif_t * pmif = (pmac_ide_hwif_t *)hwif->hwif_data; +pmac_ide_hwif_t *pmif = + (pmac_ide_hwif_t *)dev_get_drvdata (hwif->gendev.parent);struct request *rq =HWGROUP (drive)->rq;u8 unit = (drive->select.b.unit &0x01 );u8 ata4;
@@ -1558,7 +1566,9 @@ pmac_ide_dma_exec_cmd(ide_drive_t *drivestatic void pmac_ide_dma_start (ide_drive_t *drive) { -pmac_ide_hwif_t * pmif = (pmac_ide_hwif_t *)HWIF (drive)->hwif_data; +ide_hwif_t *hwif = drive->hwif; +pmac_ide_hwif_t *pmif = + (pmac_ide_hwif_t *)dev_get_drvdata (hwif->gendev.parent);volatile struct dbdma_regs __iomem *dma; dma = pmif->dma_regs;
@@ -1574,7 +1584,9 @@ pmac_ide_dma_start(ide_drive_t *drive)static int pmac_ide_dma_end (ide_drive_t *drive) { -pmac_ide_hwif_t * pmif = (pmac_ide_hwif_t *)HWIF (drive)->hwif_data; +ide_hwif_t *hwif = drive->hwif; +pmac_ide_hwif_t *pmif = + (pmac_ide_hwif_t *)dev_get_drvdata (hwif->gendev.parent);volatile struct dbdma_regs __iomem *dma;u32 dstat;
@@ -1602,7 +1614,9 @@ pmac_ide_dma_end (ide_drive_t *drive)static int pmac_ide_dma_test_irq (ide_drive_t *drive) { -pmac_ide_hwif_t * pmif = (pmac_ide_hwif_t *)HWIF (drive)->hwif_data; +ide_hwif_t *hwif = drive->hwif; +pmac_ide_hwif_t *pmif = + (pmac_ide_hwif_t *)dev_get_drvdata (hwif->gendev.parent);volatile struct dbdma_regs __iomem *dma;unsigned long status, timeout;
@@ -1662,7 +1676,9 @@ static void pmac_ide_dma_host_set(ide_drstatic void pmac_ide_dma_lost_irq (ide_drive_t *drive) { -pmac_ide_hwif_t * pmif = (pmac_ide_hwif_t *)HWIF (drive)->hwif_data; +ide_hwif_t *hwif = drive->hwif; +pmac_ide_hwif_t *pmif = + (pmac_ide_hwif_t *)dev_get_drvdata (hwif->gendev.parent);volatile struct dbdma_regs __iomem *dma;unsigned long status;
@@ -1692,7 +1708,8 @@ static const struct ide_dma_ops pmac_dmastatic int __devinit pmac_ide_init_dma (ide_hwif_t *hwif,const struct ide_port_info *d) { -pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data; +pmac_ide_hwif_t *pmif = + (pmac_ide_hwif_t *)dev_get_drvdata (hwif->gendev.parent);struct pci_dev *dev =to_pci_dev (hwif->dev);/* We won't need pci_dev if we switch to generic consistent
PATCH 6/7 ide-pmac: add ->init_dev method
In reply to Bartlomiej ZolnierkiewiczThere should be no functional changes caused by this patch.
--- drivers/ide/ppc/pmac.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
drivers/ide/ppc/pmac.c +18 -9
@@ -941,7 +941,23 @@ static u8 pmac_ide_cable_detect(ide_hwifreturn ATA_CBL_PATA40 ; } +static void pmac_ide_init_dev (ide_drive_t *drive) +{ +ide_hwif_t *hwif = drive->hwif; +pmac_ide_hwif_t *pmif = + (pmac_ide_hwif_t *)drv_get_drvdata (hwif->gendev.parent); + +if (pmif->mediabay) { +#ifdef CONFIG_PMAC_MEDIABAY +if (check_media_bay (np->parent,MB_CD ) == -ENODEV ) +return ; +#endif + drive->noprobe =1 ; + } +} +static const struct ide_port_ops pmac_ide_ata6_port_ops = { + .init_dev = pmac_ide_init_dev, .set_pio_mode = pmac_ide_set_pio_mode, .set_dma_mode = pmac_ide_set_dma_mode, .selectproc = pmac_ide_kauai_selectproc,
@@ -949,6 +965,7 @@ static const struct ide_port_ops pmac_id };static const struct ide_port_ops pmac_ide_ata4_port_ops = { + .init_dev = pmac_ide_init_dev, .set_pio_mode = pmac_ide_set_pio_mode, .set_dma_mode = pmac_ide_set_dma_mode, .selectproc = pmac_ide_selectproc,
@@ -956,6 +973,7 @@ static const struct ide_port_ops pmac_id };static const struct ide_port_ops pmac_ide_port_ops = { + .init_dev = pmac_ide_init_dev, .set_pio_mode = pmac_ide_set_pio_mode, .set_dma_mode = pmac_ide_set_dma_mode, .selectproc = pmac_ide_selectproc,
@@ -1065,15 +1083,6 @@ pmac_ide_setup_device(pmac_ide_hwif_t *p hwif->index, model_name[pmif->kind], pmif->aapl_bus_id, pmif->mediabay ? " (mediabay)" : "", hwif->irq); -if (pmif->mediabay) { -#ifdef CONFIG_PMAC_MEDIABAY -if (check_media_bay (np->parent,MB_CD ) == -ENODEV ) -break ; -#endif - hwif->drives[0 ].noprobe =1 ; - hwif->drives[1 ].noprobe =1 ; - } - idx[0 ] = hwif->index;ide_device_add (idx, &d);
PATCH 7/7 ide-pmac: move ide_find_port() call to pmac_ide_setup_device()
In reply to Bartlomiej ZolnierkiewiczMove ide_find_port() call to pmac_ide_setup_device().
While at it:
- fix return value (s/-ENODEV/-ENOENT/)
- add DRV_NAME define and use it to set name field of pmac_port_info
- use ide_find_port_slot() instead of ide_find_port()
- remove superfluous error message (ide_find_port_slot() takes care of it)
- drop IDE interface number from driver banner message (but include bus type)
--- drivers/ide/ppc/pmac.c | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-)
drivers/ide/ppc/pmac.c +16 -26
@@ -48,6 +48,8 @@#include <asm/mediabay.h> #endif +#define DRV_NAME "ide-pmac" +#undef IDE_PMAC_DEBUG#define DMA_WAIT_TIMEOUT 50
@@ -982,6 +984,7 @@ static const struct ide_port_ops pmac_idstatic const struct ide_dma_ops pmac_dma_ops;static const struct ide_port_info pmac_port_info = { + .name =DRV_NAME , .init_dma = pmac_ide_init_dma, .chipset = ide_pmac, #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC
@@ -1000,11 +1003,11 @@ static const struct ide_port_info pmac_p* Setup, register & probe an IDE channel driven by this driver, this is * called by one of the 2 probe functions (macio or PCI). */ -static int __devinit -pmac_ide_setup_device (pmac_ide_hwif_t *pmif,ide_hwif_t *hwif,hw_regs_t *hw) +static int __devinit pmac_ide_setup_device (pmac_ide_hwif_t *pmif,hw_regs_t *hw) {struct device_node *np = pmif->node;const int *bidp; +ide_hwif_t *hwif;u8 idx[4 ] = {0xff ,0xff ,0xff ,0xff };struct ide_port_info d = pmac_port_info;
@@ -1073,16 +1076,21 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmsleep (jiffies_to_msecs (IDE_WAKEUP_DELAY )); } + printk(KERN_INFO DRV_NAME ": Found Apple %s controller (%s), " +"bus ID %d%s, irq %d\n" , model_name[pmif->kind], + pmif->mdev ?"MacIO" :"PCI" , pmif->aapl_bus_id, + pmif->mediabay ? " (mediabay)" : "", hw.irq); + + hwif =ide_find_port_slot (&d); +if (hwif ==NULL ) +return -ENOENT ; +/* Setup MMIO ops */ default_hwif_mmiops (hwif); hwif->OUTBSYNC = pmac_outbsync;ide_init_port_hw (hwif, hw); -printk (KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n" , - hwif->index, model_name[pmif->kind], pmif->aapl_bus_id, - pmif->mediabay ?" (mediabay)" :"" , hwif->irq); - idx[0 ] = hwif->index;ide_device_add (idx, &d);
@@ -1112,7 +1120,6 @@ pmac_ide_macio_attach(struct macio_dev * {void __iomem *base;unsigned long regbase; -ide_hwif_t *hwif;pmac_ide_hwif_t *pmif;int irq, rc;hw_regs_t hw;
@@ -1121,14 +1128,6 @@ pmac_ide_macio_attach(struct macio_dev *if (pmif ==NULL )return -ENOMEM ; - hwif =ide_find_port (); -if (hwif ==NULL ) { -printk (KERN_ERR "ide-pmac: MacIO interface attach with no slot\n" ); -printk (KERN_ERR " %s\n" , mdev->ofdev.node->full_name); - rc = -ENODEV ; - goto out_free_pmif; - } -if (macio_resource_count (mdev) ==0 ) {printk (KERN_WARNING "ide-pmac: no address for %s\n" , mdev->ofdev.node->full_name);
@@ -1183,7 +1182,7 @@ pmac_ide_macio_attach(struct macio_dev * hw.dev = &mdev->bus->pdev->dev; hw.parent = &mdev->ofdev.dev; - rc =pmac_ide_setup_device (pmif, hwif, &hw); + rc =pmac_ide_setup_device (pmif, &hw);if (rc !=0 ) {/* The inteface is released to the common IDE layer */ dev_set_drvdata (&mdev->ofdev.dev,NULL );
@@ -1242,7 +1241,6 @@ pmac_ide_macio_resume(struct macio_dev *static int __devinit pmac_ide_pci_attach (struct pci_dev *pdev,const struct pci_device_id *id) { -ide_hwif_t *hwif;struct device_node *np;pmac_ide_hwif_t *pmif;void __iomem *base;
@@ -1260,14 +1258,6 @@ pmac_ide_pci_attach(struct pci_dev *pdevif (pmif ==NULL )return -ENOMEM ; - hwif =ide_find_port (); -if (hwif ==NULL ) { -printk (KERN_ERR "ide-pmac: PCI interface attach with no slot\n" ); -printk (KERN_ERR " %s\n" , np->full_name); - rc = -ENODEV ; - goto out_free_pmif; - } -if (pci_enable_device (pdev)) {printk (KERN_WARNING "ide-pmac: Can't enable PCI device for " "%s\n" , np->full_name);
@@ -1304,7 +1294,7 @@ pmac_ide_pci_attach(struct pci_dev *pdev hw.irq = pdev->irq; hw.dev = &pdev->dev; - rc =pmac_ide_setup_device (pmif, hwif, &hw); + rc =pmac_ide_setup_device (pmif, &hw);if (rc !=0 ) {/* The inteface is released to the common IDE layer */ pci_set_drvdata (pdev,NULL );