diff options
Diffstat (limited to 'drivers/gpu/drm/drm_sysfs.c')
-rw-r--r-- | drivers/gpu/drm/drm_sysfs.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index 7e42b7e9d43a..25bbd30ed7af 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c | |||
@@ -14,6 +14,7 @@ | |||
14 | 14 | ||
15 | #include <linux/device.h> | 15 | #include <linux/device.h> |
16 | #include <linux/kdev_t.h> | 16 | #include <linux/kdev_t.h> |
17 | #include <linux/gfp.h> | ||
17 | #include <linux/err.h> | 18 | #include <linux/err.h> |
18 | 19 | ||
19 | #include "drm_sysfs.h" | 20 | #include "drm_sysfs.h" |
@@ -70,19 +71,17 @@ static int drm_class_resume(struct device *dev) | |||
70 | return 0; | 71 | return 0; |
71 | } | 72 | } |
72 | 73 | ||
73 | /* Display the version of drm_core. This doesn't work right in current design */ | ||
74 | static ssize_t version_show(struct class *dev, char *buf) | ||
75 | { | ||
76 | return sprintf(buf, "%s %d.%d.%d %s\n", CORE_NAME, CORE_MAJOR, | ||
77 | CORE_MINOR, CORE_PATCHLEVEL, CORE_DATE); | ||
78 | } | ||
79 | |||
80 | static char *drm_devnode(struct device *dev, mode_t *mode) | 74 | static char *drm_devnode(struct device *dev, mode_t *mode) |
81 | { | 75 | { |
82 | return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev)); | 76 | return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev)); |
83 | } | 77 | } |
84 | 78 | ||
85 | static CLASS_ATTR(version, S_IRUGO, version_show, NULL); | 79 | static CLASS_ATTR_STRING(version, S_IRUGO, |
80 | CORE_NAME " " | ||
81 | __stringify(CORE_MAJOR) "." | ||
82 | __stringify(CORE_MINOR) "." | ||
83 | __stringify(CORE_PATCHLEVEL) " " | ||
84 | CORE_DATE); | ||
86 | 85 | ||
87 | /** | 86 | /** |
88 | * drm_sysfs_create - create a struct drm_sysfs_class structure | 87 | * drm_sysfs_create - create a struct drm_sysfs_class structure |
@@ -109,7 +108,7 @@ struct class *drm_sysfs_create(struct module *owner, char *name) | |||
109 | class->suspend = drm_class_suspend; | 108 | class->suspend = drm_class_suspend; |
110 | class->resume = drm_class_resume; | 109 | class->resume = drm_class_resume; |
111 | 110 | ||
112 | err = class_create_file(class, &class_attr_version); | 111 | err = class_create_file(class, &class_attr_version.attr); |
113 | if (err) | 112 | if (err) |
114 | goto err_out_class; | 113 | goto err_out_class; |
115 | 114 | ||
@@ -132,7 +131,7 @@ void drm_sysfs_destroy(void) | |||
132 | { | 131 | { |
133 | if ((drm_class == NULL) || (IS_ERR(drm_class))) | 132 | if ((drm_class == NULL) || (IS_ERR(drm_class))) |
134 | return; | 133 | return; |
135 | class_remove_file(drm_class, &class_attr_version); | 134 | class_remove_file(drm_class, &class_attr_version.attr); |
136 | class_destroy(drm_class); | 135 | class_destroy(drm_class); |
137 | } | 136 | } |
138 | 137 | ||
@@ -355,7 +354,10 @@ static struct bin_attribute edid_attr = { | |||
355 | int drm_sysfs_connector_add(struct drm_connector *connector) | 354 | int drm_sysfs_connector_add(struct drm_connector *connector) |
356 | { | 355 | { |
357 | struct drm_device *dev = connector->dev; | 356 | struct drm_device *dev = connector->dev; |
358 | int ret = 0, i, j; | 357 | int attr_cnt = 0; |
358 | int opt_cnt = 0; | ||
359 | int i; | ||
360 | int ret = 0; | ||
359 | 361 | ||
360 | /* We shouldn't get called more than once for the same connector */ | 362 | /* We shouldn't get called more than once for the same connector */ |
361 | BUG_ON(device_is_registered(&connector->kdev)); | 363 | BUG_ON(device_is_registered(&connector->kdev)); |
@@ -378,8 +380,8 @@ int drm_sysfs_connector_add(struct drm_connector *connector) | |||
378 | 380 | ||
379 | /* Standard attributes */ | 381 | /* Standard attributes */ |
380 | 382 | ||
381 | for (i = 0; i < ARRAY_SIZE(connector_attrs); i++) { | 383 | for (attr_cnt = 0; attr_cnt < ARRAY_SIZE(connector_attrs); attr_cnt++) { |
382 | ret = device_create_file(&connector->kdev, &connector_attrs[i]); | 384 | ret = device_create_file(&connector->kdev, &connector_attrs[attr_cnt]); |
383 | if (ret) | 385 | if (ret) |
384 | goto err_out_files; | 386 | goto err_out_files; |
385 | } | 387 | } |
@@ -395,8 +397,8 @@ int drm_sysfs_connector_add(struct drm_connector *connector) | |||
395 | case DRM_MODE_CONNECTOR_SVIDEO: | 397 | case DRM_MODE_CONNECTOR_SVIDEO: |
396 | case DRM_MODE_CONNECTOR_Component: | 398 | case DRM_MODE_CONNECTOR_Component: |
397 | case DRM_MODE_CONNECTOR_TV: | 399 | case DRM_MODE_CONNECTOR_TV: |
398 | for (i = 0; i < ARRAY_SIZE(connector_attrs_opt1); i++) { | 400 | for (opt_cnt = 0; opt_cnt < ARRAY_SIZE(connector_attrs_opt1); opt_cnt++) { |
399 | ret = device_create_file(&connector->kdev, &connector_attrs_opt1[i]); | 401 | ret = device_create_file(&connector->kdev, &connector_attrs_opt1[opt_cnt]); |
400 | if (ret) | 402 | if (ret) |
401 | goto err_out_files; | 403 | goto err_out_files; |
402 | } | 404 | } |
@@ -415,10 +417,10 @@ int drm_sysfs_connector_add(struct drm_connector *connector) | |||
415 | return 0; | 417 | return 0; |
416 | 418 | ||
417 | err_out_files: | 419 | err_out_files: |
418 | if (i > 0) | 420 | for (i = 0; i < opt_cnt; i++) |
419 | for (j = 0; j < i; j++) | 421 | device_remove_file(&connector->kdev, &connector_attrs_opt1[i]); |
420 | device_remove_file(&connector->kdev, | 422 | for (i = 0; i < attr_cnt; i++) |
421 | &connector_attrs[i]); | 423 | device_remove_file(&connector->kdev, &connector_attrs[i]); |
422 | device_unregister(&connector->kdev); | 424 | device_unregister(&connector->kdev); |
423 | 425 | ||
424 | out: | 426 | out: |