hwmon: (w83781d) Fix checkpatch issues

Fixed:
ERROR: code indent should use tabs where possible
ERROR: do not use assignment in if condition
ERROR: "foo* bar" should be "foo *bar"
ERROR: space prohibited after that open parenthesis '('
ERROR: space required after that ',' (ctx:VxV)
ERROR: spaces required around that '==' (ctx:VxV)
WARNING: line over 80 characters
WARNING: simple_strtol is obsolete, use kstrtol instead
WARNING: simple_strtoul is obsolete, use kstrtoul instead
WARNING: space prohibited between function name and open parenthesis '('

Not fixed (false positive):
ERROR: Macros with multiple statements should be enclosed in a do - while loop
ERROR: Macros with complex values should be enclosed in parenthesis

Not all fixed (code complexity):
ERROR: do not use assignment in if condition

Acked-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
Guenter Roeck 2012-01-15 09:19:16 -08:00 committed by Guenter Roeck
parent 2b22de5117
commit c531eb3f22

View file

@ -273,13 +273,14 @@ static ssize_t store_in_##reg (struct device *dev, struct device_attribute \
struct sensor_device_attribute *attr = to_sensor_dev_attr(da); \ struct sensor_device_attribute *attr = to_sensor_dev_attr(da); \
struct w83781d_data *data = dev_get_drvdata(dev); \ struct w83781d_data *data = dev_get_drvdata(dev); \
int nr = attr->index; \ int nr = attr->index; \
u32 val; \ unsigned long val; \
\ int err = kstrtoul(buf, 10, &val); \
val = simple_strtoul(buf, NULL, 10); \ if (err) \
\ return err; \
mutex_lock(&data->update_lock); \ mutex_lock(&data->update_lock); \
data->in_##reg[nr] = IN_TO_REG(val); \ data->in_##reg[nr] = IN_TO_REG(val); \
w83781d_write_value(data, W83781D_REG_IN_##REG(nr), data->in_##reg[nr]); \ w83781d_write_value(data, W83781D_REG_IN_##REG(nr), \
data->in_##reg[nr]); \
\ \
mutex_unlock(&data->update_lock); \ mutex_unlock(&data->update_lock); \
return count; \ return count; \
@ -325,9 +326,12 @@ store_fan_min(struct device *dev, struct device_attribute *da,
struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct w83781d_data *data = dev_get_drvdata(dev); struct w83781d_data *data = dev_get_drvdata(dev);
int nr = attr->index; int nr = attr->index;
u32 val; unsigned long val;
int err;
val = simple_strtoul(buf, NULL, 10); err = kstrtoul(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->fan_min[nr] = data->fan_min[nr] =
@ -375,9 +379,9 @@ static ssize_t store_temp_##reg (struct device *dev, \
struct w83781d_data *data = dev_get_drvdata(dev); \ struct w83781d_data *data = dev_get_drvdata(dev); \
int nr = attr->index; \ int nr = attr->index; \
long val; \ long val; \
\ int err = kstrtol(buf, 10, &val); \
val = simple_strtol(buf, NULL, 10); \ if (err) \
\ return err; \
mutex_lock(&data->update_lock); \ mutex_lock(&data->update_lock); \
\ \
if (nr >= 2) { /* TEMP2 and TEMP3 */ \ if (nr >= 2) { /* TEMP2 and TEMP3 */ \
@ -425,13 +429,17 @@ show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf)
} }
static ssize_t static ssize_t
store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) store_vrm_reg(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{ {
struct w83781d_data *data = dev_get_drvdata(dev); struct w83781d_data *data = dev_get_drvdata(dev);
u32 val; unsigned long val;
int err;
val = simple_strtoul(buf, NULL, 10); err = kstrtoul(buf, 10, &val);
data->vrm = val; if (err)
return err;
data->vrm = SENSORS_LIMIT(val, 0, 255);
return count; return count;
} }
@ -480,7 +488,8 @@ static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4);
static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5); static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5);
static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_temp3_alarm, NULL, 0); static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_temp3_alarm, NULL, 0);
static ssize_t show_beep_mask (struct device *dev, struct device_attribute *attr, char *buf) static ssize_t show_beep_mask(struct device *dev,
struct device_attribute *attr, char *buf)
{ {
struct w83781d_data *data = w83781d_update_device(dev); struct w83781d_data *data = w83781d_update_device(dev);
return sprintf(buf, "%ld\n", return sprintf(buf, "%ld\n",
@ -492,9 +501,12 @@ store_beep_mask(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct w83781d_data *data = dev_get_drvdata(dev); struct w83781d_data *data = dev_get_drvdata(dev);
u32 val; unsigned long val;
int err;
val = simple_strtoul(buf, NULL, 10); err = kstrtoul(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->beep_mask &= 0x8000; /* preserve beep enable */ data->beep_mask &= 0x8000; /* preserve beep enable */
@ -529,10 +541,14 @@ store_beep(struct device *dev, struct device_attribute *attr,
{ {
struct w83781d_data *data = dev_get_drvdata(dev); struct w83781d_data *data = dev_get_drvdata(dev);
int bitnr = to_sensor_dev_attr(attr)->index; int bitnr = to_sensor_dev_attr(attr)->index;
unsigned long bit;
u8 reg; u8 reg;
unsigned long bit;
int err;
err = kstrtoul(buf, 10, &bit);
if (err)
return err;
bit = simple_strtoul(buf, NULL, 10);
if (bit & ~1) if (bit & ~1)
return -EINVAL; return -EINVAL;
@ -633,7 +649,12 @@ store_fan_div(struct device *dev, struct device_attribute *da,
unsigned long min; unsigned long min;
int nr = attr->index; int nr = attr->index;
u8 reg; u8 reg;
unsigned long val = simple_strtoul(buf, NULL, 10); unsigned long val;
int err;
err = kstrtoul(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
@ -643,10 +664,12 @@ store_fan_div(struct device *dev, struct device_attribute *da,
data->fan_div[nr] = DIV_TO_REG(val, data->type); data->fan_div[nr] = DIV_TO_REG(val, data->type);
reg = (w83781d_read_value(data, nr==2 ? W83781D_REG_PIN : W83781D_REG_VID_FANDIV) reg = (w83781d_read_value(data, nr == 2 ?
W83781D_REG_PIN : W83781D_REG_VID_FANDIV)
& (nr == 0 ? 0xcf : 0x3f)) & (nr == 0 ? 0xcf : 0x3f))
| ((data->fan_div[nr] & 0x03) << (nr == 0 ? 4 : 6)); | ((data->fan_div[nr] & 0x03) << (nr == 0 ? 4 : 6));
w83781d_write_value(data, nr==2 ? W83781D_REG_PIN : W83781D_REG_VID_FANDIV, reg); w83781d_write_value(data, nr == 2 ?
W83781D_REG_PIN : W83781D_REG_VID_FANDIV, reg);
/* w83781d and as99127f don't have extended divisor bits */ /* w83781d and as99127f don't have extended divisor bits */
if (data->type != w83781d && data->type != as99127f) { if (data->type != w83781d && data->type != as99127f) {
@ -693,9 +716,12 @@ store_pwm(struct device *dev, struct device_attribute *da, const char *buf,
struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct w83781d_data *data = dev_get_drvdata(dev); struct w83781d_data *data = dev_get_drvdata(dev);
int nr = attr->index; int nr = attr->index;
u32 val; unsigned long val;
int err;
val = simple_strtoul(buf, NULL, 10); err = kstrtoul(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->pwm[nr] = SENSORS_LIMIT(val, 0, 255); data->pwm[nr] = SENSORS_LIMIT(val, 0, 255);
@ -709,9 +735,13 @@ store_pwm2_enable(struct device *dev, struct device_attribute *da,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct w83781d_data *data = dev_get_drvdata(dev); struct w83781d_data *data = dev_get_drvdata(dev);
u32 val, reg; unsigned long val;
u32 reg;
int err;
val = simple_strtoul(buf, NULL, 10); err = kstrtoul(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
@ -761,9 +791,13 @@ store_sensor(struct device *dev, struct device_attribute *da,
struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct w83781d_data *data = dev_get_drvdata(dev); struct w83781d_data *data = dev_get_drvdata(dev);
int nr = attr->index; int nr = attr->index;
u32 val, tmp; unsigned long val;
u32 tmp;
int err;
val = simple_strtoul(buf, NULL, 10); err = kstrtoul(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
@ -959,7 +993,8 @@ w83781d_create_files(struct device *dev, int kind, int is_isa)
{ {
int err; int err;
if ((err = sysfs_create_group(&dev->kobj, &w83781d_group))) err = sysfs_create_group(&dev->kobj, &w83781d_group);
if (err)
return err; return err;
if (kind != w83783s) { if (kind != w83783s) {
@ -1043,8 +1078,9 @@ w83781d_create_files(struct device *dev, int kind, int is_isa)
&sensor_dev_attr_temp2_type.dev_attr))) &sensor_dev_attr_temp2_type.dev_attr)))
return err; return err;
if (kind != w83783s) { if (kind != w83783s) {
if ((err = device_create_file(dev, err = device_create_file(dev,
&sensor_dev_attr_temp3_type.dev_attr))) &sensor_dev_attr_temp3_type.dev_attr);
if (err)
return err; return err;
} }
} }
@ -1331,9 +1367,11 @@ w83781d_init_device(struct device *dev)
This saves FAN 1/2/3 input/output values set by BIOS. */ This saves FAN 1/2/3 input/output values set by BIOS. */
w83781d_write_value(data, W83781D_REG_BEEP_CONFIG, i | 0x80); w83781d_write_value(data, W83781D_REG_BEEP_CONFIG, i | 0x80);
w83781d_write_value(data, W83781D_REG_PWMCLK12, p); w83781d_write_value(data, W83781D_REG_PWMCLK12, p);
/* Disable master beep-enable (reset turns it on). /*
Individual beep_mask should be reset to off but for some reason * Disable master beep-enable (reset turns it on).
disabling this bit helps some people not get beeped */ * Individual beep_mask should be reset to off but for some
* reason disabling this bit helps some people not get beeped
*/
w83781d_write_value(data, W83781D_REG_BEEP_INTS2, 0); w83781d_write_value(data, W83781D_REG_BEEP_INTS2, 0);
} }