Changeset 3180

Show
Ignore:
Timestamp:
11/05/05 20:45:58 (8 years ago)
Author:
khali
Message:

Coding style and printk fixes.

Files:
1 modified

Legend:

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

    r3179 r3180  
    160160                                 (val) >= 31 ? 31 : (val)) 
    161161 
    162 /*  
     162/* 
    163163 * ADT7461 is almost identical to LM90 except that attempts to write 
    164164 * values that are outside the range 0 < temp < 127 are treated as 
    165  * the boundary value.  
     165 * the boundary value. 
    166166 */ 
    167167 
     
    212212 */ 
    213213 
    214 struct lm90_data 
    215 { 
     214struct lm90_data { 
    216215        struct i2c_client client; 
    217216        int sysctl_id; 
     
    285284        err = i2c_smbus_read_byte_data(client, reg); 
    286285 
    287         if (err < 0) 
    288         { 
    289                 printk("lm90.o: Register 0x%02x read failed (%d)\n", 
     286        if (err < 0) { 
     287                printk(KERN_WARNING "lm90: Register 0x%02x read failed (%d)\n", 
    290288                       reg, err); 
    291289                return err; 
     
    314312        const char *client_name = ""; 
    315313 
     314        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { 
    316315#ifdef DEBUG 
    317         if (i2c_is_isa_adapter(adapter)) 
    318         { 
    319                 printk("lm90.o: Called for an ISA bus adapter, aborting.\n"); 
    320                 return 0; 
    321         } 
    322 #endif 
    323  
    324         if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 
    325         { 
    326 #ifdef DEBUG 
    327                 printk("lm90.o: I2C bus doesn't support byte read mode, " 
    328                        "skipping.\n"); 
     316                printk(KERN_DEBUG "lm90: adapter doesn't support byte mode, " 
     317                       "skipping\n"); 
    329318#endif 
    330319                return 0; 
    331320        } 
    332321 
    333         if (!(data = kmalloc(sizeof(struct lm90_data), GFP_KERNEL))) 
    334         { 
    335                 printk("lm90.o: Out of memory in lm90_detect (new_client).\n"); 
     322        if (!(data = kmalloc(sizeof(struct lm90_data), GFP_KERNEL))) { 
     323                printk(KERN_ERR "lm90: Out of memory in lm90_detect\n"); 
    336324                return -ENOMEM; 
    337325        } 
     
    365353                kind = lm90; 
    366354 
    367         if (kind < 0) /* detection and identification */ 
    368         { 
     355        if (kind < 0) { /* detection and identification */ 
    369356                u8 man_id, chip_id, reg_config1, reg_convrate; 
    370357 
     
    377364                 || lm90_read_reg(new_client, LM90_REG_R_CONVRATE, 
    378365                                  &reg_convrate) < 0) 
    379                         goto ERROR1; 
    380                  
    381                 if (man_id == 0x01) /* National Semiconductor */ 
    382                 { 
     366                        goto exit_free; 
     367 
     368                if (man_id == 0x01) { /* National Semiconductor */ 
    383369                        u8 reg_config2; 
    384370 
    385371                        if (lm90_read_reg(new_client, LM90_REG_R_CONFIG2, 
    386372                                          &reg_config2) < 0) 
    387                                 goto ERROR1; 
     373                                goto exit_free; 
    388374 
    389375                        if ((reg_config1 & 0x2A) == 0x00 
    390376                         && (reg_config2 & 0xF8) == 0x00 
    391                          && reg_convrate <= 0x09) 
    392                         { 
     377                         && reg_convrate <= 0x09) { 
    393378                                if (address == 0x4C 
    394379                                 && (chip_id & 0xF0) == 0x20) /* LM90 */ 
     
    400385                                        kind = lm99; 
    401386                        } 
    402                 } 
    403                 else if (man_id == 0x41) /* Analog Devices */ 
    404                 { 
     387                } else 
     388                if (man_id == 0x41) { /* Analog Devices */ 
    405389                        if ((chip_id & 0xF0) == 0x40 /* ADM1032 */ 
    406390                         && (reg_config1 & 0x3F) == 0x00 
     
    410394                        if (chip_id == 0x51 /* ADT7461 */ 
    411395                         && (reg_config1 & 0x1F) == 0x00 /* check compat mode */ 
    412                          && reg_convrate <= 0x0A)  
     396                         && reg_convrate <= 0x0A) 
    413397                                kind = adt7461; 
    414                 } 
    415                 else if (man_id == 0x4D) /* Maxim */ 
    416                 { 
     398                } else 
     399                if (man_id == 0x4D) { /* Maxim */ 
    417400                        /* 
    418401                         * The Maxim variants do NOT have a chip_id register. 
     
    431414        } 
    432415 
    433         if (kind <= 0) /* identification failed */ 
    434         { 
    435                 printk("lm90.o: Unsupported chip.\n"); 
    436                 goto ERROR1; 
    437         } 
    438  
    439         if (kind == lm90) 
    440         { 
     416        if (kind <= 0) { /* identification failed */ 
     417                printk(KERN_INFO "lm90: Unsupported chip\n"); 
     418                goto exit_free; 
     419        } 
     420 
     421        if (kind == lm90) { 
    441422                type_name = "lm90"; 
    442423                client_name = "LM90 chip"; 
    443         } 
    444         else if (kind == adm1032) 
    445         { 
     424        } else if (kind == adm1032) { 
    446425                type_name = "adm1032"; 
    447426                client_name = "ADM1032 chip"; 
    448         } 
    449         else if (kind == lm99) 
    450         { 
     427        } else if (kind == lm99) { 
    451428                type_name = "lm99"; 
    452429                client_name = "LM99 chip"; 
    453         } 
    454         else if (kind == lm86) 
    455         { 
     430        } else if (kind == lm86) { 
    456431                type_name = "lm86"; 
    457432                client_name = "LM86 chip"; 
    458         } 
    459         else if (kind == max6657) 
    460         { 
     433        } else if (kind == max6657) { 
    461434                type_name = "max6657"; 
    462435                client_name = "MAX6657 chip"; 
    463         } 
    464         else if (kind == adt7461) 
    465         { 
     436        } else if (kind == adt7461) { 
    466437                type_name = "adt7461"; 
    467438                client_name = "ADT7561 chip"; 
    468         } 
    469         else 
    470         { 
    471                 printk("lm90.o: Unknown kind %d.\n", kind); 
    472                 goto ERROR1; 
     439        } else { 
     440                printk(KERN_ERR "lm90: Unknown kind %d\n", kind); 
     441                goto exit_free; 
    473442        } 
    474443 
     
    487456         */ 
    488457 
    489         if ((err = i2c_attach_client(new_client))) 
    490         { 
    491 #ifdef DEBUG 
    492                 printk("lm90.o: Failed attaching client.\n"); 
    493 #endif 
    494                 goto ERROR1; 
     458        if ((err = i2c_attach_client(new_client))) { 
     459                printk(KERN_ERR "lm90: Failed to attach client (%d)\n", err); 
     460                goto exit_free; 
    495461        } 
    496462 
     
    500466 
    501467        if ((err = i2c_register_entry(new_client, type_name, 
    502              lm90_dir_table_template, THIS_MODULE)) < 0) 
    503         { 
    504 #ifdef DEBUG 
    505                 printk("lm90.o: Failed registering directory entry.\n"); 
    506 #endif 
    507                 goto ERROR2; 
     468             lm90_dir_table_template, THIS_MODULE)) < 0) { 
     469                printk(KERN_ERR "lm90: Failed to register directory entry " 
     470                       "(%d)\n", err); 
     471                goto exit_detach; 
    508472        } 
    509473        data->sysctl_id = err; 
     
    516480        return 0; 
    517481 
    518         ERROR2: 
     482exit_detach: 
    519483        i2c_detach_client(new_client); 
    520         ERROR1: 
     484exit_free: 
    521485        kfree(data); 
    522486        return err; 
     
    533497        i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE, 
    534498                5); /* 2 Hz */ 
    535         if (lm90_read_reg(client, LM90_REG_R_CONFIG1, &config) < 0) 
    536         { 
    537                 printk("lm90.o: Initialization failed!\n"); 
     499        if (lm90_read_reg(client, LM90_REG_R_CONFIG1, &config) < 0) { 
     500                printk(KERN_ERR "lm90: Initialization failed!\n"); 
    538501                return; 
    539502        } 
     
    549512 
    550513        i2c_deregister_entry(((struct lm90_data *) (client->data))->sysctl_id); 
    551         if ((err = i2c_detach_client(client))) 
    552         { 
    553                 printk("lm90.o: Client deregistration failed, client not " 
    554                        "detached.\n"); 
     514        if ((err = i2c_detach_client(client))) { 
     515                printk(KERN_ERR "lm90: Client deregistration failed, client " 
     516                       "not detached (%d)\n", err); 
    555517                return err; 
    556518        } 
     
    567529 
    568530        if ((jiffies - data->last_updated > HZ * 2) || 
    569             (jiffies < data->last_updated) || !data->valid) 
    570         { 
     531            (jiffies < data->last_updated) || !data->valid) { 
    571532                u8 oldh, newh, l; 
    572533#ifdef DEBUG 
    573                 printk("lm90.o: Updating data.\n"); 
     534                printk(KERN_DEBUG "lm90: Updating register values\n"); 
    574535#endif 
    575536 
     
    631592        if (operation == SENSORS_PROC_REAL_INFO) 
    632593                *nrels_mag = 0; /* magnitude */ 
    633         else if (operation == SENSORS_PROC_REAL_READ) 
    634         { 
     594        else if (operation == SENSORS_PROC_REAL_READ) { 
    635595                lm90_update_client(client); 
    636596                results[0] = TEMP1_FROM_REG(data->local_high); 
     
    638598                results[2] = TEMP1_FROM_REG(data->local_temp); 
    639599                *nrels_mag = 3; 
    640         } 
    641         else if (operation == SENSORS_PROC_REAL_WRITE) 
    642         { 
    643                 if (*nrels_mag >= 1) 
    644                 { 
     600        } else if (operation == SENSORS_PROC_REAL_WRITE) { 
     601                if (*nrels_mag >= 1) { 
    645602                        if (data->kind == adt7461) 
    646603                                data->local_high = TEMP1_TO_REG_ADT7461(results[0]); 
     
    650607                                data->local_high); 
    651608                } 
    652                 if (*nrels_mag >= 2) 
    653                 { 
     609                if (*nrels_mag >= 2) { 
    654610                        if (data->kind == adt7461) 
    655611                                data->local_low = TEMP1_TO_REG_ADT7461(results[1]); 
     
    669625        if (operation == SENSORS_PROC_REAL_INFO) 
    670626                *nrels_mag = 1; /* magnitude */ 
    671         else if (operation == SENSORS_PROC_REAL_READ) 
    672         { 
     627        else if (operation == SENSORS_PROC_REAL_READ) { 
    673628                lm90_update_client(client); 
    674629                results[0] = TEMP2_FROM_REG(data->remote_high); 
     
    676631                results[2] = TEMP2_FROM_REG(data->remote_temp); 
    677632                *nrels_mag = 3; 
    678         } 
    679         else if (operation == SENSORS_PROC_REAL_WRITE) 
    680         { 
    681                 if (*nrels_mag >= 1) 
    682                 { 
     633        } else if (operation == SENSORS_PROC_REAL_WRITE) { 
     634                if (*nrels_mag >= 1) { 
    683635                        if (data->kind == adt7461) 
    684636                                data->remote_high = TEMP2_TO_REG_ADT7461(results[0]); 
    685                         else  
     637                        else 
    686638                                data->remote_high = TEMP2_TO_REG(results[0]); 
    687639                        i2c_smbus_write_byte_data(client, LM90_REG_W_REMOTE_HIGHH, 
     
    690642                                data->remote_high & 0xFF); 
    691643                } 
    692                 if (*nrels_mag >= 2) 
    693                 { 
     644                if (*nrels_mag >= 2) { 
    694645                        if (data->kind == adt7461) 
    695646                                data->remote_low = TEMP2_TO_REG_ADT7461(results[1]); 
    696                         else  
     647                        else 
    697648                                data->remote_low = TEMP2_TO_REG(results[1]); 
    698649                        i2c_smbus_write_byte_data(client, LM90_REG_W_REMOTE_LOWH, 
     
    711662        if (operation == SENSORS_PROC_REAL_INFO) 
    712663                *nrels_mag = 0; /* magnitude */ 
    713         else if (operation == SENSORS_PROC_REAL_READ) 
    714         { 
     664        else if (operation == SENSORS_PROC_REAL_READ) { 
    715665                lm90_update_client(client); 
    716666                results[0] = TEMP1_FROM_REG(data->local_crit); 
    717667                *nrels_mag = 1; 
    718         } 
    719         else if (operation == SENSORS_PROC_REAL_WRITE) 
    720         { 
    721                 if (*nrels_mag >= 1) 
    722                 { 
     668        } else if (operation == SENSORS_PROC_REAL_WRITE) { 
     669                if (*nrels_mag >= 1) { 
    723670                        if (data->kind == adt7461) 
    724671                                data->local_crit = TEMP1_TO_REG_ADT7461(results[0]); 
     
    738685        if (operation == SENSORS_PROC_REAL_INFO) 
    739686                *nrels_mag = 0; /* magnitude */ 
    740         else if (operation == SENSORS_PROC_REAL_READ) 
    741         { 
     687        else if (operation == SENSORS_PROC_REAL_READ) { 
    742688                lm90_update_client(client); 
    743689                results[0] = TEMP1_FROM_REG(data->remote_crit); 
    744690                *nrels_mag = 1; 
    745         } 
    746         else if (operation == SENSORS_PROC_REAL_WRITE) 
    747         { 
    748                 if (*nrels_mag >= 1) 
    749                 { 
     691        } else if (operation == SENSORS_PROC_REAL_WRITE) { 
     692                if (*nrels_mag >= 1) { 
    750693                        if (data->kind == adt7461) 
    751694                                data->remote_crit = TEMP1_TO_REG_ADT7461(results[0]); 
     
    780723        if (operation == SENSORS_PROC_REAL_INFO) 
    781724                *nrels_mag = 0; /* magnitude */ 
    782         else if (operation == SENSORS_PROC_REAL_READ) 
    783         { 
     725        else if (operation == SENSORS_PROC_REAL_READ) { 
    784726                lm90_update_client(client); 
    785727                results[0] = TEMP1_FROM_REG(data->local_crit) - 
    786728                        TEMP1_FROM_REG(data->hyst); 
    787729                *nrels_mag = 1; 
    788         } 
    789         else if (operation == SENSORS_PROC_REAL_WRITE) 
    790         { 
    791                 if (*nrels_mag >= 1) 
    792                 { 
     730        } else if (operation == SENSORS_PROC_REAL_WRITE) { 
     731                if (*nrels_mag >= 1) { 
    793732                        data->hyst = HYST_TO_REG(data->local_crit - results[0]); 
    794733                        i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, 
     
    805744        if (operation == SENSORS_PROC_REAL_INFO) 
    806745                *nrels_mag = 0; /* magnitude */ 
    807         else if (operation == SENSORS_PROC_REAL_READ) 
    808         { 
     746        else if (operation == SENSORS_PROC_REAL_READ) { 
    809747                lm90_update_client(client); 
    810748                results[0] = TEMP1_FROM_REG(data->remote_crit) - 
     
    821759        if (operation == SENSORS_PROC_REAL_INFO) 
    822760                *nrels_mag = 0; /* magnitude */ 
    823         else if (operation == SENSORS_PROC_REAL_READ) 
    824         { 
     761        else if (operation == SENSORS_PROC_REAL_READ) { 
    825762                lm90_update_client(client); 
    826763                results[0] = data->alarms; 
     
    831768static int __init sm_lm90_init(void) 
    832769{ 
    833         printk(KERN_INFO "lm90.o version %s (%s)\n", LM_VERSION, LM_DATE); 
     770        printk(KERN_INFO "lm90 driver version %s (%s)\n", LM_VERSION, 
     771               LM_DATE); 
    834772        return i2c_add_driver(&lm90_driver); 
    835773}