Changeset 64
- Timestamp:
- 12/10/98 17:20:03 (10 years ago)
- Files:
-
- lm-sensors/trunk/TODO (modified) (1 diff)
- lm-sensors/trunk/kernel/chips/gl518sm.c (modified) (2 diffs)
- lm-sensors/trunk/kernel/chips/lm75.c (modified) (3 diffs)
- lm-sensors/trunk/src/gl518sm.c (modified) (2 diffs)
- lm-sensors/trunk/src/lm75.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
lm-sensors/trunk/TODO
r55 r64 2 2 3 3 * Check whether the FAN count divisors in the lm78 module are correct 4 (probably not!) 4 (probably not!); correct gl518sm changed-fan_div_but_did_not_update_fans 5 5 * Wouldn't it be better to display all natural voltages for the LM78 chip, 6 6 and do *all* conversions through a user program? lm-sensors/trunk/kernel/chips/gl518sm.c
r63 r64 133 133 static void gl518_inc_use (struct i2c_client *client); 134 134 static void gl518_dec_use (struct i2c_client *client); 135 static u16 swap_bytes(u16 val); 135 136 static int gl518_read_value(struct i2c_client *client, u8 reg); 136 137 static int gl518_write_value(struct i2c_client *client, u8 reg, u16 value); … … 363 364 } 364 365 365 /* Registers 0x07 to 0x0c are word-sized, others are byte-sized */ 366 u16 swap_bytes(u16 val) 367 { 368 return (val >> 8) | (val << 8); 369 } 370 371 /* Registers 0x07 to 0x0c are word-sized, others are byte-sized 372 GL518 uses a high-byte first convention, which is exactly opposite to 373 the usual practice. */ 366 374 int gl518_read_value(struct i2c_client *client, u8 reg) 367 375 { 368 376 if ((reg >= 0x07) && (reg <= 0x0c)) 369 return s mbus_read_word_data(client->adapter,client->addr,reg);377 return swap_bytes(smbus_read_word_data(client->adapter,client->addr,reg)); 370 378 else 371 379 return smbus_read_byte_data(client->adapter,client->addr,reg); 372 380 } 373 381 382 /* Registers 0x07 to 0x0c are word-sized, others are byte-sized 383 GL518 uses a high-byte first convention, which is exactly opposite to 384 the usual practice. */ 374 385 int gl518_write_value(struct i2c_client *client, u8 reg, u16 value) 375 386 { 376 387 if ((reg >= 0x07) && (reg <= 0x0c)) 377 return smbus_write_word_data(client->adapter,client->addr,reg,value); 388 return smbus_write_word_data(client->adapter,client->addr,reg, 389 swap_bytes(value)); 378 390 else 379 391 return smbus_write_byte_data(client->adapter,client->addr,reg,value); lm-sensors/trunk/kernel/chips/lm75.c
r53 r64 243 243 244 244 /* All registers are word-sized, except for the configuration register. 245 For some reason, we must swap the low and high byte, but only on246 reading words?!?*/245 LM75 uses a high-byte first convention, which is exactly opposite to 246 the usual practice. */ 247 247 int lm75_read_value(struct i2c_client *client, u8 reg) 248 248 { … … 253 253 } 254 254 255 /* No swapping needed here! */ 255 /* All registers are word-sized, except for the configuration register. 256 LM75 uses a high-byte first convention, which is exactly opposite to 257 the usual practice. */ 256 258 int lm75_write_value(struct i2c_client *client, u8 reg, u16 value) 257 259 { … … 259 261 return smbus_write_byte_data(client->adapter,client->addr,reg,value); 260 262 else 261 return smbus_write_word_data(client->adapter,client->addr,reg,value); 263 return smbus_write_word_data(client->adapter,client->addr,reg, 264 swap_bytes(value)); 262 265 } 263 266 lm-sensors/trunk/src/gl518sm.c
r63 r64 133 133 static void gl518_inc_use (struct i2c_client *client); 134 134 static void gl518_dec_use (struct i2c_client *client); 135 static u16 swap_bytes(u16 val); 135 136 static int gl518_read_value(struct i2c_client *client, u8 reg); 136 137 static int gl518_write_value(struct i2c_client *client, u8 reg, u16 value); … … 363 364 } 364 365 365 /* Registers 0x07 to 0x0c are word-sized, others are byte-sized */ 366 u16 swap_bytes(u16 val) 367 { 368 return (val >> 8) | (val << 8); 369 } 370 371 /* Registers 0x07 to 0x0c are word-sized, others are byte-sized 372 GL518 uses a high-byte first convention, which is exactly opposite to 373 the usual practice. */ 366 374 int gl518_read_value(struct i2c_client *client, u8 reg) 367 375 { 368 376 if ((reg >= 0x07) && (reg <= 0x0c)) 369 return s mbus_read_word_data(client->adapter,client->addr,reg);377 return swap_bytes(smbus_read_word_data(client->adapter,client->addr,reg)); 370 378 else 371 379 return smbus_read_byte_data(client->adapter,client->addr,reg); 372 380 } 373 381 382 /* Registers 0x07 to 0x0c are word-sized, others are byte-sized 383 GL518 uses a high-byte first convention, which is exactly opposite to 384 the usual practice. */ 374 385 int gl518_write_value(struct i2c_client *client, u8 reg, u16 value) 375 386 { 376 387 if ((reg >= 0x07) && (reg <= 0x0c)) 377 return smbus_write_word_data(client->adapter,client->addr,reg,value); 388 return smbus_write_word_data(client->adapter,client->addr,reg, 389 swap_bytes(value)); 378 390 else 379 391 return smbus_write_byte_data(client->adapter,client->addr,reg,value); lm-sensors/trunk/src/lm75.c
r53 r64 243 243 244 244 /* All registers are word-sized, except for the configuration register. 245 For some reason, we must swap the low and high byte, but only on246 reading words?!?*/245 LM75 uses a high-byte first convention, which is exactly opposite to 246 the usual practice. */ 247 247 int lm75_read_value(struct i2c_client *client, u8 reg) 248 248 { … … 253 253 } 254 254 255 /* No swapping needed here! */ 255 /* All registers are word-sized, except for the configuration register. 256 LM75 uses a high-byte first convention, which is exactly opposite to 257 the usual practice. */ 256 258 int lm75_write_value(struct i2c_client *client, u8 reg, u16 value) 257 259 { … … 259 261 return smbus_write_byte_data(client->adapter,client->addr,reg,value); 260 262 else 261 return smbus_write_word_data(client->adapter,client->addr,reg,value); 263 return smbus_write_word_data(client->adapter,client->addr,reg, 264 swap_bytes(value)); 262 265 } 263 266
