[PATCH] swsusp: switch pm_message_t to struct
authorPavel Machek <pavel@ucw.cz>
Sat, 3 Sep 2005 22:56:57 +0000 (15:56 -0700)
committerLinus Torvalds <torvalds@evo.osdl.org>
Mon, 5 Sep 2005 07:06:16 +0000 (00:06 -0700)
This adds type-checking to pm_message_t, so that people can't confuse it
with int or u32.  It also allows us to fix "disk yoyo" during suspend (disk
spinning down/up/down).

[We've tried that before; since that cpufreq problems were fixed and I've
tried make allyes config and fixed resulting damage.]

Signed-off-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Alexander Nyberg <alexn@telia.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
28 files changed:
arch/ppc/syslib/of_device.c
drivers/base/power/resume.c
drivers/base/power/runtime.c
drivers/base/power/suspend.c
drivers/base/power/sysfs.c
drivers/ide/ide.c
drivers/ide/pci/sc1200.c
drivers/ide/ppc/pmac.c
drivers/macintosh/mediabay.c
drivers/macintosh/via-pmu.c
drivers/media/dvb/cinergyT2/cinergyT2.c
drivers/net/irda/vlsi_ir.c
drivers/net/wireless/airo.c
drivers/pci/pci.c
drivers/scsi/mesh.c
drivers/serial/pmac_zilog.c
drivers/usb/core/hub.c
drivers/usb/core/usb.c
drivers/usb/host/ehci-dbg.c
drivers/usb/host/ohci-dbg.c
drivers/usb/host/sl811-hcd.c
drivers/usb/misc/usbtest.c
drivers/video/aty/aty128fb.c
drivers/video/aty/atyfb_base.c
drivers/video/aty/radeon_pm.c
drivers/video/chipsfb.c
drivers/video/i810/i810_main.c
include/linux/pm.h

index 1eb4f726ca9ffb09567d77489d9e5bf341f29357..da8a0f2128dccc23bc06cc8b3f8a93809384e7ec 100644 (file)
@@ -105,7 +105,7 @@ static int of_device_remove(struct device *dev)
        return 0;
 }
 
-static int of_device_suspend(struct device *dev, u32 state)
+static int of_device_suspend(struct device *dev, pm_message_t state)
 {
        struct of_device * of_dev = to_of_device(dev);
        struct of_platform_driver * drv = to_of_platform_driver(dev->driver);
index bdd96b03b8857a14367535bf408224b1eb939503..0a7aa07b9a2a600cc9b52992b8e0f0d44216af17 100644 (file)
@@ -26,11 +26,11 @@ int resume_device(struct device * dev)
 
        down(&dev->sem);
        if (dev->power.pm_parent
-                       && dev->power.pm_parent->power.power_state) {
+                       && dev->power.pm_parent->power.power_state.event) {
                dev_err(dev, "PM: resume from %d, parent %s still %d\n",
-                       dev->power.power_state,
+                       dev->power.power_state.event,
                        dev->power.pm_parent->bus_id,
-                       dev->power.pm_parent->power.power_state);
+                       dev->power.pm_parent->power.power_state.event);
        }
        if (dev->bus && dev->bus->resume) {
                dev_dbg(dev,"resuming\n");
@@ -54,7 +54,7 @@ void dpm_resume(void)
                list_add_tail(entry, &dpm_active);
 
                up(&dpm_list_sem);
-               if (!dev->power.prev_state)
+               if (!dev->power.prev_state.event)
                        resume_device(dev);
                down(&dpm_list_sem);
                put_device(dev);
index 325962d8019153d28316399ab7b5a8da3887293e..e8f0519f5dfa88566e3e49d34d0e637180793a7c 100644 (file)
 static void runtime_resume(struct device * dev)
 {
        dev_dbg(dev, "resuming\n");
-       if (!dev->power.power_state)
+       if (!dev->power.power_state.event)
                return;
        if (!resume_device(dev))
-               dev->power.power_state = 0;
+               dev->power.power_state = PMSG_ON;
 }
 
 
@@ -49,10 +49,10 @@ int dpm_runtime_suspend(struct device * dev, pm_message_t state)
        int error = 0;
 
        down(&dpm_sem);
-       if (dev->power.power_state == state)
+       if (dev->power.power_state.event == state.event)
                goto Done;
 
-       if (dev->power.power_state)
+       if (dev->power.power_state.event)
                runtime_resume(dev);
 
        if (!(error = suspend_device(dev, state)))
index 2ccee3763acfae23a3d1de899179dd5ac0ca9419..50501764d0508a6493256380df820eb35b8c96e1 100644 (file)
@@ -40,22 +40,22 @@ int suspend_device(struct device * dev, pm_message_t state)
        int error = 0;
 
        down(&dev->sem);
-       if (dev->power.power_state) {
+       if (dev->power.power_state.event) {
                dev_dbg(dev, "PM: suspend %d-->%d\n",
-                       dev->power.power_state, state);
+                       dev->power.power_state.event, state.event);
        }
        if (dev->power.pm_parent
-                       && dev->power.pm_parent->power.power_state) {
+                       && dev->power.pm_parent->power.power_state.event) {
                dev_err(dev,
                        "PM: suspend %d->%d, parent %s already %d\n",
-                       dev->power.power_state, state,
+                       dev->power.power_state.event, state.event,
                        dev->power.pm_parent->bus_id,
-                       dev->power.pm_parent->power.power_state);
+                       dev->power.pm_parent->power.power_state.event);
        }
 
        dev->power.prev_state = dev->power.power_state;
 
-       if (dev->bus && dev->bus->suspend && !dev->power.power_state) {
+       if (dev->bus && dev->bus->suspend && !dev->power.power_state.event) {
                dev_dbg(dev, "suspending\n");
                error = dev->bus->suspend(dev, state);
        }
index f82b3df9545f68b66cd1866862bc665a1f7e00c5..8d04fb435c176ebc92f89793cb5998d05721694b 100644 (file)
 
 static ssize_t state_show(struct device * dev, struct device_attribute *attr, char * buf)
 {
-       return sprintf(buf, "%u\n", dev->power.power_state);
+       return sprintf(buf, "%u\n", dev->power.power_state.event);
 }
 
 static ssize_t state_store(struct device * dev, struct device_attribute *attr, const char * buf, size_t n)
 {
-       u32 state;
+       pm_message_t state;
        char * rest;
        int error = 0;
 
-       state = simple_strtoul(buf, &rest, 10);
+       state.event = simple_strtoul(buf, &rest, 10);
        if (*rest)
                return -EINVAL;
-       if (state)
+       if (state.event)
                error = dpm_runtime_suspend(dev, state);
        else
                dpm_runtime_resume(dev);
index dae1bd5b8c3e1e16872af0eb5470ff93b3231230..73ca8f73917d9172bba616311437ccb3de9966e9 100644 (file)
@@ -1229,7 +1229,7 @@ static int generic_ide_suspend(struct device *dev, pm_message_t state)
        rq.special = &args;
        rq.pm = &rqpm;
        rqpm.pm_step = ide_pm_state_start_suspend;
-       rqpm.pm_state = state;
+       rqpm.pm_state = state.event;
 
        return ide_do_drive_cmd(drive, &rq, ide_wait);
 }
@@ -1248,7 +1248,7 @@ static int generic_ide_resume(struct device *dev)
        rq.special = &args;
        rq.pm = &rqpm;
        rqpm.pm_step = ide_pm_state_start_resume;
-       rqpm.pm_state = 0;
+       rqpm.pm_state = PM_EVENT_ON;
 
        return ide_do_drive_cmd(drive, &rq, ide_head_wait);
 }
index 10592cec6c43aca4e7bdf2443cff2d0dde5ca402..24e21b2838c15028bd4f72c4a2305ddf0b7b54a3 100644 (file)
@@ -350,9 +350,9 @@ static int sc1200_suspend (struct pci_dev *dev, pm_message_t state)
 {
        ide_hwif_t              *hwif = NULL;
 
-       printk("SC1200: suspend(%u)\n", state);
+       printk("SC1200: suspend(%u)\n", state.event);
 
-       if (state == 0) {
+       if (state.event == PM_EVENT_ON) {
                // we only save state when going from full power to less
 
                //
@@ -386,8 +386,8 @@ static int sc1200_suspend (struct pci_dev *dev, pm_message_t state)
        /* You don't need to iterate over disks -- sysfs should have done that for you already */ 
 
        pci_disable_device(dev);
-       pci_set_power_state(dev,state);
-       dev->current_state = state;
+       pci_set_power_state(dev, pci_choose_state(dev, state));
+       dev->current_state = state.event;
        return 0;
 }
 
@@ -396,8 +396,8 @@ static int sc1200_resume (struct pci_dev *dev)
        ide_hwif_t      *hwif = NULL;
 
 printk("SC1200: resume\n");
-       pci_set_power_state(dev,0);     // bring chip back from sleep state
-       dev->current_state = 0;
+       pci_set_power_state(dev, PCI_D0);       // bring chip back from sleep state
+       dev->current_state = PM_EVENT_ON;
        pci_enable_device(dev);
        //
        // loop over all interfaces that are part of this pci device:
index d2760b8ca1590c3e0294ac2a274fa88c41545d3c..87d1f8a1f41e4de7a0595d8702bf101276af2ba5 100644 (file)
@@ -1509,7 +1509,7 @@ pmac_ide_macio_suspend(struct macio_dev *mdev, pm_message_t state)
        ide_hwif_t      *hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev);
        int             rc = 0;
 
-       if (state != mdev->ofdev.dev.power.power_state && state >= 2) {
+       if (state.event != mdev->ofdev.dev.power.power_state.event && state.event >= PM_EVENT_SUSPEND) {
                rc = pmac_ide_do_suspend(hwif);
                if (rc == 0)
                        mdev->ofdev.dev.power.power_state = state;
@@ -1524,7 +1524,7 @@ pmac_ide_macio_resume(struct macio_dev *mdev)
        ide_hwif_t      *hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev);
        int             rc = 0;
        
-       if (mdev->ofdev.dev.power.power_state != 0) {
+       if (mdev->ofdev.dev.power.power_state.event != PM_EVENT_ON) {
                rc = pmac_ide_do_resume(hwif);
                if (rc == 0)
                        mdev->ofdev.dev.power.power_state = PMSG_ON;
@@ -1613,7 +1613,7 @@ pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t state)
        ide_hwif_t      *hwif = (ide_hwif_t *)pci_get_drvdata(pdev);
        int             rc = 0;
        
-       if (state != pdev->dev.power.power_state && state >= 2) {
+       if (state.event != pdev->dev.power.power_state.event && state.event >= 2) {
                rc = pmac_ide_do_suspend(hwif);
                if (rc == 0)
                        pdev->dev.power.power_state = state;
@@ -1628,7 +1628,7 @@ pmac_ide_pci_resume(struct pci_dev *pdev)
        ide_hwif_t      *hwif = (ide_hwif_t *)pci_get_drvdata(pdev);
        int             rc = 0;
        
-       if (pdev->dev.power.power_state != 0) {
+       if (pdev->dev.power.power_state.event != PM_EVENT_ON) {
                rc = pmac_ide_do_resume(hwif);
                if (rc == 0)
                        pdev->dev.power.power_state = PMSG_ON;
index 7e1afca75e4119b758bd87932ee01752cc723754..c0712a1ea5afabc9e7370371bf545fe11d1b118d 100644 (file)
@@ -708,7 +708,7 @@ static int __pmac media_bay_suspend(struct macio_dev *mdev, pm_message_t state)
 {
        struct media_bay_info   *bay = macio_get_drvdata(mdev);
 
-       if (state != mdev->ofdev.dev.power.power_state && state == PM_SUSPEND_MEM) {
+       if (state.event != mdev->ofdev.dev.power.power_state.event && state.event == PM_EVENT_SUSPEND) {
                down(&bay->lock);
                bay->sleeping = 1;
                set_mb_power(bay, 0);
@@ -723,7 +723,7 @@ static int __pmac media_bay_resume(struct macio_dev *mdev)
 {
        struct media_bay_info   *bay = macio_get_drvdata(mdev);
 
-       if (mdev->ofdev.dev.power.power_state != 0) {
+       if (mdev->ofdev.dev.power.power_state.event != PM_EVENT_ON) {
                mdev->ofdev.dev.power.power_state = PMSG_ON;
 
                /* We re-enable the bay using it's previous content
index 4a0a0ad2d03c09e7bff0e9185c4355e274514264..645a2e5c70ab494298b9d0359dcb38726d5fe4d6 100644 (file)
@@ -3065,7 +3065,7 @@ static int pmu_sys_suspended = 0;
 
 static int pmu_sys_suspend(struct sys_device *sysdev, pm_message_t state)
 {
-       if (state != PM_SUSPEND_DISK || pmu_sys_suspended)
+       if (state.event != PM_EVENT_SUSPEND || pmu_sys_suspended)
                return 0;
 
        /* Suspend PMU event interrupts */
index 7d8b3cad350bea238b84d4029cf209d894c116f5..9ea5747b121101759808370f15f68d6e2280312e 100644 (file)
@@ -888,7 +888,7 @@ static int cinergyt2_suspend (struct usb_interface *intf, pm_message_t state)
        if (down_interruptible(&cinergyt2->sem))
                return -ERESTARTSYS;
 
-       if (state > 0) {        /* state 0 seems to mean DEVICE_PM_ON */
+       if (state.event > PM_EVENT_ON) {
                struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
 #ifdef ENABLE_RC
                cancel_delayed_work(&cinergyt2->rc_query_work);
index 4be95398bac47e2624846553afdd4862f2db31a5..6d9de626c9670db8e0f4d436cfbfda6913fd6ceb 100644 (file)
@@ -1757,12 +1757,12 @@ static int vlsi_irda_suspend(struct pci_dev *pdev, pm_message_t state)
        idev = ndev->priv;      
        down(&idev->sem);
        if (pdev->current_state != 0) {                 /* already suspended */
-               if (state > pdev->current_state) {      /* simply go deeper */
-                       pci_set_power_state(pdev,state);
-                       pdev->current_state = state;
+               if (state.event > pdev->current_state) {        /* simply go deeper */
+                       pci_set_power_state(pdev, pci_choose_state(pdev, state));
+                       pdev->current_state = state.event;
                }
                else
-                       IRDA_ERROR("%s - %s: invalid suspend request %u -> %u\n", __FUNCTION__, PCIDEV_NAME(pdev), pdev->current_state, state);
+                       IRDA_ERROR("%s - %s: invalid suspend request %u -> %u\n", __FUNCTION__, PCIDEV_NAME(pdev), pdev->current_state, state.event);
                up(&idev->sem);
                return 0;
        }
@@ -1777,7 +1777,7 @@ static int vlsi_irda_suspend(struct pci_dev *pdev, pm_message_t state)
        }
 
        pci_set_power_state(pdev, pci_choose_state(pdev, state));
-       pdev->current_state = state;
+       pdev->current_state = state.event;
        idev->resume_ok = 1;
        up(&idev->sem);
        return 0;
index 6db1fb6461def034c898badd7c9a30bda7c4383d..abac1e40154bce50f7307da87799668e8efe0091 100644 (file)
@@ -2239,7 +2239,7 @@ static void airo_read_stats(struct airo_info *ai) {
        u32 *vals = stats_rid.vals;
 
        clear_bit(JOB_STATS, &ai->flags);
-       if (ai->power) {
+       if (ai->power.event) {
                up(&ai->sem);
                return;
        }
@@ -2969,7 +2969,7 @@ static int airo_thread(void *data) {
                        break;
                }
 
-               if (ai->power || test_bit(FLAG_FLASHING, &ai->flags)) {
+               if (ai->power.event || test_bit(FLAG_FLASHING, &ai->flags)) {
                        up(&ai->sem);
                        continue;
                }
@@ -5521,7 +5521,7 @@ static int airo_pci_resume(struct pci_dev *pdev)
        pci_restore_state(pdev);
        pci_enable_wake(pdev, pci_choose_state(pdev, ai->power), 0);
 
-       if (ai->power > 1) {
+       if (ai->power.event > 1) {
                reset_card(dev, 0);
                mpi_init_descriptors(ai);
                setup_card(ai, dev->dev_addr, 0);
@@ -7123,7 +7123,7 @@ static int airo_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
        int rc = 0;
        struct airo_info *ai = (struct airo_info *)dev->priv;
 
-       if (ai->power)
+       if (ai->power.event)
                return 0;
 
        switch (cmd) {
@@ -7202,7 +7202,7 @@ static void airo_read_wireless_stats(struct airo_info *local)
 
        /* Get stats out of the card */
        clear_bit(JOB_WSTATS, &local->flags);
-       if (local->power) {
+       if (local->power.event) {
                up(&local->sem);
                return;
        }
index 1b34fc56067ed8ae0ba9b32f46679e13068bb86c..c62d2f04339714cbf5380aa68dbdddf4aaba46c0 100644 (file)
@@ -333,13 +333,17 @@ pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state)
        if (platform_pci_choose_state) {
                ret = platform_pci_choose_state(dev, state);
                if (ret >= 0)
-                       state = ret;
+                       state.event = ret;
        }
-       switch (state) {
-       case 0: return PCI_D0;
-       case 3: return PCI_D3hot;
+
+       switch (state.event) {
+       case PM_EVENT_ON:
+               return PCI_D0;
+       case PM_EVENT_FREEZE:
+       case PM_EVENT_SUSPEND:
+               return PCI_D3hot;
        default:
-               printk("They asked me for state %d\n", state);
+               printk("They asked me for state %d\n", state.event);
                BUG();
        }
        return PCI_D0;
index ff1933298da682c5f1b0704cbee9c4b81f6d083a..a4857db4f9b8033f2ff16785dc94244e997489a6 100644 (file)
@@ -1766,7 +1766,7 @@ static int mesh_suspend(struct macio_dev *mdev, pm_message_t state)
        struct mesh_state *ms = (struct mesh_state *)macio_get_drvdata(mdev);
        unsigned long flags;
 
-       if (state == mdev->ofdev.dev.power.power_state || state < 2)
+       if (state.event == mdev->ofdev.dev.power.power_state.event || state.event < 2)
                return 0;
 
        scsi_block_requests(ms->host);
@@ -1791,7 +1791,7 @@ static int mesh_resume(struct macio_dev *mdev)
        struct mesh_state *ms = (struct mesh_state *)macio_get_drvdata(mdev);
        unsigned long flags;
 
-       if (mdev->ofdev.dev.power.power_state == 0)
+       if (mdev->ofdev.dev.power.power_state.event == PM_EVENT_ON)
                return 0;
 
        set_mesh_power(ms, 1);
@@ -1802,7 +1802,7 @@ static int mesh_resume(struct macio_dev *mdev)
        enable_irq(ms->meshintr);
        scsi_unblock_requests(ms->host);
 
-       mdev->ofdev.dev.power.power_state = 0;
+       mdev->ofdev.dev.power.power_state.event = PM_EVENT_ON;
 
        return 0;
 }
index 5bfde99e245e58acf90ce7ba0ca50d6886481d53..5ddd8ab1f108afb3af7b3acd0e38bc142c026c5f 100644 (file)
@@ -1600,7 +1600,7 @@ static int pmz_suspend(struct macio_dev *mdev, pm_message_t pm_state)
                return 0;
        }
 
-       if (pm_state == mdev->ofdev.dev.power.power_state || pm_state < 2)
+       if (pm_state.event == mdev->ofdev.dev.power.power_state.event)
                return 0;
 
        pmz_debug("suspend, switching to state %d\n", pm_state);
@@ -1660,7 +1660,7 @@ static int pmz_resume(struct macio_dev *mdev)
        if (uap == NULL)
                return 0;
 
-       if (mdev->ofdev.dev.power.power_state == 0)
+       if (mdev->ofdev.dev.power.power_state.event == PM_EVENT_ON)
                return 0;
        
        pmz_debug("resume, switching to state 0\n");
@@ -1713,7 +1713,7 @@ static int pmz_resume(struct macio_dev *mdev)
 
        pmz_debug("resume, switching complete\n");
 
-       mdev->ofdev.dev.power.power_state = 0;
+       mdev->ofdev.dev.power.power_state.event = PM_EVENT_ON;
 
        return 0;
 }
index c3e46d24a37ed0a93c8f1c2d39c27c30617b4435..c9412daff682431a820d11c3595cde972929377d 100644 (file)
@@ -1570,7 +1570,7 @@ static int __usb_suspend_device (struct usb_device *udev, int port1,
                        struct usb_driver       *driver;
 
                        intf = udev->actconfig->interface[i];
-                       if (state <= intf->dev.power.power_state)
+                       if (state.event <= intf->dev.power.power_state.event)
                                continue;
                        if (!intf->dev.driver)
                                continue;
@@ -1578,11 +1578,11 @@ static int __usb_suspend_device (struct usb_device *udev, int port1,
 
                        if (driver->suspend) {
                                status = driver->suspend(intf, state);
-                               if (intf->dev.power.power_state != state
+                               if (intf->dev.power.power_state.event != state.event
                                                || status)
                                        dev_err(&intf->dev,
                                                "suspend %d fail, code %d\n",
-                                               state, status);
+                                               state.event, status);
                        }
 
                        /* only drivers with suspend() can ever resume();
@@ -1595,7 +1595,7 @@ static int __usb_suspend_device (struct usb_device *udev, int port1,
                         * since we know every driver's probe/disconnect works
                         * even for drivers that can't suspend.
                         */
-                       if (!driver->suspend || state > PM_SUSPEND_MEM) {
+                       if (!driver->suspend || state.event > PM_EVENT_FREEZE) {
 #if 1
                                dev_warn(&intf->dev, "resume is unsafe!\n");
 #else
@@ -1616,7 +1616,7 @@ static int __usb_suspend_device (struct usb_device *udev, int port1,
         * policies (when HNP doesn't apply) once we have mechanisms to
         * turn power back on!  (Likely not before 2.7...)
         */
-       if (state > PM_SUSPEND_MEM) {
+       if (state.event > PM_EVENT_FREEZE) {
                dev_warn(&udev->dev, "no poweroff yet, suspending instead\n");
        }
 
@@ -1733,7 +1733,7 @@ static int finish_port_resume(struct usb_device *udev)
                        struct usb_driver       *driver;
 
                        intf = udev->actconfig->interface[i];
-                       if (intf->dev.power.power_state == PMSG_ON)
+                       if (intf->dev.power.power_state.event == PM_EVENT_ON)
                                continue;
                        if (!intf->dev.driver) {
                                /* FIXME maybe force to alt 0 */
@@ -1747,11 +1747,11 @@ static int finish_port_resume(struct usb_device *udev)
 
                        /* can we do better than just logging errors? */
                        status = driver->resume(intf);
-                       if (intf->dev.power.power_state != PMSG_ON
+                       if (intf->dev.power.power_state.event != PM_EVENT_ON
                                        || status)
                                dev_dbg(&intf->dev,
                                        "resume fail, state %d code %d\n",
-                                       intf->dev.power.power_state, status);
+                                       intf->dev.power.power_state.event, status);
                }
                status = 0;
 
@@ -1934,7 +1934,7 @@ static int hub_resume(struct usb_interface *intf)
        unsigned                port1;
        int                     status;
 
-       if (intf->dev.power.power_state == PM_SUSPEND_ON)
+       if (intf->dev.power.power_state.event == PM_EVENT_ON)
                return 0;
 
        for (port1 = 1; port1 <= hdev->maxchild; port1++) {
index 99c85d2f92daaf115df6cbe902a8f7a266fa3f66..2cddd8a00437b8bede3f9814a66dc73a2190886a 100644 (file)
@@ -1400,7 +1400,7 @@ static int usb_generic_suspend(struct device *dev, pm_message_t message)
        driver = to_usb_driver(dev->driver);
 
        /* there's only one USB suspend state */
-       if (intf->dev.power.power_state)
+       if (intf->dev.power.power_state.event)
                return 0;
 
        if (driver->suspend)
index b01efb6b36f6767e7e492af441421a7d27ce631e..65ac9fef3a7c1dfc382ef2c8aaf5a089fdb7a7ad 100644 (file)
@@ -641,7 +641,7 @@ show_registers (struct class_device *class_dev, char *buf)
 
        spin_lock_irqsave (&ehci->lock, flags);
 
-       if (bus->controller->power.power_state) {
+       if (bus->controller->power.power_state.event) {
                size = scnprintf (next, size,
                        "bus %s, device %s (driver " DRIVER_VERSION ")\n"
                        "%s\n"
index c58408c95c3d26666fb86482b03274dd0b2b241b..447f488f5d937f85de1e7c75348e04bf8400a040 100644 (file)
@@ -631,7 +631,7 @@ show_registers (struct class_device *class_dev, char *buf)
                hcd->product_desc,
                hcd_name);
 
-       if (bus->controller->power.power_state) {
+       if (bus->controller->power.power_state.event) {
                size -= scnprintf (next, size,
                        "SUSPENDED (no register access)\n");
                goto done;
index 7a890a65f55dc53664b8dd130ee3b4a6b048ffa7..80eaf659c1984b0921acd9b956600bcdc0a5b348 100644 (file)
@@ -1781,9 +1781,9 @@ sl811h_suspend(struct device *dev, pm_message_t state, u32 phase)
        if (phase != SUSPEND_POWER_DOWN)
                return retval;
 
-       if (state <= PM_SUSPEND_MEM)
+       if (state.event == PM_EVENT_FREEZE)
                retval = sl811h_hub_suspend(hcd);
-       else
+       else if (state.event == PM_EVENT_SUSPEND)
                port_power(sl811, 0);
        if (retval == 0)
                dev->power.power_state = state;
@@ -1802,7 +1802,7 @@ sl811h_resume(struct device *dev, u32 phase)
        /* with no "check to see if VBUS is still powered" board hook,
         * let's assume it'd only be powered to enable remote wakeup.
         */
-       if (dev->power.power_state > PM_SUSPEND_MEM
+       if (dev->power.power_state.event == PM_EVENT_SUSPEND
                        || !hcd->can_wakeup) {
                sl811->port1 = 0;
                port_power(sl811, 1);
index cda7249a90b285225df15bb99b2d3af6e5b91589..fd7fb98e4b2029c752fa94d86f8b8d26e775779e 100644 (file)
@@ -1533,7 +1533,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
        if (down_interruptible (&dev->sem))
                return -ERESTARTSYS;
 
-       if (intf->dev.power.power_state != PMSG_ON) {
+       if (intf->dev.power.power_state.event != PM_EVENT_ON) {
                up (&dev->sem);
                return -EHOSTUNREACH;
        }
index 7bc1d44d88147d5368e2301a78254dba1f25f4bd..b0eba3ac6420f61e692118075fa5baf8bce2be4f 100644 (file)
@@ -2323,17 +2323,16 @@ static int aty128_pci_suspend(struct pci_dev *pdev, pm_message_t state)
         * can properly take care of D3 ? Also, with swsusp, we
         * know we'll be rebooted, ...
         */
-#ifdef CONFIG_PPC_PMAC
+#ifndef CONFIG_PPC_PMAC
        /* HACK ALERT ! Once I find a proper way to say to each driver
         * individually what will happen with it's PCI slot, I'll change
         * that. On laptops, the AGP slot is just unclocked, so D2 is
         * expected, while on desktops, the card is powered off
         */
-       if (state >= 3)
-               state = 2;
+       return 0;
 #endif /* CONFIG_PPC_PMAC */
         
-       if (state != 2 || state == pdev->dev.power.power_state)
+       if (state.event == pdev->dev.power.power_state.event)
                return 0;
 
        printk(KERN_DEBUG "aty128fb: suspending...\n");
@@ -2367,7 +2366,7 @@ static int aty128_pci_suspend(struct pci_dev *pdev, pm_message_t state)
         * used dummy fb ops, 2.5 need proper support for this at the
         * fbdev level
         */
-       if (state == 2)
+       if (state.event != PM_EVENT_ON)
                aty128_set_suspend(par, 1);
 
        release_console_sem();
@@ -2382,12 +2381,11 @@ static int aty128_do_resume(struct pci_dev *pdev)
        struct fb_info *info = pci_get_drvdata(pdev);
        struct aty128fb_par *par = info->par;
 
-       if (pdev->dev.power.power_state == 0)
+       if (pdev->dev.power.power_state.event == PM_EVENT_ON)
                return 0;
 
        /* Wakeup chip */
-       if (pdev->dev.power.power_state == 2)
-               aty128_set_suspend(par, 0);
+       aty128_set_suspend(par, 0);
        par->asleep = 0;
 
        /* Restore display & engine */
index 8c42538dc8c12db3ff65be3721bf6f3935e0533e..3e10bd837d9e8382a9f5bf5b0ac7073bb85bdd92 100644 (file)
@@ -2022,17 +2022,16 @@ static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
        struct fb_info *info = pci_get_drvdata(pdev);
        struct atyfb_par *par = (struct atyfb_par *) info->par;
 
-#ifdef CONFIG_PPC_PMAC
+#ifndef CONFIG_PPC_PMAC
        /* HACK ALERT ! Once I find a proper way to say to each driver
         * individually what will happen with it's PCI slot, I'll change
         * that. On laptops, the AGP slot is just unclocked, so D2 is
         * expected, while on desktops, the card is powered off
         */
-       if (state >= 3)
-               state = 2;
+       return 0;
 #endif /* CONFIG_PPC_PMAC */
 
-       if (state != 2 || state == pdev->dev.power.power_state)
+       if (state.event == pdev->dev.power.power_state.event)
                return 0;
 
        acquire_console_sem();
@@ -2071,12 +2070,12 @@ static int atyfb_pci_resume(struct pci_dev *pdev)
        struct fb_info *info = pci_get_drvdata(pdev);
        struct atyfb_par *par = (struct atyfb_par *) info->par;
 
-       if (pdev->dev.power.power_state == 0)
+       if (pdev->dev.power.power_state.event == PM_EVENT_ON)
                return 0;
 
        acquire_console_sem();
 
-       if (pdev->dev.power.power_state == 2)
+       if (pdev->dev.power.power_state.event == 2)
                aty_power_mgmt(0, par);
        par->asleep = 0;
 
index 98352af393255d44907ad92270b4f236cc3210ac..59a1b6f85067863a87749913911b2386827ff898 100644 (file)
@@ -2526,18 +2526,18 @@ int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
         struct radeonfb_info *rinfo = info->par;
        int i;
 
-       if (state == pdev->dev.power.power_state)
+       if (state.event == pdev->dev.power.power_state.event)
                return 0;
 
        printk(KERN_DEBUG "radeonfb (%s): suspending to state: %d...\n",
-              pci_name(pdev), state);
+              pci_name(pdev), state.event);
 
        /* For suspend-to-disk, we cheat here. We don't suspend anything and
         * let fbcon continue drawing until we are all set. That shouldn't
         * really cause any problem at this point, provided that the wakeup
         * code knows that any state in memory may not match the HW
         */
-       if (state != PM_SUSPEND_MEM)
+       if (state.event == PM_EVENT_FREEZE)
                goto done;
 
        acquire_console_sem();
@@ -2616,7 +2616,7 @@ int radeonfb_pci_resume(struct pci_dev *pdev)
         struct radeonfb_info *rinfo = info->par;
        int rc = 0;
 
-       if (pdev->dev.power.power_state == 0)
+       if (pdev->dev.power.power_state.event == PM_EVENT_ON)
                return 0;
 
        if (rinfo->no_schedule) {
@@ -2626,7 +2626,7 @@ int radeonfb_pci_resume(struct pci_dev *pdev)
                acquire_console_sem();
 
        printk(KERN_DEBUG "radeonfb (%s): resuming from state: %d...\n",
-              pci_name(pdev), pdev->dev.power.power_state);
+              pci_name(pdev), pdev->dev.power.power_state.event);
 
 
        if (pci_enable_device(pdev)) {
@@ -2637,7 +2637,7 @@ int radeonfb_pci_resume(struct pci_dev *pdev)
        }
        pci_set_master(pdev);
 
-       if (pdev->dev.power.power_state == PM_SUSPEND_MEM) {
+       if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
                /* Wakeup chip. Check from config space if we were powered off
                 * (todo: additionally, check CLK_PIN_CNTL too)
                 */
index e75a965ec760324ff3ebe5705ebdeb4fb4c97ac6..4131243cfdf85e621263f547b7ebe6baf01985ca 100644 (file)
@@ -462,9 +462,9 @@ static int chipsfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 {
         struct fb_info *p = pci_get_drvdata(pdev);
 
-       if (state == pdev->dev.power.power_state)
+       if (state.event == pdev->dev.power.power_state.event)
                return 0;
-       if (state != PM_SUSPEND_MEM)
+       if (state.event != PM_SUSPEND_MEM)
                goto done;
 
        acquire_console_sem();
index 7513fb9b19cf739cc41afaf888efb0edae722587..6db183462b9200ff642b364492bb39c971ad1d4d 100644 (file)
@@ -1506,12 +1506,12 @@ static int i810fb_suspend(struct pci_dev *dev, pm_message_t state)
        struct i810fb_par *par = (struct i810fb_par *) info->par;
        int blank = 0, prev_state = par->cur_state;
 
-       if (state == prev_state)
+       if (state.event == prev_state)
                return 0;
 
-       par->cur_state = state;
+       par->cur_state = state.event;
 
-       switch (state) {
+       switch (state.event) {
        case 1:
                blank = VESA_VSYNC_SUSPEND;
                break;
index 7aeb208ed71357ad3a15891ea536021545fba48d..5cfb07648eca1c999403bc17e2f15ea14e125286 100644 (file)
@@ -186,7 +186,9 @@ extern int pm_suspend(suspend_state_t state);
 
 struct device;
 
-typedef u32 __bitwise pm_message_t;
+typedef struct pm_message {
+       int event;
+} pm_message_t;
 
 /*
  * There are 4 important states driver can be in:
@@ -207,9 +209,13 @@ typedef u32 __bitwise pm_message_t;
  * or something similar soon.
  */
 
-#define PMSG_FREEZE    ((__force pm_message_t) 3)
-#define PMSG_SUSPEND   ((__force pm_message_t) 3)
-#define PMSG_ON                ((__force pm_message_t) 0)
+#define PM_EVENT_ON 0
+#define PM_EVENT_FREEZE 1
+#define PM_EVENT_SUSPEND 2
+
+#define PMSG_FREEZE    ((struct pm_message){ .event = PM_EVENT_FREEZE, })
+#define PMSG_SUSPEND   ((struct pm_message){ .event = PM_EVENT_SUSPEND, })
+#define PMSG_ON                ((struct pm_message){ .event = PM_EVENT_ON, })
 
 struct dev_pm_info {
        pm_message_t            power_state;