lm75: fix Codingstyle issues.

Signed-off-by: Heiko Schocher <hs@denx.de>
This commit is contained in:
Heiko Schocher 2008-10-15 09:37:04 +02:00 committed by Wolfgang Denk
parent f2202450c7
commit 12f1678127

View File

@ -60,20 +60,14 @@ int dtt_read(int sensor, int reg)
dtt_write(sensor, DTT_CONFIG, 0x64);
#endif
/*
* Validate 'reg' param
*/
/* Validate 'reg' param */
if((reg < 0) || (reg > 3))
return -1;
/*
* Calculate sensor address and register.
*/
sensor = DTT_I2C_DEV_CODE + (sensor & 0x07); /* calculate address of lm75 */
/* Calculate sensor address and register. */
sensor = DTT_I2C_DEV_CODE + (sensor & 0x07);
/*
* Prepare to handle 2 byte result.
*/
/* Prepare to handle 2 byte result. */
if ((reg == DTT_READ_TEMP) ||
(reg == DTT_TEMP_HYST) ||
(reg == DTT_TEMP_SET))
@ -81,19 +75,14 @@ int dtt_read(int sensor, int reg)
else
dlen = 1;
/*
* Now try to read the register.
*/
/* Now try to read the register. */
if (i2c_read(sensor, reg, 1, data, dlen) != 0)
return -1;
/*
* Handle 2 byte result.
*/
/* Handle 2 byte result. */
if (dlen == 2)
return ((int)((short)data[1] + (((short)data[0]) << 8)));
return (int)data[0];
} /* dtt_read() */
@ -103,20 +92,14 @@ int dtt_write(int sensor, int reg, int val)
int dlen;
uchar data[2];
/*
* Validate 'reg' param
*/
/* Validate 'reg' param */
if ((reg < 0) || (reg > 3))
return 1;
/*
* Calculate sensor address and register.
*/
sensor = DTT_I2C_DEV_CODE + (sensor & 0x07); /* calculate address of lm75 */
/* Calculate sensor address and register. */
sensor = DTT_I2C_DEV_CODE + (sensor & 0x07);
/*
* Handle 2 byte values.
*/
/* Handle 2 byte values. */
if ((reg == DTT_READ_TEMP) ||
(reg == DTT_TEMP_HYST) ||
(reg == DTT_TEMP_SET)) {
@ -128,9 +111,7 @@ int dtt_write(int sensor, int reg, int val)
data[0] = (char)(val & 0xff);
}
/*
* Write value to register.
*/
/* Write value to register. */
if (i2c_write(sensor, reg, 1, data, dlen) != 0)
return 1;
@ -142,23 +123,17 @@ static int _dtt_init(int sensor)
{
int val;
/*
* Setup TSET ( trip point ) register
*/
/* Setup TSET ( trip point ) register */
val = ((CFG_DTT_MAX_TEMP * 2) << 7) & 0xff80; /* trip */
if (dtt_write(sensor, DTT_TEMP_SET, val) != 0)
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;
if (dtt_write(sensor, DTT_TEMP_HYST, val) != 0)
return 1;
/*
* Setup configuraton register
*/
/* Setup configuraton register */
#ifdef CONFIG_DTT_AD7414
/* config = alert active low and disabled */
val = 0x60;
@ -178,6 +153,7 @@ int dtt_init (void)
int i;
unsigned char sensors[] = CONFIG_DTT_SENSORS;
const char *const header = "DTT: ";
int old_bus;
for (i = 0; i < sizeof(sensors); i++) {
if (_dtt_init(sensors[i]) != 0)