Commit 08e4d534 authored by Thomas Hellstrom's avatar Thomas Hellstrom Committed by Dave Airlie

drm: Fix sysfs device confusion.

The drm sysfs class suspend / resume methods could not distinguish
between different device types wich could lead to illegal type casts.

Use struct device_type and make sure the class suspend / resume callbacks
are aware of those. There is no per device-type suspend / resume. Only
new-style PM.
Signed-off-by: default avatarThomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent e3b2415e
...@@ -22,16 +22,21 @@ ...@@ -22,16 +22,21 @@
#define to_drm_minor(d) container_of(d, struct drm_minor, kdev) #define to_drm_minor(d) container_of(d, struct drm_minor, kdev)
#define to_drm_connector(d) container_of(d, struct drm_connector, kdev) #define to_drm_connector(d) container_of(d, struct drm_connector, kdev)
static struct device_type drm_sysfs_device_minor = {
.name = "drm_minor"
};
/** /**
* drm_sysfs_suspend - DRM class suspend hook * drm_class_suspend - DRM class suspend hook
* @dev: Linux device to suspend * @dev: Linux device to suspend
* @state: power state to enter * @state: power state to enter
* *
* Just figures out what the actual struct drm_device associated with * Just figures out what the actual struct drm_device associated with
* @dev is and calls its suspend hook, if present. * @dev is and calls its suspend hook, if present.
*/ */
static int drm_sysfs_suspend(struct device *dev, pm_message_t state) static int drm_class_suspend(struct device *dev, pm_message_t state)
{ {
if (dev->type == &drm_sysfs_device_minor) {
struct drm_minor *drm_minor = to_drm_minor(dev); struct drm_minor *drm_minor = to_drm_minor(dev);
struct drm_device *drm_dev = drm_minor->dev; struct drm_device *drm_dev = drm_minor->dev;
...@@ -39,19 +44,20 @@ static int drm_sysfs_suspend(struct device *dev, pm_message_t state) ...@@ -39,19 +44,20 @@ static int drm_sysfs_suspend(struct device *dev, pm_message_t state)
!drm_core_check_feature(drm_dev, DRIVER_MODESET) && !drm_core_check_feature(drm_dev, DRIVER_MODESET) &&
drm_dev->driver->suspend) drm_dev->driver->suspend)
return drm_dev->driver->suspend(drm_dev, state); return drm_dev->driver->suspend(drm_dev, state);
}
return 0; return 0;
} }
/** /**
* drm_sysfs_resume - DRM class resume hook * drm_class_resume - DRM class resume hook
* @dev: Linux device to resume * @dev: Linux device to resume
* *
* Just figures out what the actual struct drm_device associated with * Just figures out what the actual struct drm_device associated with
* @dev is and calls its resume hook, if present. * @dev is and calls its resume hook, if present.
*/ */
static int drm_sysfs_resume(struct device *dev) static int drm_class_resume(struct device *dev)
{ {
if (dev->type == &drm_sysfs_device_minor) {
struct drm_minor *drm_minor = to_drm_minor(dev); struct drm_minor *drm_minor = to_drm_minor(dev);
struct drm_device *drm_dev = drm_minor->dev; struct drm_device *drm_dev = drm_minor->dev;
...@@ -59,7 +65,7 @@ static int drm_sysfs_resume(struct device *dev) ...@@ -59,7 +65,7 @@ static int drm_sysfs_resume(struct device *dev)
!drm_core_check_feature(drm_dev, DRIVER_MODESET) && !drm_core_check_feature(drm_dev, DRIVER_MODESET) &&
drm_dev->driver->resume) drm_dev->driver->resume)
return drm_dev->driver->resume(drm_dev); return drm_dev->driver->resume(drm_dev);
}
return 0; return 0;
} }
...@@ -99,8 +105,8 @@ struct class *drm_sysfs_create(struct module *owner, char *name) ...@@ -99,8 +105,8 @@ struct class *drm_sysfs_create(struct module *owner, char *name)
goto err_out; goto err_out;
} }
class->suspend = drm_sysfs_suspend; class->suspend = drm_class_suspend;
class->resume = drm_sysfs_resume; class->resume = drm_class_resume;
err = class_create_file(class, &class_attr_version); err = class_create_file(class, &class_attr_version);
if (err) if (err)
...@@ -480,6 +486,7 @@ int drm_sysfs_device_add(struct drm_minor *minor) ...@@ -480,6 +486,7 @@ int drm_sysfs_device_add(struct drm_minor *minor)
minor->kdev.class = drm_class; minor->kdev.class = drm_class;
minor->kdev.release = drm_sysfs_device_release; minor->kdev.release = drm_sysfs_device_release;
minor->kdev.devt = minor->device; minor->kdev.devt = minor->device;
minor->kdev.type = &drm_sysfs_device_minor;
if (minor->type == DRM_MINOR_CONTROL) if (minor->type == DRM_MINOR_CONTROL)
minor_str = "controlD%d"; minor_str = "controlD%d";
else if (minor->type == DRM_MINOR_RENDER) else if (minor->type == DRM_MINOR_RENDER)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment