Changeset 3289
- Timestamp:
- 04/22/06 11:06:21 (7 years ago)
- Files:
-
- 1 modified
-
lm-sensors/trunk/prog/detect/sensors-detect (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/prog/detect/sensors-detect
r3287 r3289 2313 2313 # This should really go into a separate module/package. 2314 2314 2315 # These are copied from <linux/i2c .h> and <linux/smbus.h>2315 # These are copied from <linux/i2c-dev.h> 2316 2316 2317 2317 use constant IOCTL_I2C_SLAVE => 0x0703; 2318 use constant IOCTL_I2C_TENBIT => 0x0704;2319 2318 use constant IOCTL_I2C_SMBUS => 0x0720; 2320 2321 # These are copied from <linux/smbus.h>2322 2319 2323 2320 use constant SMBUS_READ => 1; … … 2328 2325 use constant SMBUS_BYTE_DATA => 2; 2329 2326 use constant SMBUS_WORD_DATA => 3; 2330 use constant SMBUS_PROC_CALL => 4;2331 use constant SMBUS_BLOCK_DATA => 5;2332 2327 2333 2328 # Select the device to communicate with through its address. … … 2389 2384 2390 2385 # $_[0]: Reference to an opened filehandle 2391 # $_[1]: Byte to write2392 # Returns: -1 on failure, 0 on success.2393 sub i2c_smbus_write_byte2394 {2395 my ($file,$command) = @_;2396 my @data = ($command);2397 i2c_smbus_access $file, SMBUS_WRITE, 0, SMBUS_BYTE, \@data2398 or return -1;2399 return 0;2400 }2401 2402 # $_[0]: Reference to an opened filehandle2403 2386 # $_[1]: Command byte (usually register number) 2404 2387 # Returns: -1 on failure, the read byte on success. … … 2412 2395 } 2413 2396 2414 # $_[0]: Reference to an opened filehandle2415 # $_[1]: Command byte (usually register number)2416 # $_[2]: Byte to write2417 # Returns: -1 on failure, 0 on success.2418 sub i2c_smbus_write_byte_data2419 {2420 my ($file,$command,$value) = @_;2421 my @data = ($value);2422 i2c_smbus_access $file, SMBUS_WRITE, $command, SMBUS_BYTE_DATA, \@data2423 or return -1;2424 return 0;2425 }2426 2427 2397 # $_[0]: Reference to an opened filehandle 2428 2398 # $_[1]: Command byte (usually register number) … … 2437 2407 or return -1; 2438 2408 return $data[0] + 256 * $data[1]; 2439 }2440 2441 # $_[0]: Reference to an opened filehandle2442 # $_[1]: Command byte (usually register number)2443 # $_[2]: Byte to write2444 # Returns: -1 on failure, 0 on success.2445 # Note: some devices use the wrong endiannes; use swap_bytes to correct for2446 # this.2447 sub i2c_smbus_write_word_data2448 {2449 my ($file,$command,$value) = @_;2450 my @data = ($value & 0xff, $value >> 8);2451 i2c_smbus_access $file, SMBUS_WRITE, $command, SMBUS_WORD_DATA, \@data2452 or return -1;2453 return 0;2454 2409 } 2455 2410
