Changeset 1692
- Timestamp:
- 01/11/03 18:53:12 (10 years ago)
- Files:
-
- 1 modified
-
lm-sensors/trunk/kernel/chips/adm1021.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/kernel/chips/adm1021.c
r1685 r1692 28 28 #include <linux/init.h> 29 29 30 #ifdef MODULE_LICENSE31 MODULE_LICENSE("GPL");32 #endif33 34 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18)) || \35 (LINUX_VERSION_CODE == KERNEL_VERSION(2,3,0))36 #define init_MUTEX(s) do { *(s) = MUTEX; } while(0)37 #endif38 39 #ifndef THIS_MODULE40 #define THIS_MODULE NULL41 #endif42 30 43 31 /* Addresses to scan */ … … 121 109 }; 122 110 123 #ifdef MODULE124 extern int init_module(void);125 extern int cleanup_module(void);126 #endif /* MODULE */127 128 #ifdef MODULE129 static130 #else131 extern132 #endif133 int __init sensors_adm1021_init(void);134 static int __init adm1021_cleanup(void);135 111 static int adm1021_attach_adapter(struct i2c_adapter *adapter); 136 112 static int adm1021_detect(struct i2c_adapter *adapter, int address, … … 163 139 /* This is the driver that will be inserted */ 164 140 static struct i2c_driver adm1021_driver = { 165 /* name */"ADM1021, MAX1617 sensor driver",166 /* id */I2C_DRIVERID_ADM1021,167 /* flags */I2C_DF_NOTIFY,168 /* attach_adapter */ &adm1021_attach_adapter,169 /* detach_client */ &adm1021_detach_client,170 /* command */ &adm1021_command,171 /* inc_use */ &adm1021_inc_use,172 /* dec_use */ &adm1021_dec_use141 .name = "ADM1021, MAX1617 sensor driver", 142 .id = I2C_DRIVERID_ADM1021, 143 .flags = I2C_DF_NOTIFY, 144 .attach_adapter = adm1021_attach_adapter, 145 .detach_client = adm1021_detach_client, 146 .command = adm1021_command, 147 .inc_use = adm1021_inc_use, 148 .dec_use = adm1021_dec_use 173 149 }; 174 150 … … 200 176 }; 201 177 202 /* Used by init/cleanup */203 static int __initdata adm1021_initialized = 0;204 205 178 /* I choose here for semi-static allocation. Complete dynamic 206 179 allocation could also be used; the code needed for this would probably … … 234 207 235 208 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 236 goto ERROR0;209 goto error0; 237 210 238 211 /* OK. For now, we presume we have a valid client. We now create the … … 244 217 GFP_KERNEL))) { 245 218 err = -ENOMEM; 246 goto ERROR0;219 goto error0; 247 220 } 248 221 … … 260 233 (adm1021_read_value(new_client, ADM1021_REG_STATUS) & 261 234 0x03) != 0x00) 262 goto ERROR1;235 goto error1; 263 236 } 264 237 … … 320 293 kind); 321 294 #endif 322 goto ERROR1;295 goto error1; 323 296 } 324 297 … … 333 306 /* Tell the I2C layer a new client has arrived */ 334 307 if ((err = i2c_attach_client(new_client))) 335 goto ERROR3;308 goto error3; 336 309 337 310 /* Register a new directory entry with module sensors */ … … 344 317 THIS_MODULE)) < 0) { 345 318 err = i; 346 goto ERROR4;319 goto error4; 347 320 } 348 321 data->sysctl_id = i; … … 352 325 return 0; 353 326 354 /* OK, this is not exactly good programming practice, usually. But it is 355 very code-efficient in this case. */ 356 357 ERROR4: 327 error4: 358 328 i2c_detach_client(new_client); 359 ERROR3:360 ERROR1:329 error3: 330 error1: 361 331 kfree(new_client); 362 ERROR0:332 error0: 363 333 return err; 364 334 } … … 525 495 int ctl_name, int *nrels_mag, long *results) 526 496 { 527 int prec=0;528 497 struct adm1021_data *data = client->data; 498 int prec = 0; 499 529 500 if (operation == SENSORS_PROC_REAL_INFO) 530 501 if (data->type == adm1023) { *nrels_mag = 3; } … … 624 595 } 625 596 626 int __init sensors_adm1021_init(void) 627 { 628 int res; 629 630 printk("adm1021.o version %s (%s)\n", LM_VERSION, LM_DATE); 631 adm1021_initialized = 0; 632 if ((res = i2c_add_driver(&adm1021_driver))) { 633 printk 634 ("adm1021.o: Driver registration failed, module not inserted.\n"); 635 adm1021_cleanup(); 636 return res; 637 } 638 adm1021_initialized++; 639 return 0; 640 } 641 642 int __init adm1021_cleanup(void) 643 { 644 int res; 645 646 if (adm1021_initialized >= 1) { 647 if ((res = i2c_del_driver(&adm1021_driver))) { 648 printk 649 ("adm1021.o: Driver deregistration failed, module not removed.\n"); 650 return res; 651 } 652 adm1021_initialized--; 653 } 654 655 return 0; 656 } 657 658 EXPORT_NO_SYMBOLS; 659 660 #ifdef MODULE 597 static int __init sensors_adm1021_init(void) 598 { 599 printk(KERN_INFO "adm1021.o version %s (%s)\n", LM_VERSION, LM_DATE); 600 return i2c_add_driver(&adm1021_driver); 601 } 602 603 static void __exit sensors_adm1021_exit(void) 604 { 605 i2c_del_driver(&adm1021_driver); 606 } 661 607 662 608 MODULE_AUTHOR 663 609 ("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>"); 664 610 MODULE_DESCRIPTION("adm1021 driver"); 611 MODULE_LICENSE("GPL"); 665 612 666 613 MODULE_PARM(read_only, "i"); 667 614 MODULE_PARM_DESC(read_only, "Don't set any values, read only mode"); 668 615 669 int init_module(void) 670 { 671 return sensors_adm1021_init(); 672 } 673 674 int cleanup_module(void) 675 { 676 return adm1021_cleanup(); 677 } 678 679 #endif /* MODULE */ 616 module_init(sensors_adm1021_init) 617 module_exit(sensors_adm1021_exit)
