lm75: fix Codingstyle issues.
Signed-off-by: Heiko Schocher <hs@denx.de>
This commit is contained in:
parent
f2202450c7
commit
12f1678127
|
@ -60,20 +60,14 @@ int dtt_read(int sensor, int reg)
|
||||||
dtt_write(sensor, DTT_CONFIG, 0x64);
|
dtt_write(sensor, DTT_CONFIG, 0x64);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/* Validate 'reg' param */
|
||||||
* Validate 'reg' param
|
|
||||||
*/
|
|
||||||
if((reg < 0) || (reg > 3))
|
if((reg < 0) || (reg > 3))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/*
|
/* Calculate sensor address and register. */
|
||||||
* Calculate sensor address and register.
|
sensor = DTT_I2C_DEV_CODE + (sensor & 0x07);
|
||||||
*/
|
|
||||||
sensor = DTT_I2C_DEV_CODE + (sensor & 0x07); /* calculate address of lm75 */
|
|
||||||
|
|
||||||
/*
|
/* Prepare to handle 2 byte result. */
|
||||||
* Prepare to handle 2 byte result.
|
|
||||||
*/
|
|
||||||
if ((reg == DTT_READ_TEMP) ||
|
if ((reg == DTT_READ_TEMP) ||
|
||||||
(reg == DTT_TEMP_HYST) ||
|
(reg == DTT_TEMP_HYST) ||
|
||||||
(reg == DTT_TEMP_SET))
|
(reg == DTT_TEMP_SET))
|
||||||
|
@ -81,19 +75,14 @@ int dtt_read(int sensor, int reg)
|
||||||
else
|
else
|
||||||
dlen = 1;
|
dlen = 1;
|
||||||
|
|
||||||
/*
|
/* Now try to read the register. */
|
||||||
* Now try to read the register.
|
|
||||||
*/
|
|
||||||
if (i2c_read(sensor, reg, 1, data, dlen) != 0)
|
if (i2c_read(sensor, reg, 1, data, dlen) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/*
|
/* Handle 2 byte result. */
|
||||||
* Handle 2 byte result.
|
|
||||||
*/
|
|
||||||
if (dlen == 2)
|
if (dlen == 2)
|
||||||
return ((int)((short)data[1] + (((short)data[0]) << 8)));
|
return ((int)((short)data[1] + (((short)data[0]) << 8)));
|
||||||
|
|
||||||
|
|
||||||
return (int)data[0];
|
return (int)data[0];
|
||||||
} /* dtt_read() */
|
} /* dtt_read() */
|
||||||
|
|
||||||
|
@ -103,20 +92,14 @@ int dtt_write(int sensor, int reg, int val)
|
||||||
int dlen;
|
int dlen;
|
||||||
uchar data[2];
|
uchar data[2];
|
||||||
|
|
||||||
/*
|
/* Validate 'reg' param */
|
||||||
* Validate 'reg' param
|
|
||||||
*/
|
|
||||||
if ((reg < 0) || (reg > 3))
|
if ((reg < 0) || (reg > 3))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/*
|
/* Calculate sensor address and register. */
|
||||||
* Calculate sensor address and register.
|
sensor = DTT_I2C_DEV_CODE + (sensor & 0x07);
|
||||||
*/
|
|
||||||
sensor = DTT_I2C_DEV_CODE + (sensor & 0x07); /* calculate address of lm75 */
|
|
||||||
|
|
||||||
/*
|
/* Handle 2 byte values. */
|
||||||
* Handle 2 byte values.
|
|
||||||
*/
|
|
||||||
if ((reg == DTT_READ_TEMP) ||
|
if ((reg == DTT_READ_TEMP) ||
|
||||||
(reg == DTT_TEMP_HYST) ||
|
(reg == DTT_TEMP_HYST) ||
|
||||||
(reg == DTT_TEMP_SET)) {
|
(reg == DTT_TEMP_SET)) {
|
||||||
|
@ -128,9 +111,7 @@ int dtt_write(int sensor, int reg, int val)
|
||||||
data[0] = (char)(val & 0xff);
|
data[0] = (char)(val & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Write value to register. */
|
||||||
* Write value to register.
|
|
||||||
*/
|
|
||||||
if (i2c_write(sensor, reg, 1, data, dlen) != 0)
|
if (i2c_write(sensor, reg, 1, data, dlen) != 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -142,23 +123,17 @@ static int _dtt_init(int sensor)
|
||||||
{
|
{
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
/*
|
/* Setup TSET ( trip point ) register */
|
||||||
* Setup TSET ( trip point ) register
|
|
||||||
*/
|
|
||||||
val = ((CFG_DTT_MAX_TEMP * 2) << 7) & 0xff80; /* trip */
|
val = ((CFG_DTT_MAX_TEMP * 2) << 7) & 0xff80; /* trip */
|
||||||
if (dtt_write(sensor, DTT_TEMP_SET, val) != 0)
|
if (dtt_write(sensor, DTT_TEMP_SET, val) != 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/*
|
/* Setup THYST ( untrip point ) register - Hysteresis */
|
||||||
* Setup THYST ( untrip point ) register - Hysteresis
|
|
||||||
*/
|
|
||||||
val = (((CFG_DTT_MAX_TEMP - CFG_DTT_HYSTERESIS) * 2) << 7) & 0xff80;
|
val = (((CFG_DTT_MAX_TEMP - CFG_DTT_HYSTERESIS) * 2) << 7) & 0xff80;
|
||||||
if (dtt_write(sensor, DTT_TEMP_HYST, val) != 0)
|
if (dtt_write(sensor, DTT_TEMP_HYST, val) != 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/*
|
/* Setup configuraton register */
|
||||||
* Setup configuraton register
|
|
||||||
*/
|
|
||||||
#ifdef CONFIG_DTT_AD7414
|
#ifdef CONFIG_DTT_AD7414
|
||||||
/* config = alert active low and disabled */
|
/* config = alert active low and disabled */
|
||||||
val = 0x60;
|
val = 0x60;
|
||||||
|
@ -178,6 +153,7 @@ int dtt_init (void)
|
||||||
int i;
|
int i;
|
||||||
unsigned char sensors[] = CONFIG_DTT_SENSORS;
|
unsigned char sensors[] = CONFIG_DTT_SENSORS;
|
||||||
const char *const header = "DTT: ";
|
const char *const header = "DTT: ";
|
||||||
|
int old_bus;
|
||||||
|
|
||||||
for (i = 0; i < sizeof(sensors); i++) {
|
for (i = 0; i < sizeof(sensors); i++) {
|
||||||
if (_dtt_init(sensors[i]) != 0)
|
if (_dtt_init(sensors[i]) != 0)
|
||||||
|
|
Loading…
Reference in New Issue