Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / i2c / busses / i2c-parport.c
index e9560ba..934bd55 100644 (file)
@@ -24,7 +24,6 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  * ------------------------------------------------------------------------ */
 
-#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -131,7 +130,7 @@ static int parport_getsda(void *data)
 /* Encapsulate the functions above in the correct structure.
    Note that this is only a template, from which the real structures are
    copied. The attaching code will set getscl to NULL for adapters that
-   cannot read SCL back, and will also make the the data field point to
+   cannot read SCL back, and will also make the data field point to
    the parallel port structure. */
 static struct i2c_algo_bit_data parport_algo_data = {
        .setsda         = parport_setsda,
@@ -156,12 +155,11 @@ static void i2c_parport_attach (struct parport *port)
 {
        struct i2c_par *adapter;
        
-       adapter = kmalloc(sizeof(struct i2c_par), GFP_KERNEL);
+       adapter = kzalloc(sizeof(struct i2c_par), GFP_KERNEL);
        if (adapter == NULL) {
-               printk(KERN_ERR "i2c-parport: Failed to kmalloc\n");
+               printk(KERN_ERR "i2c-parport: Failed to kzalloc\n");
                return;
        }
-       memset(adapter, 0x00, sizeof(struct i2c_par));
 
        pr_debug("i2c-parport: attaching to %s\n", port->name);
        adapter->pdev = parport_register_device(port, "i2c-parport",
@@ -233,7 +231,7 @@ static void i2c_parport_detach (struct parport *port)
        }
 }
 
-static struct parport_driver i2c_driver = {
+static struct parport_driver i2c_parport_driver = {
        .name   = "i2c-parport",
        .attach = i2c_parport_attach,
        .detach = i2c_parport_detach,
@@ -243,20 +241,22 @@ static struct parport_driver i2c_driver = {
 
 static int __init i2c_parport_init(void)
 {
-       int type_count;
+       if (type < 0) {
+               printk(KERN_WARNING "i2c-parport: adapter type unspecified\n");
+               return -ENODEV;
+       }
 
-       type_count = sizeof(adapter_parm)/sizeof(struct adapter_parm);
-       if (type < 0 || type >= type_count) {
+       if (type >= ARRAY_SIZE(adapter_parm)) {
                printk(KERN_WARNING "i2c-parport: invalid type (%d)\n", type);
-               type = 0;
+               return -ENODEV;
        }
-       
-       return parport_register_driver(&i2c_driver);
+
+       return parport_register_driver(&i2c_parport_driver);
 }
 
 static void __exit i2c_parport_exit(void)
 {
-       parport_unregister_driver(&i2c_driver);
+       parport_unregister_driver(&i2c_parport_driver);
 }
 
 MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");