aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_sysfs.c
diff options
context:
space:
mode:
authorShuah Khan <shuah.kh@samsung.com>2013-07-01 18:06:02 -0400
committerDave Airlie <airlied@redhat.com>2013-07-03 20:50:26 -0400
commitcf4b91f2d9de7ccc7ca0fb0931d55aaf8569fbc0 (patch)
tree4a9abea83ec038b1a401279f16576ec888b20aa3 /drivers/gpu/drm/drm_sysfs.c
parentd0aaa2836aa3f12b4ebf3e21811616a083c8c91b (diff)
drm: Convert drm class driver from legacy pm ops to dev_pm_ops
Convert drivers/gpu/drm class to use dev_pm_ops for power management and remove Legacy PM ops hooks. With this change, drm class registers suspend/resume callbacks via class->pm (dev_pm_ops) instead of Legacy class->suspend/resume. When __device_suspend() runs call-backs, it will find class->pm ops for the drm class. drm_class_suspend() hook calls driver legacy ops with the state information. e.g: drm_class_suspend() calls into driver suspend routines via drm_dev->driver->suspend(drm_dev, state). Once drm_class_suspend() is converted to dev_pm_ops, it will no longer have access to pm_transition which it has to pass into driver legacy suspend calls. A new freeze and suspend hooks are added to address the not having access to the state information. The new freeze and suspend hooks simply call __drm_class_suspend() with the appropriate pm state information. __drm_class_suspend() is the original suspend hook with a new name. Signed-off-by: Shuah Khan <shuah.kh@samsung.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/drm_sysfs.c')
-rw-r--r--drivers/gpu/drm/drm_sysfs.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 02296653a058..2290b3b73832 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -30,14 +30,14 @@ static struct device_type drm_sysfs_device_minor = {
30}; 30};
31 31
32/** 32/**
33 * drm_class_suspend - DRM class suspend hook 33 * __drm_class_suspend - internal DRM class suspend routine
34 * @dev: Linux device to suspend 34 * @dev: Linux device to suspend
35 * @state: power state to enter 35 * @state: power state to enter
36 * 36 *
37 * Just figures out what the actual struct drm_device associated with 37 * Just figures out what the actual struct drm_device associated with
38 * @dev is and calls its suspend hook, if present. 38 * @dev is and calls its suspend hook, if present.
39 */ 39 */
40static int drm_class_suspend(struct device *dev, pm_message_t state) 40static int __drm_class_suspend(struct device *dev, pm_message_t state)
41{ 41{
42 if (dev->type == &drm_sysfs_device_minor) { 42 if (dev->type == &drm_sysfs_device_minor) {
43 struct drm_minor *drm_minor = to_drm_minor(dev); 43 struct drm_minor *drm_minor = to_drm_minor(dev);
@@ -52,6 +52,26 @@ static int drm_class_suspend(struct device *dev, pm_message_t state)
52} 52}
53 53
54/** 54/**
55 * drm_class_suspend - internal DRM class suspend hook. Simply calls
56 * __drm_class_suspend() with the correct pm state.
57 * @dev: Linux device to suspend
58 */
59static int drm_class_suspend(struct device *dev)
60{
61 return __drm_class_suspend(dev, PMSG_SUSPEND);
62}
63
64/**
65 * drm_class_freeze - internal DRM class freeze hook. Simply calls
66 * __drm_class_suspend() with the correct pm state.
67 * @dev: Linux device to freeze
68 */
69static int drm_class_freeze(struct device *dev)
70{
71 return __drm_class_suspend(dev, PMSG_FREEZE);
72}
73
74/**
55 * drm_class_resume - DRM class resume hook 75 * drm_class_resume - DRM class resume hook
56 * @dev: Linux device to resume 76 * @dev: Linux device to resume
57 * 77 *
@@ -72,6 +92,12 @@ static int drm_class_resume(struct device *dev)
72 return 0; 92 return 0;
73} 93}
74 94
95static const struct dev_pm_ops drm_class_dev_pm_ops = {
96 .suspend = drm_class_suspend,
97 .resume = drm_class_resume,
98 .freeze = drm_class_freeze,
99};
100
75static char *drm_devnode(struct device *dev, umode_t *mode) 101static char *drm_devnode(struct device *dev, umode_t *mode)
76{ 102{
77 return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev)); 103 return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev));
@@ -106,8 +132,7 @@ struct class *drm_sysfs_create(struct module *owner, char *name)
106 goto err_out; 132 goto err_out;
107 } 133 }
108 134
109 class->suspend = drm_class_suspend; 135 class->pm = &drm_class_dev_pm_ops;
110 class->resume = drm_class_resume;
111 136
112 err = class_create_file(class, &class_attr_version.attr); 137 err = class_create_file(class, &class_attr_version.attr);
113 if (err) 138 if (err)