Changeset 2658

Show
Ignore:
Timestamp:
08/12/04 21:51:04 (9 years ago)
Author:
khali
Message:

Backport some cleanups and fixes from 2.6.

Files:
1 modified

Legend:

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

    r2445 r2658  
    22    adm9240.c - Part of lm_sensors, Linux kernel modules for hardware 
    33             monitoring 
    4     Copyright (c) 1999  Frodo Looijaard <frodol@dds.nl> 
     4    Copyright (C) 1999  Frodo Looijaard <frodol@dds.nl> 
    55    and Philip Edelbrock <phil@netroedge.com> 
    66 
     
    5454#include <linux/init.h> 
    5555#include "version.h" 
    56  
    57 MODULE_LICENSE("GPL"); 
    5856 
    5957/* Addresses to scan */ 
     
    127125   these macros are called: arguments may be evaluated more than once. 
    128126   Fixing this is just not worth it. */ 
    129 #define IN_TO_REG(val,nr) (SENSORS_LIMIT(((val) & 0xff),0,255)) 
     127#define IN_TO_REG(val,nr) (SENSORS_LIMIT((val), 0, 255)) 
    130128#define IN_FROM_REG(val,nr) (val) 
    131129 
     
    142140                               (val)==255?0:1350000/((div)*(val))) 
    143141 
    144 #define TEMP_FROM_REG(temp) \ 
    145    ((temp)<256?((((temp)&0x1fe) >> 1) * 10)      + ((temp) & 1) * 5:  \ 
    146                ((((temp)&0x1fe) >> 1) -255) * 10 - ((temp) & 1) * 5)  \ 
    147  
    148 #define TEMP_LIMIT_FROM_REG(val) (((val)>0x80?(val)-0x100:(val))*10) 
    149  
    150 #define TEMP_LIMIT_TO_REG(val) SENSORS_LIMIT(((val)<0?(((val)-5)/10):\ 
     142#define TEMP_FROM_REG(temp) ((temp)<256 ? (temp) * 5 : \ 
     143                             ((temp) - 512) * 5) 
     144 
     145#define TEMP_LIMIT_FROM_REG(val) (((val)>=0x80?(val)-0x100:(val))*10) 
     146 
     147#define TEMP_LIMIT_TO_REG(val) SENSORS_LIMIT(((val)<0?(((val)-5)/10)+256:\ 
    151148                                                      ((val)+5)/10), \ 
    152149                                             0,255) 
     
    160157                           205-(val)*5) 
    161158 
    162 /* For each registered ADM9240, we need to keep some data in memory. That 
    163    data is pointed to by adm9240_list[NR]->data. The structure itself is 
    164    dynamically allocated, at the same time when a new adm9240 client is 
    165    allocated. */ 
     159/* For each registered ADM9240, we need to keep some data in memory. */ 
    166160struct adm9240_data { 
    167161        struct i2c_client client; 
     
    193187static int adm9240_detach_client(struct i2c_client *client); 
    194188 
    195 static int adm9240_read_value(struct i2c_client *client, u8 register); 
    196 static int adm9240_write_value(struct i2c_client *client, u8 register, 
    197                                u8 value); 
     189static int adm9240_read_value(struct i2c_client *client, u8 reg); 
     190static int adm9240_write_value(struct i2c_client *client, u8 reg, u8 value); 
    198191static void adm9240_update_client(struct i2c_client *client); 
    199192static void adm9240_init_client(struct i2c_client *client); 
     
    308301        const char *client_name = ""; 
    309302 
    310         /* Make sure we aren't probing the ISA bus!! This is just a safety check 
    311            at this moment; i2c_detect really won't call us. */ 
    312 #ifdef DEBUG 
    313         if (i2c_is_isa_adapter(adapter)) { 
    314                 printk 
    315                     ("adm9240.o: adm9240_detect called for an ISA bus adapter?!?\n"); 
    316                 return 0; 
    317         } 
    318 #endif 
    319  
    320303        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 
    321304                goto ERROR0; 
     
    444427static int adm9240_read_value(struct i2c_client *client, u8 reg) 
    445428{ 
    446         return 0xFF & i2c_smbus_read_byte_data(client, reg); 
     429        return i2c_smbus_read_byte_data(client, reg); 
    447430} 
    448431 
     
    452435} 
    453436 
    454 /* Called when we have found a new ADM9240. It should set limits, etc. */ 
     437/* Called when we have found a new ADM9240. */ 
    455438static void adm9240_init_client(struct i2c_client *client) 
    456439{ 
     
    723706MODULE_AUTHOR 
    724707    ("Frodo Looijaard <frodol@dds.nl> and Philip Edelbrock <phil@netroedge.com>"); 
     708MODULE_LICENSE("GPL"); 
    725709MODULE_DESCRIPTION("ADM9240 driver"); 
    726710