hwmon: (adm1025) Fix checkpatch issues
Subsystems (2)
Guenter Roeck
maintainerPATCH 4/39 hwmon: (adm1025) Fix checkpatch issues
Fixed:
ERROR: do not use assignment in if condition
ERROR: space required after that ',' (ctx:VxV)
ERROR: spaces required around that '<' (ctx:VxV)
ERROR: spaces required around that '=' (ctx:VxV)
ERROR: trailing whitespace
WARNING: simple_strtol is obsolete, use kstrtol instead
WARNING: simple_strtoul is obsolete, use kstrtoul instead
Not fixed:
ERROR: Macros with multiple statements should be enclosed in a do - while loop
--- drivers/hwmon/adm1025.c | 63 ++++++++++++++++++++++++++++++++++------------ 1 files changed, 46 insertions(+), 17 deletions(-)
drivers/hwmon/adm1025.c +46 -17
@@ -12,7 +12,7 @@* resolution of about 0.5% of the nominal value). Temperature values are * reported with a 1 deg resolution and a 3 deg accuracy. Complete * datasheet can be obtained from Analog's website at: -* http://www.onsemi.com/PowerSolutions/product.do?idM1025 +* http://www.onsemi.com/PowerSolutions/product.do?idM1025 * * This driver also supports the ADM1025A, which differs from the ADM1025 * only in that it has "open-drain VID inputs while the ADM1025 has
@@ -91,15 +91,16 @@ enum chips { adm1025, ne1619 };static const int in_scale[6 ] = {2500 ,2250 ,3300 ,5000 ,12000 ,3300 }; -#define IN_FROM_REG (reg,scale) (((reg) * (scale) + 96) / 192) -#define IN_TO_REG (val,scale) ((val) <= 0 ? 0 : \ +#define IN_FROM_REG (reg, scale) (((reg) * (scale) + 96) / 192) +#define IN_TO_REG (val, scale) ((val) <= 0 ? 0 : \ (val) * 192 >= (scale) * 255 ? 255 : \ - ((val) * 192 + (scale)/2) / (scale)) + ((val) * 192 + (scale) / 2) / (scale))#define TEMP_FROM_REG (reg) ((reg) * 1000)#define TEMP_TO_REG (val) ((val) <= -127500 ? -128 : \ (val) >= 126500 ? 127 : \ - (((val) < 0 ? (val)-500 : (val)+500) / 1000)) + (((val) < 0 ? (val) - 500 : \ + (val) + 500) / 1000))/* * Functions declaration
@@ -218,7 +219,12 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,int index =to_sensor_dev_attr (attr)->index;struct i2c_client *client =to_i2c_client (dev);struct adm1025_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); data->in_min[index] =IN_TO_REG (val, in_scale[index]);
@@ -234,7 +240,12 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,int index =to_sensor_dev_attr (attr)->index;struct i2c_client *client =to_i2c_client (dev);struct adm1025_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); data->in_max[index] =IN_TO_REG (val, in_scale[index]);
@@ -264,7 +275,12 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,int index =to_sensor_dev_attr (attr)->index;struct i2c_client *client =to_i2c_client (dev);struct adm1025_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); data->temp_min[index] =TEMP_TO_REG (val);
@@ -280,7 +296,12 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,int index =to_sensor_dev_attr (attr)->index;struct i2c_client *client =to_i2c_client (dev);struct adm1025_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); data->temp_max[index] =TEMP_TO_REG (val);
@@ -343,7 +364,14 @@ static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) {struct adm1025_data *data =dev_get_drvdata (dev); - data->vrm =simple_strtoul (buf,NULL ,10 ); +unsigned long val; +int err; + + err =kstrtoul (buf,10 , &val); +if (err) +return err; + + data->vrm =SENSORS_LIMIT (val,0 ,255 );return count; } static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm);
@@ -462,14 +490,15 @@ static int adm1025_probe(struct i2c_client *client,adm1025_init_client (client);/* Register sysfs hooks */ -if ((err =sysfs_create_group (&client->dev.kobj, &adm1025_group))) + err =sysfs_create_group (&client->dev.kobj, &adm1025_group); +if (err) goto exit_free;/* Pin 11 is either in4 (+12V) or VID4 */ config =i2c_smbus_read_byte_data (client,ADM1025_REG_CONFIG );if (!(config &0x20 )) { -if ((err =sysfs_create_group (&client->dev.kobj, - &adm1025_group_in4))) + err =sysfs_create_group (&client->dev.kobj, &adm1025_group_in4); +if (err) goto exit_remove; }
@@ -506,7 +535,7 @@ static void adm1025_init_client(struct i2c_client *client)* setting yet, we better set the high limits to the max so that * no alarm triggers. */ -for (i=0 ; i<6 ; i++) { +for (i =0 ; i <6 ; i++) { reg =i2c_smbus_read_byte_data (client,ADM1025_REG_IN_MAX (i));if (reg =0 )
@@ -514,7 +543,7 @@ static void adm1025_init_client(struct i2c_client *client)ADM1025_REG_IN_MAX (i), 0xFF); } -for (i=0 ; i<2 ; i++) { +for (i =0 ; i <2 ; i++) { reg =i2c_smbus_read_byte_data (client,ADM1025_REG_TEMP_HIGH (i));if (reg =0 )
@@ -555,7 +584,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev)int i;dev_dbg (&client->dev,"Updating data.\n" ); -for (i=0 ; i<6 ; i++) { +for (i =0 ; i <6 ; i++) { data->in[i] =i2c_smbus_read_byte_data (client,ADM1025_REG_IN (i)); data->in_min[i] = i2c_smbus_read_byte_data(client,
@@ -563,7 +592,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev) data->in_max[i] =i2c_smbus_read_byte_data (client,ADM1025_REG_IN_MAX (i)); } -for (i=0 ; i<2 ; i++) { +for (i =0 ; i <2 ; i++) { data->temp[i] =i2c_smbus_read_byte_data (client,ADM1025_REG_TEMP (i)); data->temp_min[i] = i2c_smbus_read_byte_data(client,
Signature · 7 lines
1.7.5.4 _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 27 lines · Guenter Roeck
Fixed:
ERROR: do not use assignment in if condition
ERROR: space required after that ',' (ctx:VxV)
ERROR: spaces required around that '<' (ctx:VxV)
ERROR: spaces required around that '=' (ctx:VxV)
ERROR: trailing whitespace
WARNING:simple_strtolis obsolete, use kstrtol instead
WARNING:simple_strtoulis obsolete, use kstrtoul insteadNot fixed:
ERROR: Macros with multiple statements should be enclosed in a do - while loopSigned-off-by Guenter Roeck <[email protected]>--- drivers/hwmon/adm1025.c | 63 ++++++++++++++++++++++++++++++++++------------ 1 files changed, 46 insertions(+), 17 deletions(-)drivers/hwmon/adm1025.c +0
-1@@ -343,7 +364,14 @@ static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) {struct adm1025_data *data =dev_get_drvdata (dev); - data->vrm =simple_strtoul (buf,NULL ,10 );
drivers/hwmon/adm1025.c static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, · line 376
Quoted 10 lines
drivers/hwmon/adm1025.c +8
-0+unsigned long val; +int err; + + err =kstrtoul (buf,10 , &val); +if (err) +return err; + + data->vrm =SENSORS_LIMIT (val,0 ,255 );return count; }
This is a behavioral change, not a mere checkpatch clean-up. The change itself is correct but it should be separated.
The rest looks good, so:
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 33 lines · Jean Delvare
Quoted 32 lines · Guenter Roeck
Fixed:
ERROR: do not use assignment in if condition
ERROR: space required after that ',' (ctx:VxV)
ERROR: spaces required around that '<' (ctx:VxV)
ERROR: spaces required around that '=' (ctx:VxV)
ERROR: trailing whitespace
WARNING:simple_strtolis obsolete, use kstrtol instead
WARNING:simple_strtoulis obsolete, use kstrtoul insteadNot fixed:
ERROR: Macros with multiple statements should be enclosed in a do - while loopSigned-off-by Guenter Roeck <[email protected]>--- drivers/hwmon/adm1025.c | 63 ++++++++++++++++++++++++++++++++++------------ 1 files changed, 46 insertions(+), 17 deletions(-)drivers/hwmon/adm1025.c +5
-1@@ -343,7 +364,14 @@ static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) {struct adm1025_data *data =dev_get_drvdata (dev); - data->vrm =simple_strtoul (buf,NULL ,10 ); +unsigned long val; +int err; + + err =kstrtoul (buf,10 , &val); +if (err)
Quoted 9 lines
drivers/hwmon/adm1025.c static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, · line 376
Quoted 5 lines
drivers/hwmon/adm1025.c +3
-0+return err; + + data->vrm =SENSORS_LIMIT (val,0 ,255 );return count; }This is a behavioral change, not a mere checkpatch clean-up. The change itself is correct but it should be separated.
I have done the same with all vrm assignments, at least the ones similar to the above. Assigning "value & 255", or in other words a more or less random value, just seemed wrong.
There are other borderline cases throughout, for example
unsigned long xxx = simple_strtol(...); or long xxx = simple_strtoul(...); or u32 = simple_strtoul(...);
where I fixed either the variable type or the function call to match each other, depending on the context. Obviously those also cause minor behavioral changes - mostly more stringent error checking. I would call that borderline cases. Sure, I could have fixed the type issues with one commit and then the coding style issues with another, but that would just have added complexity to the whole thing for very minor gain.
Quoted 4 lines
The rest looks good, so:
Acked-by Jean Delvare <[email protected]>
I'll separate this commit into two and add your Acked-by to both, assuming this is ok with you.
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 5 lines · Guenter Roeck
Quoted 1 line · Jean Delvare
Acked-by Jean Delvare <[email protected]>I'll separate this commit into two and add your Acked-by to both, assuming this is ok with you.
Yes it is.
Thanks,
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors