diff options
author | David Brownell <david-b@pacbell.net> | 2006-08-15 02:11:03 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-09-26 00:08:37 -0400 |
commit | 8b4b8a24e4e49dc9fe36d4d079f6d2c23f942b03 (patch) | |
tree | f8c2a452bff75b013182dd90996eef0aa760042c | |
parent | 8f4bcc20ee39f9c087f3532672e3e5f086e92281 (diff) |
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 <dbrownell@users.sourceforge.net>
Acked-by: Pavel Machek <pavel@ucw.cz>
Cc: Greg KH <greg@kroah.com>
Cc: Paul Mackerras <paulus@samba.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/ide/ppc/pmac.c | 14 | ||||
-rw-r--r-- | drivers/media/dvb/cinergyT2/cinergyT2.c | 2 | ||||
-rw-r--r-- | drivers/scsi/mesh.c | 15 |
3 files changed, 20 insertions, 11 deletions
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c index 996c694341bc..31ad79f52df7 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) | |||
1369 | } | 1369 | } |
1370 | 1370 | ||
1371 | static int | 1371 | static int |
1372 | pmac_ide_macio_suspend(struct macio_dev *mdev, pm_message_t state) | 1372 | pmac_ide_macio_suspend(struct macio_dev *mdev, pm_message_t mesg) |
1373 | { | 1373 | { |
1374 | ide_hwif_t *hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev); | 1374 | ide_hwif_t *hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev); |
1375 | int rc = 0; | 1375 | int rc = 0; |
1376 | 1376 | ||
1377 | if (state.event != mdev->ofdev.dev.power.power_state.event && state.event >= PM_EVENT_SUSPEND) { | 1377 | if (mesg.event != mdev->ofdev.dev.power.power_state.event |
1378 | && mesg.event == PM_EVENT_SUSPEND) { | ||
1378 | rc = pmac_ide_do_suspend(hwif); | 1379 | rc = pmac_ide_do_suspend(hwif); |
1379 | if (rc == 0) | 1380 | if (rc == 0) |
1380 | mdev->ofdev.dev.power.power_state = state; | 1381 | mdev->ofdev.dev.power.power_state = mesg; |
1381 | } | 1382 | } |
1382 | 1383 | ||
1383 | return rc; | 1384 | return rc; |
@@ -1473,15 +1474,16 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1473 | } | 1474 | } |
1474 | 1475 | ||
1475 | static int | 1476 | static int |
1476 | pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t state) | 1477 | pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t mesg) |
1477 | { | 1478 | { |
1478 | ide_hwif_t *hwif = (ide_hwif_t *)pci_get_drvdata(pdev); | 1479 | ide_hwif_t *hwif = (ide_hwif_t *)pci_get_drvdata(pdev); |
1479 | int rc = 0; | 1480 | int rc = 0; |
1480 | 1481 | ||
1481 | if (state.event != pdev->dev.power.power_state.event && state.event >= 2) { | 1482 | if (mesg.event != pdev->dev.power.power_state.event |
1483 | && mesg.event == PM_EVENT_SUSPEND) { | ||
1482 | rc = pmac_ide_do_suspend(hwif); | 1484 | rc = pmac_ide_do_suspend(hwif); |
1483 | if (rc == 0) | 1485 | if (rc == 0) |
1484 | pdev->dev.power.power_state = state; | 1486 | pdev->dev.power.power_state = mesg; |
1485 | } | 1487 | } |
1486 | 1488 | ||
1487 | return rc; | 1489 | return rc; |
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c index 001c71b6be61..410fa6d620ff 100644 --- a/drivers/media/dvb/cinergyT2/cinergyT2.c +++ b/drivers/media/dvb/cinergyT2/cinergyT2.c | |||
@@ -981,7 +981,7 @@ static int cinergyt2_suspend (struct usb_interface *intf, pm_message_t state) | |||
981 | if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem)) | 981 | if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem)) |
982 | return -ERESTARTSYS; | 982 | return -ERESTARTSYS; |
983 | 983 | ||
984 | if (state.event > PM_EVENT_ON) { | 984 | if (1) { |
985 | struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf); | 985 | struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf); |
986 | 986 | ||
987 | cinergyt2_suspend_rc(cinergyt2); | 987 | cinergyt2_suspend_rc(cinergyt2); |
diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c index 592b52afe658..683fc7ae4b8f 100644 --- a/drivers/scsi/mesh.c +++ b/drivers/scsi/mesh.c | |||
@@ -1756,16 +1756,23 @@ static void set_mesh_power(struct mesh_state *ms, int state) | |||
1756 | pmac_call_feature(PMAC_FTR_MESH_ENABLE, macio_get_of_node(ms->mdev), 0, 0); | 1756 | pmac_call_feature(PMAC_FTR_MESH_ENABLE, macio_get_of_node(ms->mdev), 0, 0); |
1757 | msleep(10); | 1757 | msleep(10); |
1758 | } | 1758 | } |
1759 | } | 1759 | } |
1760 | 1760 | ||
1761 | 1761 | ||
1762 | #ifdef CONFIG_PM | 1762 | #ifdef CONFIG_PM |
1763 | static int mesh_suspend(struct macio_dev *mdev, pm_message_t state) | 1763 | static int mesh_suspend(struct macio_dev *mdev, pm_message_t mesg) |
1764 | { | 1764 | { |
1765 | struct mesh_state *ms = (struct mesh_state *)macio_get_drvdata(mdev); | 1765 | struct mesh_state *ms = (struct mesh_state *)macio_get_drvdata(mdev); |
1766 | unsigned long flags; | 1766 | unsigned long flags; |
1767 | 1767 | ||
1768 | if (state.event == mdev->ofdev.dev.power.power_state.event || state.event < 2) | 1768 | switch (mesg.event) { |
1769 | case PM_EVENT_SUSPEND: | ||
1770 | case PM_EVENT_FREEZE: | ||
1771 | break; | ||
1772 | default: | ||
1773 | return 0; | ||
1774 | } | ||
1775 | if (mesg.event == mdev->ofdev.dev.power.power_state.event) | ||
1769 | return 0; | 1776 | return 0; |
1770 | 1777 | ||
1771 | scsi_block_requests(ms->host); | 1778 | scsi_block_requests(ms->host); |
@@ -1780,7 +1787,7 @@ static int mesh_suspend(struct macio_dev *mdev, pm_message_t state) | |||
1780 | disable_irq(ms->meshintr); | 1787 | disable_irq(ms->meshintr); |
1781 | set_mesh_power(ms, 0); | 1788 | set_mesh_power(ms, 0); |
1782 | 1789 | ||
1783 | mdev->ofdev.dev.power.power_state = state; | 1790 | mdev->ofdev.dev.power.power_state = mesg; |
1784 | 1791 | ||
1785 | return 0; | 1792 | return 0; |
1786 | } | 1793 | } |