提交 6d9eac34 编写于 作者: A Andrew Morton 提交者: Linus Torvalds

[PATCH] capi: register_chrdev() fix

If the user specified `major=0' (odd thing to do), capi.c will use dynamic
allocation.  We need to pick up that major for subsequent unregister_chrdev().
Acked-by: NKarsten Keil <kkeil@suse.de>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 829d5f68
...@@ -1485,6 +1485,7 @@ static int __init capi_init(void) ...@@ -1485,6 +1485,7 @@ static int __init capi_init(void)
{ {
char *p; char *p;
char *compileinfo; char *compileinfo;
int major_ret;
if ((p = strchr(revision, ':')) != 0 && p[1]) { if ((p = strchr(revision, ':')) != 0 && p[1]) {
strlcpy(rev, p + 2, sizeof(rev)); strlcpy(rev, p + 2, sizeof(rev));
...@@ -1493,11 +1494,12 @@ static int __init capi_init(void) ...@@ -1493,11 +1494,12 @@ static int __init capi_init(void)
} else } else
strcpy(rev, "1.0"); strcpy(rev, "1.0");
if (register_chrdev(capi_major, "capi20", &capi_fops)) { major_ret = register_chrdev(capi_major, "capi20", &capi_fops);
if (major_ret < 0) {
printk(KERN_ERR "capi20: unable to get major %d\n", capi_major); printk(KERN_ERR "capi20: unable to get major %d\n", capi_major);
return -EIO; return major_ret;
} }
capi_major = major_ret;
capi_class = class_create(THIS_MODULE, "capi"); capi_class = class_create(THIS_MODULE, "capi");
if (IS_ERR(capi_class)) { if (IS_ERR(capi_class)) {
unregister_chrdev(capi_major, "capi20"); unregister_chrdev(capi_major, "capi20");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册