[PATCH] cm4000_cs: fix return value check
authorAkinobu Mita <akinobu.mita@gmail.com>
Tue, 17 Oct 2006 06:25:59 +0000 (15:25 +0900)
committerDominik Brodowski <linux@dominikbrodowski.net>
Tue, 5 Dec 2006 01:09:13 +0000 (20:09 -0500)
The return value of class_create() need to be checked with IS_ERR().
And register_chrdev() returns errno on failure.
This patch includes these fixes for cm4000_cs and cm4040_cs.

Signed-off-by: Akinbou Mita <akinobu.mita@gmail.com>
Signed-off-by: Harald Welte <laforge@gnumonks.org>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
drivers/char/pcmcia/cm4000_cs.c
drivers/char/pcmcia/cm4040_cs.c

index 50d20aafeb186638f836c3967644370c314168bf..d9fdef2279106c6b5c410165a380528c133056ad 100644 (file)
@@ -1973,14 +1973,14 @@ static int __init cmm_init(void)
        printk(KERN_INFO "%s\n", version);
 
        cmm_class = class_create(THIS_MODULE, "cardman_4000");
-       if (!cmm_class)
-               return -1;
+       if (IS_ERR(cmm_class))
+               return PTR_ERR(cmm_class);
 
        major = register_chrdev(0, DEVICE_NAME, &cm4000_fops);
        if (major < 0) {
                printk(KERN_WARNING MODULE_NAME
                        ": could not get major number\n");
-               return -1;
+               return major;
        }
 
        rc = pcmcia_register_driver(&cm4000_driver);
index 55cf4be42976913547663b6b15b41b196d9c5800..7368332c698c88dd3e10d69cb9a4bdb5371f6815 100644 (file)
@@ -721,14 +721,14 @@ static int __init cm4040_init(void)
 
        printk(KERN_INFO "%s\n", version);
        cmx_class = class_create(THIS_MODULE, "cardman_4040");
-       if (!cmx_class)
-               return -1;
+       if (IS_ERR(cmx_class))
+               return PTR_ERR(cmx_class);
 
        major = register_chrdev(0, DEVICE_NAME, &reader_fops);
        if (major < 0) {
                printk(KERN_WARNING MODULE_NAME
                        ": could not get major number\n");
-               return -1;
+               return major;
        }
 
        rc = pcmcia_register_driver(&reader_driver);