aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntonino A. Daplas <adaplas@gmail.com>2006-10-03 04:14:50 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-03 11:04:10 -0400
commit1a6600be3e5dafe2ddcc5d969d931c2591eed896 (patch)
tree453d3d63fce8f1092f21546a4c00d350cfe04fdd
parent928e964f262b522dad57483108f62d87c52ccf82 (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>
-rw-r--r--drivers/video/fbsysfs.c35
-rw-r--r--include/linux/fb.h1
2 files changed, 29 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
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 37aab314f0c4..3e69241e6a81 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -776,6 +776,7 @@ struct fb_info {
776 struct fb_ops *fbops; 776 struct fb_ops *fbops;
777 struct device *device; 777 struct device *device;
778 struct class_device *class_device; /* sysfs per device attrs */ 778 struct class_device *class_device; /* sysfs per device attrs */
779 int class_flag; /* private sysfs flags */
779#ifdef CONFIG_FB_TILEBLITTING 780#ifdef CONFIG_FB_TILEBLITTING
780 struct fb_tile_ops *tileops; /* Tile Blitting */ 781 struct fb_tile_ops *tileops; /* Tile Blitting */
781#endif 782#endif