Changeset 1692

Show
Ignore:
Timestamp:
01/11/03 18:53:12 (10 years ago)
Author:
mds
Message:

backport from kernel 2.5.54 which contained changes from

Christoph Hellwig <hch@…> and Pavel <pavel@…>;
Leave in 3 things: refcounts, sensors.h, and init printk.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/kernel/chips/adm1021.c

    r1685 r1692  
    2828#include <linux/init.h> 
    2929 
    30 #ifdef MODULE_LICENSE 
    31 MODULE_LICENSE("GPL"); 
    32 #endif 
    33  
    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 #endif 
    38  
    39 #ifndef THIS_MODULE 
    40 #define THIS_MODULE NULL 
    41 #endif 
    4230 
    4331/* Addresses to scan */ 
     
    121109}; 
    122110 
    123 #ifdef MODULE 
    124 extern int init_module(void); 
    125 extern int cleanup_module(void); 
    126 #endif                          /* MODULE */ 
    127  
    128 #ifdef MODULE 
    129 static 
    130 #else 
    131 extern 
    132 #endif 
    133 int __init sensors_adm1021_init(void); 
    134 static int __init adm1021_cleanup(void); 
    135111static int adm1021_attach_adapter(struct i2c_adapter *adapter); 
    136112static int adm1021_detect(struct i2c_adapter *adapter, int address, 
     
    163139/* This is the driver that will be inserted */ 
    164140static 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_use 
     141        .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 
    173149}; 
    174150 
     
    200176}; 
    201177 
    202 /* Used by init/cleanup */ 
    203 static int __initdata adm1021_initialized = 0; 
    204  
    205178/* I choose here for semi-static allocation. Complete dynamic 
    206179   allocation could also be used; the code needed for this would probably 
     
    234207 
    235208        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 
    236                 goto ERROR0; 
     209                goto error0; 
    237210 
    238211        /* OK. For now, we presume we have a valid client. We now create the 
     
    244217                                   GFP_KERNEL))) { 
    245218                err = -ENOMEM; 
    246                 goto ERROR0; 
     219                goto error0; 
    247220        } 
    248221 
     
    260233                    (adm1021_read_value(new_client, ADM1021_REG_STATUS) & 
    261234                     0x03) != 0x00) 
    262                         goto ERROR1; 
     235                        goto error1; 
    263236        } 
    264237 
     
    320293                       kind); 
    321294#endif 
    322                 goto ERROR1; 
     295                goto error1; 
    323296        } 
    324297 
     
    333306        /* Tell the I2C layer a new client has arrived */ 
    334307        if ((err = i2c_attach_client(new_client))) 
    335                 goto ERROR3; 
     308                goto error3; 
    336309 
    337310        /* Register a new directory entry with module sensors */ 
     
    344317                                        THIS_MODULE)) < 0) { 
    345318                err = i; 
    346                 goto ERROR4; 
     319                goto error4; 
    347320        } 
    348321        data->sysctl_id = i; 
     
    352325        return 0; 
    353326 
    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: 
    358328        i2c_detach_client(new_client); 
    359       ERROR3: 
    360       ERROR1: 
     329      error3: 
     330      error1: 
    361331        kfree(new_client); 
    362       ERROR0: 
     332      error0: 
    363333        return err; 
    364334} 
     
    525495                         int ctl_name, int *nrels_mag, long *results) 
    526496{ 
    527 int prec=0; 
    528497        struct adm1021_data *data = client->data; 
     498        int prec = 0; 
     499 
    529500        if (operation == SENSORS_PROC_REAL_INFO) 
    530501                if (data->type == adm1023) { *nrels_mag = 3; } 
     
    624595} 
    625596 
    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 
     597static 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 
     603static void __exit sensors_adm1021_exit(void) 
     604{ 
     605        i2c_del_driver(&adm1021_driver); 
     606} 
    661607 
    662608MODULE_AUTHOR 
    663609    ("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>"); 
    664610MODULE_DESCRIPTION("adm1021 driver"); 
     611MODULE_LICENSE("GPL"); 
    665612 
    666613MODULE_PARM(read_only, "i"); 
    667614MODULE_PARM_DESC(read_only, "Don't set any values, read only mode"); 
    668615 
    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 */ 
     616module_init(sensors_adm1021_init) 
     617module_exit(sensors_adm1021_exit)