Commit c387e4eb authored by Guenter Roeck's avatar Guenter Roeck Committed by Guenter Roeck

hwmon: (adm9240) Fix checkpatch issues

Fixed:
ERROR: do not use assignment in if condition
ERROR: that open brace { should be on the previous line
WARNING: please, no space before tabs
WARNING: simple_strtol is obsolete, use kstrtol instead
WARNING: simple_strtoul is obsolete, use kstrtoul instead

Modify multi-line comments to follow Documentation/CodingStyle.

Not fixed (false positive):
ERROR: Macros with multiple statements should be enclosed in a do - while loop
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 86aa3e22
/* /*
* adm9240.c Part of lm_sensors, Linux kernel modules for hardware * adm9240.c Part of lm_sensors, Linux kernel modules for hardware
* monitoring * monitoring
* *
* Copyright (C) 1999 Frodo Looijaard <frodol@dds.nl> * Copyright (C) 1999 Frodo Looijaard <frodol@dds.nl>
* Philip Edelbrock <phil@netroedge.com> * Philip Edelbrock <phil@netroedge.com>
* Copyright (C) 2003 Michiel Rook <michiel@grendelproject.nl> * Copyright (C) 2003 Michiel Rook <michiel@grendelproject.nl>
* Copyright (C) 2005 Grant Coady <gcoady.lk@gmail.com> with valuable * Copyright (C) 2005 Grant Coady <gcoady.lk@gmail.com> with valuable
* guidance from Jean Delvare * guidance from Jean Delvare
* *
* Driver supports Analog Devices ADM9240 * Driver supports Analog Devices ADM9240
* Dallas Semiconductor DS1780 * Dallas Semiconductor DS1780
...@@ -204,7 +204,12 @@ static ssize_t set_max(struct device *dev, struct device_attribute *devattr, ...@@ -204,7 +204,12 @@ static ssize_t set_max(struct device *dev, struct device_attribute *devattr,
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct adm9240_data *data = i2c_get_clientdata(client); struct adm9240_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10); long val;
int err;
err = kstrtol(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->temp_max[attr->index] = TEMP_TO_REG(val); data->temp_max[attr->index] = TEMP_TO_REG(val);
...@@ -255,7 +260,12 @@ static ssize_t set_in_min(struct device *dev, ...@@ -255,7 +260,12 @@ static ssize_t set_in_min(struct device *dev,
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct adm9240_data *data = i2c_get_clientdata(client); struct adm9240_data *data = i2c_get_clientdata(client);
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);
data->in_min[attr->index] = IN_TO_REG(val, attr->index); data->in_min[attr->index] = IN_TO_REG(val, attr->index);
...@@ -272,7 +282,12 @@ static ssize_t set_in_max(struct device *dev, ...@@ -272,7 +282,12 @@ static ssize_t set_in_max(struct device *dev,
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct adm9240_data *data = i2c_get_clientdata(client); struct adm9240_data *data = i2c_get_clientdata(client);
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);
data->in_max[attr->index] = IN_TO_REG(val, attr->index); data->in_max[attr->index] = IN_TO_REG(val, attr->index);
...@@ -283,7 +298,7 @@ static ssize_t set_in_max(struct device *dev, ...@@ -283,7 +298,7 @@ static ssize_t set_in_max(struct device *dev,
} }
#define vin(nr) \ #define vin(nr) \
static SENSOR_DEVICE_ATTR(in##nr##_input, S_IRUGO, \ static SENSOR_DEVICE_ATTR(in##nr##_input, S_IRUGO, \
show_in, NULL, nr); \ show_in, NULL, nr); \
static SENSOR_DEVICE_ATTR(in##nr##_min, S_IRUGO | S_IWUSR, \ static SENSOR_DEVICE_ATTR(in##nr##_min, S_IRUGO | S_IWUSR, \
show_in_min, set_in_min, nr); \ show_in_min, set_in_min, nr); \
...@@ -357,9 +372,14 @@ static ssize_t set_fan_min(struct device *dev, ...@@ -357,9 +372,14 @@ static ssize_t set_fan_min(struct device *dev,
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct adm9240_data *data = i2c_get_clientdata(client); struct adm9240_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
int nr = attr->index; int nr = attr->index;
u8 new_div; u8 new_div;
unsigned long val;
int err;
err = kstrtoul(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
...@@ -465,7 +485,12 @@ static ssize_t set_aout(struct device *dev, ...@@ -465,7 +485,12 @@ static ssize_t set_aout(struct device *dev,
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct adm9240_data *data = i2c_get_clientdata(client); struct adm9240_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtol(buf, NULL, 10); long val;
int err;
err = kstrtol(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->aout = AOUT_TO_REG(val); data->aout = AOUT_TO_REG(val);
...@@ -481,7 +506,12 @@ static ssize_t chassis_clear_legacy(struct device *dev, ...@@ -481,7 +506,12 @@ static ssize_t chassis_clear_legacy(struct device *dev,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
unsigned long val = simple_strtol(buf, NULL, 10); long val;
int err;
err = kstrtol(buf, 10, &val);
if (err)
return err;
dev_warn(dev, "Attribute chassis_clear is deprecated, " dev_warn(dev, "Attribute chassis_clear is deprecated, "
"use intrusion0_alarm instead\n"); "use intrusion0_alarm instead\n");
...@@ -632,7 +662,8 @@ static int adm9240_probe(struct i2c_client *new_client, ...@@ -632,7 +662,8 @@ static int adm9240_probe(struct i2c_client *new_client,
adm9240_init_client(new_client); adm9240_init_client(new_client);
/* populate sysfs filesystem */ /* populate sysfs filesystem */
if ((err = sysfs_create_group(&new_client->dev.kobj, &adm9240_group))) err = sysfs_create_group(&new_client->dev.kobj, &adm9240_group);
if (err)
goto exit_free; goto exit_free;
data->hwmon_dev = hwmon_device_register(&new_client->dev); data->hwmon_dev = hwmon_device_register(&new_client->dev);
...@@ -681,8 +712,7 @@ static void adm9240_init_client(struct i2c_client *client) ...@@ -681,8 +712,7 @@ static void adm9240_init_client(struct i2c_client *client)
} else { /* cold start: open limits before starting chip */ } else { /* cold start: open limits before starting chip */
int i; int i;
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++) {
{
i2c_smbus_write_byte_data(client, i2c_smbus_write_byte_data(client,
ADM9240_REG_IN_MIN(i), 0); ADM9240_REG_IN_MIN(i), 0);
i2c_smbus_write_byte_data(client, i2c_smbus_write_byte_data(client,
...@@ -717,8 +747,7 @@ static struct adm9240_data *adm9240_update_device(struct device *dev) ...@@ -717,8 +747,7 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
if (time_after(jiffies, data->last_updated_measure + (HZ * 7 / 4)) if (time_after(jiffies, data->last_updated_measure + (HZ * 7 / 4))
|| !data->valid) { || !data->valid) {
for (i = 0; i < 6; i++) /* read voltages */ for (i = 0; i < 6; i++) { /* read voltages */
{
data->in[i] = i2c_smbus_read_byte_data(client, data->in[i] = i2c_smbus_read_byte_data(client,
ADM9240_REG_IN(i)); ADM9240_REG_IN(i));
} }
...@@ -727,16 +756,17 @@ static struct adm9240_data *adm9240_update_device(struct device *dev) ...@@ -727,16 +756,17 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
i2c_smbus_read_byte_data(client, i2c_smbus_read_byte_data(client,
ADM9240_REG_INT(1)) << 8; ADM9240_REG_INT(1)) << 8;
/* read temperature: assume temperature changes less than /*
* read temperature: assume temperature changes less than
* 0.5'C per two measurement cycles thus ignore possible * 0.5'C per two measurement cycles thus ignore possible
* but unlikely aliasing error on lsb reading. --Grant */ * but unlikely aliasing error on lsb reading. --Grant
*/
data->temp = ((i2c_smbus_read_byte_data(client, data->temp = ((i2c_smbus_read_byte_data(client,
ADM9240_REG_TEMP) << 8) | ADM9240_REG_TEMP) << 8) |
i2c_smbus_read_byte_data(client, i2c_smbus_read_byte_data(client,
ADM9240_REG_TEMP_CONF)) / 128; ADM9240_REG_TEMP_CONF)) / 128;
for (i = 0; i < 2; i++) /* read fans */ for (i = 0; i < 2; i++) { /* read fans */
{
data->fan[i] = i2c_smbus_read_byte_data(client, data->fan[i] = i2c_smbus_read_byte_data(client,
ADM9240_REG_FAN(i)); ADM9240_REG_FAN(i));
...@@ -760,15 +790,13 @@ static struct adm9240_data *adm9240_update_device(struct device *dev) ...@@ -760,15 +790,13 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
if (time_after(jiffies, data->last_updated_config + (HZ * 300)) if (time_after(jiffies, data->last_updated_config + (HZ * 300))
|| !data->valid) { || !data->valid) {
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++) {
{
data->in_min[i] = i2c_smbus_read_byte_data(client, data->in_min[i] = i2c_smbus_read_byte_data(client,
ADM9240_REG_IN_MIN(i)); ADM9240_REG_IN_MIN(i));
data->in_max[i] = i2c_smbus_read_byte_data(client, data->in_max[i] = i2c_smbus_read_byte_data(client,
ADM9240_REG_IN_MAX(i)); ADM9240_REG_IN_MAX(i));
} }
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++) {
{
data->fan_min[i] = i2c_smbus_read_byte_data(client, data->fan_min[i] = i2c_smbus_read_byte_data(client,
ADM9240_REG_FAN_MIN(i)); ADM9240_REG_FAN_MIN(i));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment