diff options
Diffstat (limited to 'drivers/gpu/drm/drm_sysfs.c')
-rw-r--r-- | drivers/gpu/drm/drm_sysfs.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index 014ce24761b9..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" |
@@ -353,7 +354,10 @@ static struct bin_attribute edid_attr = { | |||
353 | int drm_sysfs_connector_add(struct drm_connector *connector) | 354 | int drm_sysfs_connector_add(struct drm_connector *connector) |
354 | { | 355 | { |
355 | struct drm_device *dev = connector->dev; | 356 | struct drm_device *dev = connector->dev; |
356 | int ret = 0, i, j; | 357 | int attr_cnt = 0; |
358 | int opt_cnt = 0; | ||
359 | int i; | ||
360 | int ret = 0; | ||
357 | 361 | ||
358 | /* 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 */ |
359 | BUG_ON(device_is_registered(&connector->kdev)); | 363 | BUG_ON(device_is_registered(&connector->kdev)); |
@@ -376,8 +380,8 @@ int drm_sysfs_connector_add(struct drm_connector *connector) | |||
376 | 380 | ||
377 | /* Standard attributes */ | 381 | /* Standard attributes */ |
378 | 382 | ||
379 | for (i = 0; i < ARRAY_SIZE(connector_attrs); i++) { | 383 | for (attr_cnt = 0; attr_cnt < ARRAY_SIZE(connector_attrs); attr_cnt++) { |
380 | ret = device_create_file(&connector->kdev, &connector_attrs[i]); | 384 | ret = device_create_file(&connector->kdev, &connector_attrs[attr_cnt]); |
381 | if (ret) | 385 | if (ret) |
382 | goto err_out_files; | 386 | goto err_out_files; |
383 | } | 387 | } |
@@ -393,8 +397,8 @@ int drm_sysfs_connector_add(struct drm_connector *connector) | |||
393 | case DRM_MODE_CONNECTOR_SVIDEO: | 397 | case DRM_MODE_CONNECTOR_SVIDEO: |
394 | case DRM_MODE_CONNECTOR_Component: | 398 | case DRM_MODE_CONNECTOR_Component: |
395 | case DRM_MODE_CONNECTOR_TV: | 399 | case DRM_MODE_CONNECTOR_TV: |
396 | for (i = 0; i < ARRAY_SIZE(connector_attrs_opt1); i++) { | 400 | for (opt_cnt = 0; opt_cnt < ARRAY_SIZE(connector_attrs_opt1); opt_cnt++) { |
397 | ret = device_create_file(&connector->kdev, &connector_attrs_opt1[i]); | 401 | ret = device_create_file(&connector->kdev, &connector_attrs_opt1[opt_cnt]); |
398 | if (ret) | 402 | if (ret) |
399 | goto err_out_files; | 403 | goto err_out_files; |
400 | } | 404 | } |
@@ -413,10 +417,10 @@ int drm_sysfs_connector_add(struct drm_connector *connector) | |||
413 | return 0; | 417 | return 0; |
414 | 418 | ||
415 | err_out_files: | 419 | err_out_files: |
416 | if (i > 0) | 420 | for (i = 0; i < opt_cnt; i++) |
417 | for (j = 0; j < i; j++) | 421 | device_remove_file(&connector->kdev, &connector_attrs_opt1[i]); |
418 | device_remove_file(&connector->kdev, | 422 | for (i = 0; i < attr_cnt; i++) |
419 | &connector_attrs[i]); | 423 | device_remove_file(&connector->kdev, &connector_attrs[i]); |
420 | device_unregister(&connector->kdev); | 424 | device_unregister(&connector->kdev); |
421 | 425 | ||
422 | out: | 426 | out: |