aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/fbsysfs.c35
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
484int fb_init_class_device(struct fb_info *fb_info) 486int 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