提交 8637980b 编写于 作者: A Andrew Morton 提交者: Linus Torvalds

[PATCH] paride: register_chrdev fix

If the user specified `major=0' (odd thing to do), pg.c will use dynamic
allocation.  We need to pick up that major for subsequent unregister_chrdev().
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 a687fb18
...@@ -643,7 +643,8 @@ static ssize_t pg_read(struct file *filp, char __user *buf, size_t count, loff_t ...@@ -643,7 +643,8 @@ static ssize_t pg_read(struct file *filp, char __user *buf, size_t count, loff_t
static int __init pg_init(void) static int __init pg_init(void)
{ {
int unit, err = 0; int unit;
int err;
if (disable){ if (disable){
err = -1; err = -1;
...@@ -657,16 +658,17 @@ static int __init pg_init(void) ...@@ -657,16 +658,17 @@ static int __init pg_init(void)
goto out; goto out;
} }
if (register_chrdev(major, name, &pg_fops)) { err = register_chrdev(major, name, &pg_fops);
if (err < 0) {
printk("pg_init: unable to get major number %d\n", major); printk("pg_init: unable to get major number %d\n", major);
for (unit = 0; unit < PG_UNITS; unit++) { for (unit = 0; unit < PG_UNITS; unit++) {
struct pg *dev = &devices[unit]; struct pg *dev = &devices[unit];
if (dev->present) if (dev->present)
pi_release(dev->pi); pi_release(dev->pi);
} }
err = -1;
goto out; goto out;
} }
major = err; /* In case the user specified `major=0' (dynamic) */
pg_class = class_create(THIS_MODULE, "pg"); pg_class = class_create(THIS_MODULE, "pg");
if (IS_ERR(pg_class)) { if (IS_ERR(pg_class)) {
err = PTR_ERR(pg_class); err = PTR_ERR(pg_class);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册