aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ppc/pmac.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 13:55:48 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-07-23 13:55:48 -0400
commit7b8797acd499d59ed03c7a5b98d82cdf054fd04d (patch)
treecc488646f451399a7d13869969944c4d7a8fc236 /drivers/ide/ppc/pmac.c
parentc010b2f76c3032e48097a6eef291d8593d5d79a6 (diff)
ide-pmac: store pmif instead of hwif in ->driver_data (take 2)
* 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. v2: * Build fixes from Stephen Rothwell. There should be no functional changes caused by this patch. Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ppc/pmac.c')
-rw-r--r--drivers/ide/ppc/pmac.c97
1 files changed, 57 insertions, 40 deletions
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index 93fb9067c043..9244b58e0548 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -424,7 +424,9 @@ static void pmac_ide_kauai_selectproc(ide_drive_t *drive);
424static void 424static void
425pmac_ide_selectproc(ide_drive_t *drive) 425pmac_ide_selectproc(ide_drive_t *drive)
426{ 426{
427 pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; 427 ide_hwif_t *hwif = drive->hwif;
428 pmac_ide_hwif_t *pmif =
429 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
428 430
429 if (pmif == NULL) 431 if (pmif == NULL)
430 return; 432 return;
@@ -444,7 +446,9 @@ pmac_ide_selectproc(ide_drive_t *drive)
444static void 446static void
445pmac_ide_kauai_selectproc(ide_drive_t *drive) 447pmac_ide_kauai_selectproc(ide_drive_t *drive)
446{ 448{
447 pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; 449 ide_hwif_t *hwif = drive->hwif;
450 pmac_ide_hwif_t *pmif =
451 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
448 452
449 if (pmif == NULL) 453 if (pmif == NULL)
450 return; 454 return;
@@ -465,7 +469,9 @@ pmac_ide_kauai_selectproc(ide_drive_t *drive)
465static void 469static void
466pmac_ide_do_update_timings(ide_drive_t *drive) 470pmac_ide_do_update_timings(ide_drive_t *drive)
467{ 471{
468 pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; 472 ide_hwif_t *hwif = drive->hwif;
473 pmac_ide_hwif_t *pmif =
474 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
469 475
470 if (pmif == NULL) 476 if (pmif == NULL)
471 return; 477 return;
@@ -493,11 +499,13 @@ static void pmac_outbsync(ide_hwif_t *hwif, u8 value, unsigned long port)
493static void 499static void
494pmac_ide_set_pio_mode(ide_drive_t *drive, const u8 pio) 500pmac_ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
495{ 501{
502 ide_hwif_t *hwif = drive->hwif;
503 pmac_ide_hwif_t *pmif =
504 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
496 struct ide_timing *tim = ide_timing_find_mode(XFER_PIO_0 + pio); 505 struct ide_timing *tim = ide_timing_find_mode(XFER_PIO_0 + pio);
497 u32 *timings, t; 506 u32 *timings, t;
498 unsigned accessTicks, recTicks; 507 unsigned accessTicks, recTicks;
499 unsigned accessTime, recTime; 508 unsigned accessTime, recTime;
500 pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
501 unsigned int cycle_time; 509 unsigned int cycle_time;
502 510
503 if (pmif == NULL) 511 if (pmif == NULL)
@@ -778,9 +786,11 @@ set_timings_mdma(ide_drive_t *drive, int intf_type, u32 *timings, u32 *timings2,
778 786
779static void pmac_ide_set_dma_mode(ide_drive_t *drive, const u8 speed) 787static void pmac_ide_set_dma_mode(ide_drive_t *drive, const u8 speed)
780{ 788{
789 ide_hwif_t *hwif = drive->hwif;
790 pmac_ide_hwif_t *pmif =
791 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
781 int unit = (drive->select.b.unit & 0x01); 792 int unit = (drive->select.b.unit & 0x01);
782 int ret = 0; 793 int ret = 0;
783 pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data;
784 u32 *timings, *timings2, tl[2]; 794 u32 *timings, *timings2, tl[2];
785 795
786 timings = &pmif->timings[unit]; 796 timings = &pmif->timings[unit];
@@ -852,11 +862,8 @@ sanitize_timings(pmac_ide_hwif_t *pmif)
852/* Suspend call back, should be called after the child devices 862/* Suspend call back, should be called after the child devices
853 * have actually been suspended 863 * have actually been suspended
854 */ 864 */
855static int 865static int pmac_ide_do_suspend(pmac_ide_hwif_t *pmif)
856pmac_ide_do_suspend(ide_hwif_t *hwif)
857{ 866{
858 pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
859
860 /* We clear the timings */ 867 /* We clear the timings */
861 pmif->timings[0] = 0; 868 pmif->timings[0] = 0;
862 pmif->timings[1] = 0; 869 pmif->timings[1] = 0;
@@ -884,11 +891,8 @@ pmac_ide_do_suspend(ide_hwif_t *hwif)
884/* Resume call back, should be called before the child devices 891/* Resume call back, should be called before the child devices
885 * are resumed 892 * are resumed
886 */ 893 */
887static int 894static int pmac_ide_do_resume(pmac_ide_hwif_t *pmif)
888pmac_ide_do_resume(ide_hwif_t *hwif)
889{ 895{
890 pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
891
892 /* Hard reset & re-enable controller (do we really need to reset ? -BenH) */ 896 /* Hard reset & re-enable controller (do we really need to reset ? -BenH) */
893 if (!pmif->mediabay) { 897 if (!pmif->mediabay) {
894 ppc_md.feature_call(PMAC_FTR_IDE_RESET, pmif->node, pmif->aapl_bus_id, 1); 898 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)
916 920
917static u8 pmac_ide_cable_detect(ide_hwif_t *hwif) 921static u8 pmac_ide_cable_detect(ide_hwif_t *hwif)
918{ 922{
919 pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)ide_get_hwifdata(hwif); 923 pmac_ide_hwif_t *pmif =
924 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
920 struct device_node *np = pmif->node; 925 struct device_node *np = pmif->node;
921 const char *cable = of_get_property(np, "cable-type", NULL); 926 const char *cable = of_get_property(np, "cable-type", NULL);
922 927
@@ -1058,7 +1063,6 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw)
1058 default_hwif_mmiops(hwif); 1063 default_hwif_mmiops(hwif);
1059 hwif->OUTBSYNC = pmac_outbsync; 1064 hwif->OUTBSYNC = pmac_outbsync;
1060 1065
1061 hwif->hwif_data = pmif;
1062 ide_init_port_hw(hwif, hw); 1066 ide_init_port_hw(hwif, hw);
1063 1067
1064 printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n", 1068 printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n",
@@ -1164,7 +1168,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1164 } else 1168 } else
1165 pmif->dma_regs = NULL; 1169 pmif->dma_regs = NULL;
1166#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ 1170#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
1167 dev_set_drvdata(&mdev->ofdev.dev, hwif); 1171 dev_set_drvdata(&mdev->ofdev.dev, pmif);
1168 1172
1169 memset(&hw, 0, sizeof(hw)); 1173 memset(&hw, 0, sizeof(hw));
1170 pmac_ide_init_ports(&hw, pmif->regbase); 1174 pmac_ide_init_ports(&hw, pmif->regbase);
@@ -1195,12 +1199,13 @@ out_free_pmif:
1195static int 1199static int
1196pmac_ide_macio_suspend(struct macio_dev *mdev, pm_message_t mesg) 1200pmac_ide_macio_suspend(struct macio_dev *mdev, pm_message_t mesg)
1197{ 1201{
1198 ide_hwif_t *hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev); 1202 pmac_ide_hwif_t *pmif =
1199 int rc = 0; 1203 (pmac_ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev);
1204 int rc = 0;
1200 1205
1201 if (mesg.event != mdev->ofdev.dev.power.power_state.event 1206 if (mesg.event != mdev->ofdev.dev.power.power_state.event
1202 && (mesg.event & PM_EVENT_SLEEP)) { 1207 && (mesg.event & PM_EVENT_SLEEP)) {
1203 rc = pmac_ide_do_suspend(hwif); 1208 rc = pmac_ide_do_suspend(pmif);
1204 if (rc == 0) 1209 if (rc == 0)
1205 mdev->ofdev.dev.power.power_state = mesg; 1210 mdev->ofdev.dev.power.power_state = mesg;
1206 } 1211 }
@@ -1211,11 +1216,12 @@ pmac_ide_macio_suspend(struct macio_dev *mdev, pm_message_t mesg)
1211static int 1216static int
1212pmac_ide_macio_resume(struct macio_dev *mdev) 1217pmac_ide_macio_resume(struct macio_dev *mdev)
1213{ 1218{
1214 ide_hwif_t *hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev); 1219 pmac_ide_hwif_t *pmif =
1215 int rc = 0; 1220 (pmac_ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev);
1216 1221 int rc = 0;
1222
1217 if (mdev->ofdev.dev.power.power_state.event != PM_EVENT_ON) { 1223 if (mdev->ofdev.dev.power.power_state.event != PM_EVENT_ON) {
1218 rc = pmac_ide_do_resume(hwif); 1224 rc = pmac_ide_do_resume(pmif);
1219 if (rc == 0) 1225 if (rc == 0)
1220 mdev->ofdev.dev.power.power_state = PMSG_ON; 1226 mdev->ofdev.dev.power.power_state = PMSG_ON;
1221 } 1227 }
@@ -1284,7 +1290,7 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1284 pmif->kauai_fcr = base; 1290 pmif->kauai_fcr = base;
1285 pmif->irq = pdev->irq; 1291 pmif->irq = pdev->irq;
1286 1292
1287 pci_set_drvdata(pdev, hwif); 1293 pci_set_drvdata(pdev, pmif);
1288 1294
1289 memset(&hw, 0, sizeof(hw)); 1295 memset(&hw, 0, sizeof(hw));
1290 pmac_ide_init_ports(&hw, pmif->regbase); 1296 pmac_ide_init_ports(&hw, pmif->regbase);
@@ -1310,12 +1316,12 @@ out_free_pmif:
1310static int 1316static int
1311pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t mesg) 1317pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
1312{ 1318{
1313 ide_hwif_t *hwif = (ide_hwif_t *)pci_get_drvdata(pdev); 1319 pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)pci_get_drvdata(pdev);
1314 int rc = 0; 1320 int rc = 0;
1315 1321
1316 if (mesg.event != pdev->dev.power.power_state.event 1322 if (mesg.event != pdev->dev.power.power_state.event
1317 && (mesg.event & PM_EVENT_SLEEP)) { 1323 && (mesg.event & PM_EVENT_SLEEP)) {
1318 rc = pmac_ide_do_suspend(hwif); 1324 rc = pmac_ide_do_suspend(pmif);
1319 if (rc == 0) 1325 if (rc == 0)
1320 pdev->dev.power.power_state = mesg; 1326 pdev->dev.power.power_state = mesg;
1321 } 1327 }
@@ -1326,11 +1332,11 @@ pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
1326static int 1332static int
1327pmac_ide_pci_resume(struct pci_dev *pdev) 1333pmac_ide_pci_resume(struct pci_dev *pdev)
1328{ 1334{
1329 ide_hwif_t *hwif = (ide_hwif_t *)pci_get_drvdata(pdev); 1335 pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)pci_get_drvdata(pdev);
1330 int rc = 0; 1336 int rc = 0;
1331 1337
1332 if (pdev->dev.power.power_state.event != PM_EVENT_ON) { 1338 if (pdev->dev.power.power_state.event != PM_EVENT_ON) {
1333 rc = pmac_ide_do_resume(hwif); 1339 rc = pmac_ide_do_resume(pmif);
1334 if (rc == 0) 1340 if (rc == 0)
1335 pdev->dev.power.power_state = PMSG_ON; 1341 pdev->dev.power.power_state = PMSG_ON;
1336 } 1342 }
@@ -1421,10 +1427,11 @@ out:
1421static int 1427static int
1422pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq) 1428pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq)
1423{ 1429{
1430 ide_hwif_t *hwif = drive->hwif;
1431 pmac_ide_hwif_t *pmif =
1432 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
1424 struct dbdma_cmd *table; 1433 struct dbdma_cmd *table;
1425 int i, count = 0; 1434 int i, count = 0;
1426 ide_hwif_t *hwif = HWIF(drive);
1427 pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data;
1428 volatile struct dbdma_regs __iomem *dma = pmif->dma_regs; 1435 volatile struct dbdma_regs __iomem *dma = pmif->dma_regs;
1429 struct scatterlist *sg; 1436 struct scatterlist *sg;
1430 int wr = (rq_data_dir(rq) == WRITE); 1437 int wr = (rq_data_dir(rq) == WRITE);
@@ -1520,7 +1527,8 @@ static int
1520pmac_ide_dma_setup(ide_drive_t *drive) 1527pmac_ide_dma_setup(ide_drive_t *drive)
1521{ 1528{
1522 ide_hwif_t *hwif = HWIF(drive); 1529 ide_hwif_t *hwif = HWIF(drive);
1523 pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data; 1530 pmac_ide_hwif_t *pmif =
1531 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
1524 struct request *rq = HWGROUP(drive)->rq; 1532 struct request *rq = HWGROUP(drive)->rq;
1525 u8 unit = (drive->select.b.unit & 0x01); 1533 u8 unit = (drive->select.b.unit & 0x01);
1526 u8 ata4; 1534 u8 ata4;
@@ -1560,7 +1568,9 @@ pmac_ide_dma_exec_cmd(ide_drive_t *drive, u8 command)
1560static void 1568static void
1561pmac_ide_dma_start(ide_drive_t *drive) 1569pmac_ide_dma_start(ide_drive_t *drive)
1562{ 1570{
1563 pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; 1571 ide_hwif_t *hwif = drive->hwif;
1572 pmac_ide_hwif_t *pmif =
1573 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
1564 volatile struct dbdma_regs __iomem *dma; 1574 volatile struct dbdma_regs __iomem *dma;
1565 1575
1566 dma = pmif->dma_regs; 1576 dma = pmif->dma_regs;
@@ -1576,7 +1586,9 @@ pmac_ide_dma_start(ide_drive_t *drive)
1576static int 1586static int
1577pmac_ide_dma_end (ide_drive_t *drive) 1587pmac_ide_dma_end (ide_drive_t *drive)
1578{ 1588{
1579 pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; 1589 ide_hwif_t *hwif = drive->hwif;
1590 pmac_ide_hwif_t *pmif =
1591 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
1580 volatile struct dbdma_regs __iomem *dma; 1592 volatile struct dbdma_regs __iomem *dma;
1581 u32 dstat; 1593 u32 dstat;
1582 1594
@@ -1604,7 +1616,9 @@ pmac_ide_dma_end (ide_drive_t *drive)
1604static int 1616static int
1605pmac_ide_dma_test_irq (ide_drive_t *drive) 1617pmac_ide_dma_test_irq (ide_drive_t *drive)
1606{ 1618{
1607 pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; 1619 ide_hwif_t *hwif = drive->hwif;
1620 pmac_ide_hwif_t *pmif =
1621 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
1608 volatile struct dbdma_regs __iomem *dma; 1622 volatile struct dbdma_regs __iomem *dma;
1609 unsigned long status, timeout; 1623 unsigned long status, timeout;
1610 1624
@@ -1664,7 +1678,9 @@ static void pmac_ide_dma_host_set(ide_drive_t *drive, int on)
1664static void 1678static void
1665pmac_ide_dma_lost_irq (ide_drive_t *drive) 1679pmac_ide_dma_lost_irq (ide_drive_t *drive)
1666{ 1680{
1667 pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)HWIF(drive)->hwif_data; 1681 ide_hwif_t *hwif = drive->hwif;
1682 pmac_ide_hwif_t *pmif =
1683 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
1668 volatile struct dbdma_regs __iomem *dma; 1684 volatile struct dbdma_regs __iomem *dma;
1669 unsigned long status; 1685 unsigned long status;
1670 1686
@@ -1694,7 +1710,8 @@ static const struct ide_dma_ops pmac_dma_ops = {
1694static int __devinit pmac_ide_init_dma(ide_hwif_t *hwif, 1710static int __devinit pmac_ide_init_dma(ide_hwif_t *hwif,
1695 const struct ide_port_info *d) 1711 const struct ide_port_info *d)
1696{ 1712{
1697 pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data; 1713 pmac_ide_hwif_t *pmif =
1714 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent);
1698 struct pci_dev *dev = to_pci_dev(hwif->dev); 1715 struct pci_dev *dev = to_pci_dev(hwif->dev);
1699 1716
1700 /* We won't need pci_dev if we switch to generic consistent 1717 /* We won't need pci_dev if we switch to generic consistent