hwmon: (lm85) Coding-style cleanups

Fix most style issues reported by checkpatch, including:
* Trailing, missing and extra whitespace
* Extra parentheses, curly braces and semi-colons
* Broken indentation
* Lines too long

I verified that the generated code is the same before and after
these changes.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Juerg Haefliger <juergh at gmail.com>
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
This commit is contained in:
Jean Delvare 2008-04-29 14:03:37 +02:00 committed by Mark M. Hoffman
parent 9ebd3d822e
commit 1f44809ac3

View File

@ -151,7 +151,8 @@ static inline u16 FAN_TO_REG(unsigned long val)
return 0xffff;
return SENSORS_LIMIT(5400000 / val, 1, 0xfffe);
}
#define FAN_FROM_REG(val) ((val)==0?-1:(val)==0xffff?0:5400000/(val))
#define FAN_FROM_REG(val) ((val) == 0 ? -1 : (val) == 0xffff ? 0 : \
5400000 / (val))
/* Temperature is reported in .001 degC increments */
#define TEMP_TO_REG(val) \
@ -160,7 +161,7 @@ static inline u16 FAN_TO_REG(unsigned long val)
SCALE(((val) << 4) + (ext), 16, 1000)
#define TEMP_FROM_REG(val) ((val) * 1000)
#define PWM_TO_REG(val) (SENSORS_LIMIT(val,0,255))
#define PWM_TO_REG(val) SENSORS_LIMIT(val, 0, 255)
#define PWM_FROM_REG(val) (val)
@ -184,10 +185,10 @@ static inline u16 FAN_TO_REG(unsigned long val)
/* These are the zone temperature range encodings in .001 degree C */
static int lm85_range_map[] = {
2000, 2500, 3300, 4000, 5000, 6600,
8000, 10000, 13300, 16000, 20000, 26600,
32000, 40000, 53300, 80000
2000, 2500, 3300, 4000, 5000, 6600, 8000, 10000,
13300, 16000, 20000, 26600, 32000, 40000, 53300, 80000
};
static int RANGE_TO_REG(int range)
{
int i;
@ -207,7 +208,7 @@ static int RANGE_TO_REG( int range )
return 0;
}
#define RANGE_FROM_REG(val) (lm85_range_map[(val)&0x0f])
#define RANGE_FROM_REG(val) lm85_range_map[(val) & 0x0f]
/* These are the Acoustic Enhancement, or Temperature smoothing encodings
* NOTE: The enable/disable bit is INCLUDED in these encodings as the
@ -218,17 +219,19 @@ static int RANGE_TO_REG( int range )
static int lm85_freq_map[] = { /* .1 Hz */
100, 150, 230, 300, 380, 470, 620, 940
};
static int FREQ_TO_REG(int freq)
{
int i;
if( freq >= lm85_freq_map[7] ) { return 7 ; }
if (freq >= lm85_freq_map[7])
return 7;
for (i = 0; i < 7; ++i)
if (freq <= lm85_freq_map[i])
break;
return( i & 0x07 );
return i & 0x07;
}
#define FREQ_FROM_REG(val) (lm85_freq_map[(val)&0x07])
#define FREQ_FROM_REG(val) lm85_freq_map[(val) & 0x07]
/* Since we can't use strings, I'm abusing these numbers
* to stand in for the following meanings:
@ -243,7 +246,7 @@ static int FREQ_TO_REG( int freq )
*/
static int lm85_zone_map[] = { 1, 2, 3, -1, 0, 23, 123, -2 };
#define ZONE_FROM_REG(val) (lm85_zone_map[((val)>>5)&0x07])
#define ZONE_FROM_REG(val) lm85_zone_map[((val) >> 5) & 0x07]
static int ZONE_TO_REG(int zone)
{
@ -254,18 +257,18 @@ static int ZONE_TO_REG( int zone )
break;
if (i > 7) /* Not found. */
i = 3; /* Always 100% */
return( (i & 0x07)<<5 );
return (i & 0x07) << 5;
}
#define HYST_TO_REG(val) (SENSORS_LIMIT(((val)+500)/1000,0,15))
#define HYST_TO_REG(val) SENSORS_LIMIT(((val) + 500) / 1000, 0, 15)
#define HYST_FROM_REG(val) ((val) * 1000)
#define OFFSET_TO_REG(val) (SENSORS_LIMIT((val)/25,-127,127))
#define OFFSET_TO_REG(val) SENSORS_LIMIT((val) / 25, -127, 127)
#define OFFSET_FROM_REG(val) ((val) * 25)
#define PPR_MASK(fan) (0x03<<(fan *2))
#define PPR_TO_REG(val,fan) (SENSORS_LIMIT((val)-1,0,3)<<(fan *2))
#define PPR_FROM_REG(val,fan) ((((val)>>(fan * 2))&0x03)+1)
#define PPR_MASK(fan) (0x03 << ((fan) * 2))
#define PPR_TO_REG(val, fan) (SENSORS_LIMIT((val) - 1, 0, 3) << ((fan) * 2))
#define PPR_FROM_REG(val, fan) ((((val) >> ((fan) * 2)) & 0x03) + 1)
/* Chip sampling rates
*
@ -414,7 +417,8 @@ show_fan_offset(4);
/* vid, vrm, alarms */
static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf)
static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct lm85_data *data = lm85_update_device(dev);
int vid;
@ -432,13 +436,15 @@ static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, c
static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL);
static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf)
static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct lm85_data *data = dev_get_drvdata(dev);
return sprintf(buf, "%ld\n", (long) data->vrm);
}
static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct lm85_data *data = dev_get_drvdata(dev);
data->vrm = simple_strtoul(buf, NULL, 10);
@ -447,7 +453,8 @@ static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr,
static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf)
static ssize_t show_alarms_reg(struct device *dev, struct device_attribute
*attr, char *buf)
{
struct lm85_data *data = lm85_update_device(dev);
return sprintf(buf, "%u\n", data->alarms);
@ -581,8 +588,7 @@ static ssize_t show_in(struct device *dev, struct device_attribute *attr,
{
int nr = to_sensor_dev_attr(attr)->index;
struct lm85_data *data = lm85_update_device(dev);
return sprintf( buf, "%d\n", INSEXT_FROM_REG(nr,
data->in[nr],
return sprintf(buf, "%d\n", INSEXT_FROM_REG(nr, data->in[nr],
data->in_ext[nr]));
}
@ -792,8 +798,7 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev,
| data->syncpwm3
| (data->autofan[0].min_off ? 0x20 : 0)
| (data->autofan[1].min_off ? 0x40 : 0)
| (data->autofan[2].min_off ? 0x80 : 0)
);
| (data->autofan[2].min_off ? 0x80 : 0));
mutex_unlock(&data->update_lock);
return count;
}
@ -818,8 +823,7 @@ static ssize_t set_pwm_auto_pwm_freq(struct device *dev,
data->autofan[nr].freq = FREQ_TO_REG(val);
lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
(data->zone[nr].range << 4)
| data->autofan[nr].freq
);
| data->autofan[nr].freq);
mutex_unlock(&data->update_lock);
return count;
}
@ -869,12 +873,10 @@ static ssize_t set_temp_auto_temp_off(struct device *dev,
if (nr == 0 || nr == 1) {
lm85_write_value(client, LM85_REG_AFAN_HYST1,
(data->zone[0].hyst << 4)
| data->zone[1].hyst
);
| data->zone[1].hyst);
} else {
lm85_write_value(client, LM85_REG_AFAN_HYST2,
(data->zone[2].hyst << 4)
);
(data->zone[2].hyst << 4));
}
mutex_unlock(&data->update_lock);
return count;
@ -916,12 +918,10 @@ static ssize_t set_temp_auto_temp_min(struct device *dev,
if (nr == 0 || nr == 1) {
lm85_write_value(client, LM85_REG_AFAN_HYST1,
(data->zone[0].hyst << 4)
| data->zone[1].hyst
);
| data->zone[1].hyst);
} else {
lm85_write_value(client, LM85_REG_AFAN_HYST2,
(data->zone[2].hyst << 4)
);
(data->zone[2].hyst << 4));
}
mutex_unlock(&data->update_lock);
return count;
@ -1140,7 +1140,7 @@ static int lm85_detect(struct i2c_adapter *adapter, int address,
I2C_FUNC_SMBUS_BYTE_DATA)) {
/* We need to be able to do byte I/O */
goto ERROR0;
};
}
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet.
@ -1232,21 +1232,20 @@ static int lm85_detect(struct i2c_adapter *adapter, int address,
}
/* Fill in the chip specific driver values */
if ( kind == any_chip ) {
if (kind == any_chip)
type_name = "lm85";
} else if ( kind == lm85b ) {
else if (kind == lm85b)
type_name = "lm85b";
} else if ( kind == lm85c ) {
else if (kind == lm85c)
type_name = "lm85c";
} else if ( kind == adm1027 ) {
else if (kind == adm1027)
type_name = "adm1027";
} else if ( kind == adt7463 ) {
else if (kind == adt7463)
type_name = "adt7463";
} else if ( kind == emc6d100){
else if (kind == emc6d100)
type_name = "emc6d100";
} else if ( kind == emc6d102 ) {
else if (kind == emc6d102)
type_name = "emc6d102";
}
strlcpy(new_client->name, type_name, I2C_NAME_SIZE);
/* Fill in the remaining client fields */
@ -1363,10 +1362,12 @@ static int lm85_write_value(struct i2c_client *client, u8 reg, int value)
case LM85_REG_FAN_MIN(3):
/* NOTE: ALARM is read only, so not included here */
res = i2c_smbus_write_byte_data(client, reg, value & 0xff);
res |= i2c_smbus_write_byte_data(client, reg+1, (value>>8) & 0xff) ;
res |= i2c_smbus_write_byte_data(client, reg + 1,
(value >> 8) & 0xff);
break;
case ADT7463_REG_TMIN_CTL1: /* Write WORD MSB, LSB */
res = i2c_smbus_write_byte_data(client, reg, (value>>8) & 0xff);
res = i2c_smbus_write_byte_data(client, reg,
(value >> 8) & 0xff);
res |= i2c_smbus_write_byte_data(client, reg + 1, value & 0xff);
break;
default: /* Write BYTE data */
@ -1390,18 +1391,18 @@ static void lm85_init_client(struct i2c_client *client)
if (value & 0x02) {
dev_err(&client->dev, "Client (%d,0x%02x) config is locked.\n",
i2c_adapter_id(client->adapter), client->addr);
};
}
if (!(value & 0x04)) {
dev_err(&client->dev, "Client (%d,0x%02x) is not ready.\n",
i2c_adapter_id(client->adapter), client->addr);
};
}
if (value & 0x10
&& (data->type == adm1027
|| data->type == adt7463)) {
dev_err(&client->dev, "Client (%d,0x%02x) VxI mode is set. "
"Please report this to the lm85 maintainer.\n",
i2c_adapter_id(client->adapter), client->addr);
};
}
/* WE INTENTIONALLY make no changes to the limits,
* offsets, pwms, fans and zones. If they were
@ -1437,7 +1438,7 @@ static struct lm85_data *lm85_update_device(struct device *dev)
* There are 2 additional resolution bits per channel and we
* have room for 4, so we shift them to the left.
*/
if ( (data->type == adm1027) || (data->type == adt7463) ) {
if (data->type == adm1027 || data->type == adt7463) {
int ext1 = lm85_read_value(client,
ADM1027_REG_EXTEND_ADC1);
int ext2 = lm85_read_value(client,
@ -1445,10 +1446,12 @@ static struct lm85_data *lm85_update_device(struct device *dev)
int val = (ext1 << 8) + ext2;
for (i = 0; i <= 4; i++)
data->in_ext[i] = ((val>>(i * 2))&0x03) << 2;
data->in_ext[i] =
((val >> (i * 2)) & 0x03) << 2;
for (i = 0; i <= 2; i++)
data->temp_ext[i] = (val>>((i + 4) * 2))&0x0c;
data->temp_ext[i] =
(val >> ((i + 4) * 2)) & 0x0c;
}
data->vid = lm85_read_value(client, LM85_REG_VID);
@ -1488,12 +1491,12 @@ static struct lm85_data *lm85_update_device(struct device *dev)
} else if (data->type == emc6d100) {
/* Three more voltage sensors */
for (i = 5; i <= 7; ++i) {
data->in[i] =
lm85_read_value(client, EMC6D100_REG_IN(i));
data->in[i] = lm85_read_value(client,
EMC6D100_REG_IN(i));
}
/* More alarm bits */
data->alarms |=
lm85_read_value(client, EMC6D100_REG_ALARM3) << 16;
data->alarms |= lm85_read_value(client,
EMC6D100_REG_ALARM3) << 16;
} else if (data->type == emc6d102) {
/* Have to read LSB bits after the MSB ones because
the reading of the MSB bits has frozen the
@ -1519,7 +1522,7 @@ static struct lm85_data *lm85_update_device(struct device *dev)
}
data->last_reading = jiffies;
}; /* last_reading */
} /* last_reading */
if (!data->valid ||
time_after(jiffies, data->last_config + LM85_CONFIG_INTERVAL)) {
@ -1542,10 +1545,10 @@ static struct lm85_data *lm85_update_device(struct device *dev)
if (data->type == emc6d100) {
for (i = 5; i <= 7; ++i) {
data->in_min[i] =
lm85_read_value(client, EMC6D100_REG_IN_MIN(i));
data->in_max[i] =
lm85_read_value(client, EMC6D100_REG_IN_MAX(i));
data->in_min[i] = lm85_read_value(client,
EMC6D100_REG_IN_MIN(i));
data->in_max[i] = lm85_read_value(client,
EMC6D100_REG_IN_MAX(i));
}
}
@ -1593,12 +1596,12 @@ static struct lm85_data *lm85_update_device(struct device *dev)
i = lm85_read_value(client, LM85_REG_AFAN_HYST2);
data->zone[2].hyst = (i >> 4) & 0x0f;
if ( (data->type == lm85b) || (data->type == lm85c) ) {
if (data->type == lm85b || data->type == lm85c) {
data->tach_mode = lm85_read_value(client,
LM85_REG_TACH_MODE);
data->spinup_ctl = lm85_read_value(client,
LM85_REG_SPINUP_CTL);
} else if ( (data->type == adt7463) || (data->type == adm1027) ) {
} else if (data->type == adt7463 || data->type == adm1027) {
if (data->type == adt7463) {
for (i = 0; i <= 2; ++i) {
data->oppoint[i] = lm85_read_value(client,
@ -1620,7 +1623,7 @@ static struct lm85_data *lm85_update_device(struct device *dev)
}
data->last_config = jiffies;
}; /* last_config */
} /* last_config */
data->valid = 1;
@ -1645,7 +1648,9 @@ static void __exit sm_lm85_exit(void)
* post 2.7.0 CVS changes.
*/
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Philip Pokorny <ppokorny@penguincomputing.com>, Margit Schubert-While <margitsw@t-online.de>, Justin Thiessen <jthiessen@penguincomputing.com");
MODULE_AUTHOR("Philip Pokorny <ppokorny@penguincomputing.com>, "
"Margit Schubert-While <margitsw@t-online.de>, "
"Justin Thiessen <jthiessen@penguincomputing.com");
MODULE_DESCRIPTION("LM85-B, LM85-C driver");
module_init(sm_lm85_init);