diff options
author | Antonino A. Daplas <adaplas@gmail.com> | 2006-10-03 04:14:50 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-03 11:04:10 -0400 |
commit | 1a6600be3e5dafe2ddcc5d969d931c2591eed896 (patch) | |
tree | 453d3d63fce8f1092f21546a4c00d350cfe04fdd /drivers/video/fbsysfs.c | |
parent | 928e964f262b522dad57483108f62d87c52ccf82 (diff) |
[PATCH] fbdev: Honor the return value of device_create_file
Check the return value of device_create_file(). If return is 'fail', remove
attributes by calling device_remove_file().
Signed-off-by: Antonino Daplas <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/video/fbsysfs.c')
-rw-r--r-- | drivers/video/fbsysfs.c | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c index c151dcf68786..d3a50417ed9a 100644 --- a/drivers/video/fbsysfs.c +++ b/drivers/video/fbsysfs.c | |||
@@ -20,6 +20,8 @@ | |||
20 | #include <linux/console.h> | 20 | #include <linux/console.h> |
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | 22 | ||
23 | #define FB_SYSFS_FLAG_ATTR 1 | ||
24 | |||
23 | /** | 25 | /** |
24 | * framebuffer_alloc - creates a new frame buffer info structure | 26 | * framebuffer_alloc - creates a new frame buffer info structure |
25 | * | 27 | * |
@@ -483,12 +485,27 @@ static struct class_device_attribute class_device_attrs[] = { | |||
483 | 485 | ||
484 | int fb_init_class_device(struct fb_info *fb_info) | 486 | int fb_init_class_device(struct fb_info *fb_info) |
485 | { | 487 | { |
486 | unsigned int i; | 488 | int i, error = 0; |
489 | |||
487 | class_set_devdata(fb_info->class_device, fb_info); | 490 | class_set_devdata(fb_info->class_device, fb_info); |
488 | 491 | ||
489 | for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) | 492 | fb_info->class_flag |= FB_SYSFS_FLAG_ATTR; |
490 | class_device_create_file(fb_info->class_device, | 493 | |
491 | &class_device_attrs[i]); | 494 | for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) { |
495 | error = class_device_create_file(fb_info->class_device, | ||
496 | &class_device_attrs[i]); | ||
497 | |||
498 | if (error) | ||
499 | break; | ||
500 | } | ||
501 | |||
502 | if (error) { | ||
503 | while (--i >= 0) | ||
504 | class_device_remove_file(fb_info->class_device, | ||
505 | &class_device_attrs[i]); | ||
506 | fb_info->class_flag &= ~FB_SYSFS_FLAG_ATTR; | ||
507 | } | ||
508 | |||
492 | return 0; | 509 | return 0; |
493 | } | 510 | } |
494 | 511 | ||
@@ -496,9 +513,13 @@ void fb_cleanup_class_device(struct fb_info *fb_info) | |||
496 | { | 513 | { |
497 | unsigned int i; | 514 | unsigned int i; |
498 | 515 | ||
499 | for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) | 516 | if (fb_info->class_flag & FB_SYSFS_FLAG_ATTR) { |
500 | class_device_remove_file(fb_info->class_device, | 517 | for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) |
501 | &class_device_attrs[i]); | 518 | class_device_remove_file(fb_info->class_device, |
519 | &class_device_attrs[i]); | ||
520 | |||
521 | fb_info->class_flag &= ~FB_SYSFS_FLAG_ATTR; | ||
522 | } | ||
502 | } | 523 | } |
503 | 524 | ||
504 | #ifdef CONFIG_FB_BACKLIGHT | 525 | #ifdef CONFIG_FB_BACKLIGHT |