From 8b4b8a24e4e49dc9fe36d4d079f6d2c23f942b03 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Mon, 14 Aug 2006 23:11:03 -0700 Subject: fix broken/dubious driver suspend() methods Small driver suspend() fixes in preparation for the PRETHAW events: - Only compare message events for equality against PM_EVENT_* codes; not against integers, or using greater/less-than comparisons. (PM_EVENT_* should really become a __bitwise thing.) - Explicitly test for SUSPEND events (rather than not-something-else) before suspending devices. - Removes more of the confusion between a pm_message_t (wraps event code) and a "state" ... suspend() originally took a target system state. These updates are correct and appropriate even without new PM_EVENT codes. benh: "I think in the Mesh case, we should handle the freeze case as well or we might get wild DMA." Signed-off-by: David Brownell Acked-by: Pavel Machek Cc: Greg KH Cc: Paul Mackerras Acked-by: Benjamin Herrenschmidt Cc: Mauro Carvalho Chehab Cc: James Bottomley Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/ide/ppc/pmac.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'drivers/ide/ppc') diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c index 996c694341b..31ad79f52df 100644 --- a/drivers/ide/ppc/pmac.c +++ b/drivers/ide/ppc/pmac.c @@ -1369,15 +1369,16 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match) } static int -pmac_ide_macio_suspend(struct macio_dev *mdev, pm_message_t state) +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; - if (state.event != mdev->ofdev.dev.power.power_state.event && state.event >= PM_EVENT_SUSPEND) { + if (mesg.event != mdev->ofdev.dev.power.power_state.event + && mesg.event == PM_EVENT_SUSPEND) { rc = pmac_ide_do_suspend(hwif); if (rc == 0) - mdev->ofdev.dev.power.power_state = state; + mdev->ofdev.dev.power.power_state = mesg; } return rc; @@ -1473,15 +1474,16 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id) } static int -pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t state) +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; - if (state.event != pdev->dev.power.power_state.event && state.event >= 2) { + if (mesg.event != pdev->dev.power.power_state.event + && mesg.event == PM_EVENT_SUSPEND) { rc = pmac_ide_do_suspend(hwif); if (rc == 0) - pdev->dev.power.power_state = state; + pdev->dev.power.power_state = mesg; } return rc; -- cgit v1.2.3-70-g09d2