Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 151097
b: refs/heads/master
c: 7e597a2
h: refs/heads/master
i:
  151095: 0baa2cb
v: v3
  • Loading branch information
Sebastian Ott authored and Martin Schwidefsky committed Jun 16, 2009
1 parent 6781bd7 commit ca2af42
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 823d494ac11111064cf39abd4178ce299414c771
refs/heads/master: 7e597a21a1470b12428cb0edd03c40986026451f
10 changes: 10 additions & 0 deletions trunk/arch/s390/include/asm/ccwgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ struct ccwgroup_device {
* @set_online: function called when device is set online
* @set_offline: function called when device is set offline
* @shutdown: function called when device is shut down
* @prepare: prepare for pm state transition
* @complete: undo work done in @prepare
* @freeze: callback for freezing during hibernation snapshotting
* @thaw: undo work done in @freeze
* @restore: callback for restoring after hibernation
* @driver: embedded driver structure
*/
struct ccwgroup_driver {
Expand All @@ -51,6 +56,11 @@ struct ccwgroup_driver {
int (*set_online) (struct ccwgroup_device *);
int (*set_offline) (struct ccwgroup_device *);
void (*shutdown)(struct ccwgroup_device *);
int (*prepare) (struct ccwgroup_device *);
void (*complete) (struct ccwgroup_device *);
int (*freeze)(struct ccwgroup_device *);
int (*thaw) (struct ccwgroup_device *);
int (*restore)(struct ccwgroup_device *);

struct device_driver driver;
};
Expand Down
78 changes: 73 additions & 5 deletions trunk/drivers/s390/cio/ccwgroup.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/*
* drivers/s390/cio/ccwgroup.c
* bus driver for ccwgroup
*
* Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
* IBM Corporation
* Author(s): Arnd Bergmann (arndb@de.ibm.com)
* Cornelia Huck (cornelia.huck@de.ibm.com)
* Copyright IBM Corp. 2002, 2009
*
* Author(s): Arnd Bergmann (arndb@de.ibm.com)
* Cornelia Huck (cornelia.huck@de.ibm.com)
*/
#include <linux/module.h>
#include <linux/errno.h>
Expand Down Expand Up @@ -501,13 +500,82 @@ static void ccwgroup_shutdown(struct device *dev)
gdrv->shutdown(gdev);
}

static int ccwgroup_pm_prepare(struct device *dev)
{
struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
struct ccwgroup_driver *gdrv = to_ccwgroupdrv(gdev->dev.driver);

/* Fail while device is being set online/offline. */
if (atomic_read(&gdev->onoff))
return -EAGAIN;

if (!gdev->dev.driver || gdev->state != CCWGROUP_ONLINE)
return 0;

return gdrv->prepare ? gdrv->prepare(gdev) : 0;
}

static void ccwgroup_pm_complete(struct device *dev)
{
struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
struct ccwgroup_driver *gdrv = to_ccwgroupdrv(dev->driver);

if (!gdev->dev.driver || gdev->state != CCWGROUP_ONLINE)
return;

if (gdrv->complete)
gdrv->complete(gdev);
}

static int ccwgroup_pm_freeze(struct device *dev)
{
struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
struct ccwgroup_driver *gdrv = to_ccwgroupdrv(gdev->dev.driver);

if (!gdev->dev.driver || gdev->state != CCWGROUP_ONLINE)
return 0;

return gdrv->freeze ? gdrv->freeze(gdev) : 0;
}

static int ccwgroup_pm_thaw(struct device *dev)
{
struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
struct ccwgroup_driver *gdrv = to_ccwgroupdrv(gdev->dev.driver);

if (!gdev->dev.driver || gdev->state != CCWGROUP_ONLINE)
return 0;

return gdrv->thaw ? gdrv->thaw(gdev) : 0;
}

static int ccwgroup_pm_restore(struct device *dev)
{
struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
struct ccwgroup_driver *gdrv = to_ccwgroupdrv(gdev->dev.driver);

if (!gdev->dev.driver || gdev->state != CCWGROUP_ONLINE)
return 0;

return gdrv->restore ? gdrv->restore(gdev) : 0;
}

static struct dev_pm_ops ccwgroup_pm_ops = {
.prepare = ccwgroup_pm_prepare,
.complete = ccwgroup_pm_complete,
.freeze = ccwgroup_pm_freeze,
.thaw = ccwgroup_pm_thaw,
.restore = ccwgroup_pm_restore,
};

static struct bus_type ccwgroup_bus_type = {
.name = "ccwgroup",
.match = ccwgroup_bus_match,
.uevent = ccwgroup_uevent,
.probe = ccwgroup_probe,
.remove = ccwgroup_remove,
.shutdown = ccwgroup_shutdown,
.pm = &ccwgroup_pm_ops,
};


Expand Down

0 comments on commit ca2af42

Please sign in to comment.