#include <linux/console.h>
#include <linux/module.h>
+#define FB_SYSFS_FLAG_ATTR 1
+
/**
* framebuffer_alloc - creates a new frame buffer info structure
*
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;
}
{
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