Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ieee1394: ohci1394: suspend/resume cosmetics

Reorder the definitions of ohci1394_pci_suspend and _resume. Remove
redundant comments. Beautify return statements.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>

+57 -87
+57 -87
drivers/ieee1394/ohci1394.c
··· 3529 3529 } 3530 3530 3531 3531 #ifdef CONFIG_PM 3532 - static int ohci1394_pci_resume (struct pci_dev *pdev) 3532 + static int ohci1394_pci_suspend(struct pci_dev *pdev, pm_message_t state) 3533 3533 { 3534 3534 int err; 3535 - struct ti_ohci *ohci; 3535 + struct ti_ohci *ohci = pci_get_drvdata(pdev); 3536 + 3537 + PRINT(KERN_DEBUG, "suspend called"); 3538 + if (!ohci) 3539 + return -ENXIO; 3540 + 3541 + /* Clear the async DMA contexts and stop using the controller */ 3542 + hpsb_bus_reset(ohci->host); 3543 + 3544 + /* See ohci1394_pci_remove() for comments on this sequence */ 3545 + reg_write(ohci, OHCI1394_ConfigROMhdr, 0); 3546 + reg_write(ohci, OHCI1394_BusOptions, 3547 + (reg_read(ohci, OHCI1394_BusOptions) & 0x0000f007) | 3548 + 0x00ff0000); 3549 + reg_write(ohci, OHCI1394_IntMaskClear, 0xffffffff); 3550 + reg_write(ohci, OHCI1394_IntEventClear, 0xffffffff); 3551 + reg_write(ohci, OHCI1394_IsoXmitIntMaskClear, 0xffffffff); 3552 + reg_write(ohci, OHCI1394_IsoXmitIntEventClear, 0xffffffff); 3553 + reg_write(ohci, OHCI1394_IsoRecvIntMaskClear, 0xffffffff); 3554 + reg_write(ohci, OHCI1394_IsoRecvIntEventClear, 0xffffffff); 3555 + set_phy_reg(ohci, 4, ~0xc0 & get_phy_reg(ohci, 4)); 3556 + reg_write(ohci, OHCI1394_LinkControlClear, 0xffffffff); 3557 + ohci_devctl(ohci->host, RESET_BUS, LONG_RESET_NO_FORCE_ROOT); 3558 + ohci_soft_reset(ohci); 3559 + 3560 + err = pci_save_state(pdev); 3561 + if (err) 3562 + return err; 3563 + err = pci_set_power_state(pdev, pci_choose_state(pdev, state)); 3564 + if (err) 3565 + return err; 3566 + 3567 + /* PowerMac suspend code comes last */ 3568 + #ifdef CONFIG_PPC_PMAC 3569 + if (machine_is(powermac)) { 3570 + struct device_node *of_node; 3571 + 3572 + /* Disable 1394 */ 3573 + of_node = pci_device_to_OF_node (pdev); 3574 + if (of_node) 3575 + pmac_call_feature(PMAC_FTR_1394_ENABLE, of_node, 0, 0); 3576 + } 3577 + #endif /* CONFIG_PPC_PMAC */ 3578 + 3579 + return 0; 3580 + } 3581 + 3582 + static int ohci1394_pci_resume(struct pci_dev *pdev) 3583 + { 3584 + int err; 3585 + struct ti_ohci *ohci = pci_get_drvdata(pdev); 3586 + 3587 + PRINT(KERN_DEBUG, "resume called"); 3588 + if (!ohci) 3589 + return -ENXIO; 3536 3590 3537 3591 /* PowerMac resume code comes first */ 3538 3592 #ifdef CONFIG_PPC_PMAC ··· 3606 3552 if (err) 3607 3553 return err; 3608 3554 3609 - ohci = pci_get_drvdata(pdev); 3610 - if (!ohci) 3611 - return -1; /* or which exit status to use? */ 3612 - 3613 - PRINT(KERN_DEBUG, "resume called"); 3614 - 3615 - /* The following lines are copied from ohci1394_pci_probe(): */ 3616 - 3617 - /* Start off with a soft reset, to clear everything to a sane 3618 - * state. */ 3555 + /* See ohci1394_pci_probe() for comments on this sequence */ 3619 3556 ohci_soft_reset(ohci); 3620 - 3621 - /* Now enable LPS, which we need in order to start accessing 3622 - * most of the registers. In fact, on some cards (ALI M5251), 3623 - * accessing registers in the SClk domain without LPS enabled 3624 - * will lock up the machine. Wait 50msec to make sure we have 3625 - * full link enabled. */ 3626 3557 reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_LPS); 3627 - 3628 - /* Disable and clear interrupts */ 3629 3558 reg_write(ohci, OHCI1394_IntEventClear, 0xffffffff); 3630 3559 reg_write(ohci, OHCI1394_IntMaskClear, 0xffffffff); 3631 - 3632 3560 mdelay(50); 3633 - 3634 3561 ohci_initialize(ohci); 3635 3562 3636 3563 return 0; 3637 - } 3638 - 3639 - static int ohci1394_pci_suspend (struct pci_dev *pdev, pm_message_t state) 3640 - { 3641 - int err; 3642 - struct ti_ohci *ohci; 3643 - 3644 - ohci = pci_get_drvdata(pdev); 3645 - if (!ohci) 3646 - return -1; /* Not sure if this is the correct return code */ 3647 - 3648 - PRINT(KERN_DEBUG, "suspend called"); 3649 - 3650 - /* clear the async DMA contexts and stop using the controller: */ 3651 - hpsb_bus_reset(ohci->host); 3652 - 3653 - /* The following calls are from ohci1394_pci_remove(): */ 3654 - 3655 - /* Clear out BUS Options */ 3656 - reg_write(ohci, OHCI1394_ConfigROMhdr, 0); 3657 - reg_write(ohci, OHCI1394_BusOptions, 3658 - (reg_read(ohci, OHCI1394_BusOptions) & 0x0000f007) | 3659 - 0x00ff0000); 3660 - 3661 - /* Clear interrupt registers */ 3662 - reg_write(ohci, OHCI1394_IntMaskClear, 0xffffffff); 3663 - reg_write(ohci, OHCI1394_IntEventClear, 0xffffffff); 3664 - reg_write(ohci, OHCI1394_IsoXmitIntMaskClear, 0xffffffff); 3665 - reg_write(ohci, OHCI1394_IsoXmitIntEventClear, 0xffffffff); 3666 - reg_write(ohci, OHCI1394_IsoRecvIntMaskClear, 0xffffffff); 3667 - reg_write(ohci, OHCI1394_IsoRecvIntEventClear, 0xffffffff); 3668 - 3669 - /* Disable IRM Contender */ 3670 - set_phy_reg(ohci, 4, ~0xc0 & get_phy_reg(ohci, 4)); 3671 - 3672 - /* Clear link control register */ 3673 - reg_write(ohci, OHCI1394_LinkControlClear, 0xffffffff); 3674 - 3675 - /* Let all other nodes know to ignore us */ 3676 - ohci_devctl(ohci->host, RESET_BUS, LONG_RESET_NO_FORCE_ROOT); 3677 - 3678 - /* This stops all DMA contexts, disables interrupts, 3679 - * and clears linkEnable and LPS: */ 3680 - ohci_soft_reset(ohci); 3681 - 3682 - err = pci_save_state(pdev); 3683 - if (err) 3684 - goto out; 3685 - err = pci_set_power_state(pdev, pci_choose_state(pdev, state)); 3686 - if (err) 3687 - goto out; 3688 - 3689 - /* PowerMac suspend code comes last */ 3690 - #ifdef CONFIG_PPC_PMAC 3691 - if (machine_is(powermac)) { 3692 - struct device_node *of_node; 3693 - 3694 - /* Disable 1394 */ 3695 - of_node = pci_device_to_OF_node (pdev); 3696 - if (of_node) 3697 - pmac_call_feature(PMAC_FTR_1394_ENABLE, of_node, 0, 0); 3698 - } 3699 - #endif /* CONFIG_PPC_PMAC */ 3700 - out: 3701 - return err; 3702 3564 } 3703 3565 #endif /* CONFIG_PM */ 3704 3566