X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fi2c%2Fbusses%2Fi2c-parport.c;h=66696a40c7b5a877c738edae5e848fcdaf521460;hb=refs%2Fheads%2Fvserver;hp=6a9b764caadaea6667d34c5a7714d9b0e4a4b5f9;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c index 6a9b764ca..66696a40c 100644 --- a/drivers/i2c/busses/i2c-parport.c +++ b/drivers/i2c/busses/i2c-parport.c @@ -24,7 +24,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * ------------------------------------------------------------------------ */ -#include #include #include #include @@ -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, @@ -139,7 +138,6 @@ static struct i2c_algo_bit_data parport_algo_data = { .getsda = parport_getsda, .getscl = parport_getscl, .udelay = 60, - .mdelay = 60, .timeout = HZ, }; @@ -147,7 +145,7 @@ static struct i2c_algo_bit_data parport_algo_data = { static struct i2c_adapter parport_adapter = { .owner = THIS_MODULE, - .class = I2C_ADAP_CLASS_SMBUS, + .class = I2C_CLASS_HWMON, .id = I2C_HW_B_LP, .name = "Parallel port adapter", }; @@ -156,12 +154,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", @@ -221,7 +218,7 @@ static void i2c_parport_detach (struct parport *port) if (adapter_parm[type].init.val) line_set(port, 0, &adapter_parm[type].init); - i2c_bit_del_bus(&adapter->adapter); + i2c_del_adapter(&adapter->adapter); parport_unregister_device(adapter->pdev); if (prev) prev->next = adapter->next; @@ -233,7 +230,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 +240,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 ");