diff options
Diffstat (limited to 'drivers/gpu/drm/drm_sysfs.c')
| -rw-r--r-- | drivers/gpu/drm/drm_sysfs.c | 49 |
1 files changed, 22 insertions, 27 deletions
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index 0f6cd33b531f..f08873f6489c 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c | |||
| @@ -30,6 +30,8 @@ static struct device_type drm_sysfs_device_minor = { | |||
| 30 | .name = "drm_minor" | 30 | .name = "drm_minor" |
| 31 | }; | 31 | }; |
| 32 | 32 | ||
| 33 | struct class *drm_class; | ||
| 34 | |||
| 33 | /** | 35 | /** |
| 34 | * __drm_class_suspend - internal DRM class suspend routine | 36 | * __drm_class_suspend - internal DRM class suspend routine |
| 35 | * @dev: Linux device to suspend | 37 | * @dev: Linux device to suspend |
| @@ -112,41 +114,34 @@ static CLASS_ATTR_STRING(version, S_IRUGO, | |||
| 112 | CORE_DATE); | 114 | CORE_DATE); |
| 113 | 115 | ||
| 114 | /** | 116 | /** |
| 115 | * drm_sysfs_create - create a struct drm_sysfs_class structure | 117 | * drm_sysfs_init - initialize sysfs helpers |
| 116 | * @owner: pointer to the module that is to "own" this struct drm_sysfs_class | 118 | * |
| 117 | * @name: pointer to a string for the name of this class. | 119 | * This is used to create the DRM class, which is the implicit parent of any |
| 120 | * other top-level DRM sysfs objects. | ||
| 118 | * | 121 | * |
| 119 | * This is used to create DRM class pointer that can then be used | 122 | * You must call drm_sysfs_destroy() to release the allocated resources. |
| 120 | * in calls to drm_sysfs_device_add(). | ||
| 121 | * | 123 | * |
| 122 | * Note, the pointer created here is to be destroyed when finished by making a | 124 | * Return: 0 on success, negative error code on failure. |
| 123 | * call to drm_sysfs_destroy(). | ||
| 124 | */ | 125 | */ |
| 125 | struct class *drm_sysfs_create(struct module *owner, char *name) | 126 | int drm_sysfs_init(void) |
| 126 | { | 127 | { |
| 127 | struct class *class; | ||
| 128 | int err; | 128 | int err; |
| 129 | 129 | ||
| 130 | class = class_create(owner, name); | 130 | drm_class = class_create(THIS_MODULE, "drm"); |
| 131 | if (IS_ERR(class)) { | 131 | if (IS_ERR(drm_class)) |
| 132 | err = PTR_ERR(class); | 132 | return PTR_ERR(drm_class); |
| 133 | goto err_out; | ||
| 134 | } | ||
| 135 | |||
| 136 | class->pm = &drm_class_dev_pm_ops; | ||
| 137 | 133 | ||
| 138 | err = class_create_file(class, &class_attr_version.attr); | 134 | drm_class->pm = &drm_class_dev_pm_ops; |
| 139 | if (err) | ||
| 140 | goto err_out_class; | ||
| 141 | 135 | ||
| 142 | class->devnode = drm_devnode; | 136 | err = class_create_file(drm_class, &class_attr_version.attr); |
| 143 | 137 | if (err) { | |
| 144 | return class; | 138 | class_destroy(drm_class); |
| 139 | drm_class = NULL; | ||
| 140 | return err; | ||
| 141 | } | ||
| 145 | 142 | ||
| 146 | err_out_class: | 143 | drm_class->devnode = drm_devnode; |
| 147 | class_destroy(class); | 144 | return 0; |
| 148 | err_out: | ||
| 149 | return ERR_PTR(err); | ||
| 150 | } | 145 | } |
| 151 | 146 | ||
| 152 | /** | 147 | /** |
| @@ -156,7 +151,7 @@ err_out: | |||
| 156 | */ | 151 | */ |
| 157 | void drm_sysfs_destroy(void) | 152 | void drm_sysfs_destroy(void) |
| 158 | { | 153 | { |
| 159 | if ((drm_class == NULL) || (IS_ERR(drm_class))) | 154 | if (IS_ERR_OR_NULL(drm_class)) |
| 160 | return; | 155 | return; |
| 161 | class_remove_file(drm_class, &class_attr_version.attr); | 156 | class_remove_file(drm_class, &class_attr_version.attr); |
| 162 | class_destroy(drm_class); | 157 | class_destroy(drm_class); |
