From 9783419546749e53efabcaf95162ff22727945b5 Mon Sep 17 00:00:00 2001 From: "Antonino A. Daplas" Date: Tue, 3 Oct 2006 01:14:50 -0700 Subject: [PATCH] --- yaml --- r: 38055 b: refs/heads/master c: 1a6600be3e5dafe2ddcc5d969d931c2591eed896 h: refs/heads/master i: 38053: 83fd8195841f2175a51d99dcfe08955e995f5a47 38051: 8e41071c8691c567a8a3cccfaf83ded031f7b195 38047: 2b422313548164c4e5164f3852d33f39424d6864 v: v3 --- [refs] | 2 +- trunk/drivers/video/fbsysfs.c | 35 ++++++++++++++++++++++++++++------- trunk/include/linux/fb.h | 1 + 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/[refs] b/[refs] index b31c96afdb6c..937bb9961de5 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 928e964f262b522dad57483108f62d87c52ccf82 +refs/heads/master: 1a6600be3e5dafe2ddcc5d969d931c2591eed896 diff --git a/trunk/drivers/video/fbsysfs.c b/trunk/drivers/video/fbsysfs.c index c151dcf68786..d3a50417ed9a 100644 --- a/trunk/drivers/video/fbsysfs.c +++ b/trunk/drivers/video/fbsysfs.c @@ -20,6 +20,8 @@ #include #include +#define FB_SYSFS_FLAG_ATTR 1 + /** * framebuffer_alloc - creates a new frame buffer info structure * @@ -483,12 +485,27 @@ static struct class_device_attribute class_device_attrs[] = { int fb_init_class_device(struct fb_info *fb_info) { - unsigned int i; + int i, error = 0; + class_set_devdata(fb_info->class_device, fb_info); - for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) - class_device_create_file(fb_info->class_device, - &class_device_attrs[i]); + fb_info->class_flag |= FB_SYSFS_FLAG_ATTR; + + for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) { + error = class_device_create_file(fb_info->class_device, + &class_device_attrs[i]); + + if (error) + break; + } + + if (error) { + while (--i >= 0) + class_device_remove_file(fb_info->class_device, + &class_device_attrs[i]); + fb_info->class_flag &= ~FB_SYSFS_FLAG_ATTR; + } + return 0; } @@ -496,9 +513,13 @@ void fb_cleanup_class_device(struct fb_info *fb_info) { unsigned int i; - for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) - class_device_remove_file(fb_info->class_device, - &class_device_attrs[i]); + if (fb_info->class_flag & FB_SYSFS_FLAG_ATTR) { + for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) + class_device_remove_file(fb_info->class_device, + &class_device_attrs[i]); + + fb_info->class_flag &= ~FB_SYSFS_FLAG_ATTR; + } } #ifdef CONFIG_FB_BACKLIGHT diff --git a/trunk/include/linux/fb.h b/trunk/include/linux/fb.h index 37aab314f0c4..3e69241e6a81 100644 --- a/trunk/include/linux/fb.h +++ b/trunk/include/linux/fb.h @@ -776,6 +776,7 @@ struct fb_info { struct fb_ops *fbops; struct device *device; struct class_device *class_device; /* sysfs per device attrs */ + int class_flag; /* private sysfs flags */ #ifdef CONFIG_FB_TILEBLITTING struct fb_tile_ops *tileops; /* Tile Blitting */ #endif