Skip to content

Commit

Permalink
[PATCH] fbcon: Honor the return value of device_create_file
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Antonino A. Daplas authored and Linus Torvalds committed Oct 3, 2006
1 parent 1a6600b commit 0a727de
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions drivers/video/console/fbcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ static int info_idx = -1;

/* console rotation */
static int rotate;
static int fbcon_has_sysfs;

static const struct consw fb_con;

Expand Down Expand Up @@ -3166,11 +3167,26 @@ static struct class_device_attribute class_device_attrs[] = {

static int fbcon_init_class_device(void)
{
int i;
int i, error = 0;

fbcon_has_sysfs = 1;

for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) {
error = class_device_create_file(fbcon_class_device,
&class_device_attrs[i]);

if (error)
break;
}

if (error) {
while (--i >= 0)
class_device_remove_file(fbcon_class_device,
&class_device_attrs[i]);

fbcon_has_sysfs = 0;
}

for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
class_device_create_file(fbcon_class_device,
&class_device_attrs[i]);
return 0;
}

Expand Down Expand Up @@ -3279,9 +3295,13 @@ static void __exit fbcon_deinit_class_device(void)
{
int i;

for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
class_device_remove_file(fbcon_class_device,
&class_device_attrs[i]);
if (fbcon_has_sysfs) {
for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
class_device_remove_file(fbcon_class_device,
&class_device_attrs[i]);

fbcon_has_sysfs = 0;
}
}

static void __exit fb_console_exit(void)
Expand Down

0 comments on commit 0a727de

Please sign in to comment.