提交 0a727dea 编写于 作者: A Antonino A. Daplas 提交者: Linus Torvalds

[PATCH] fbcon: 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: NAntonino Daplas <adaplas@pol.net>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 1a6600be
...@@ -133,6 +133,7 @@ static int info_idx = -1; ...@@ -133,6 +133,7 @@ static int info_idx = -1;
/* console rotation */ /* console rotation */
static int rotate; static int rotate;
static int fbcon_has_sysfs;
static const struct consw fb_con; static const struct consw fb_con;
...@@ -3166,11 +3167,26 @@ static struct class_device_attribute class_device_attrs[] = { ...@@ -3166,11 +3167,26 @@ static struct class_device_attribute class_device_attrs[] = {
static int fbcon_init_class_device(void) static int fbcon_init_class_device(void)
{ {
int i; int i, error = 0;
for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) fbcon_has_sysfs = 1;
class_device_create_file(fbcon_class_device,
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]); &class_device_attrs[i]);
fbcon_has_sysfs = 0;
}
return 0; return 0;
} }
...@@ -3279,9 +3295,13 @@ static void __exit fbcon_deinit_class_device(void) ...@@ -3279,9 +3295,13 @@ static void __exit fbcon_deinit_class_device(void)
{ {
int i; int i;
if (fbcon_has_sysfs) {
for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++)
class_device_remove_file(fbcon_class_device, class_device_remove_file(fbcon_class_device,
&class_device_attrs[i]); &class_device_attrs[i]);
fbcon_has_sysfs = 0;
}
} }
static void __exit fb_console_exit(void) static void __exit fb_console_exit(void)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册