aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adm1025.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-01-14 15:49:22 -0500
committerGuenter Roeck <guenter.roeck@ericsson.com>2012-03-18 21:26:46 -0400
commit2b22de5117d6dec44b62c305cb456e5b9a913c95 (patch)
tree02c8077a7200c02df820b1c6d22ab0a8b53068ca /drivers/hwmon/adm1025.c
parent79738416f6016198aef64a772d94ce50fe8b0f5c (diff)
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 Acked-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/adm1025.c')
-rw-r--r--drivers/hwmon/adm1025.c63
1 files changed, 46 insertions, 17 deletions
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c
index 60befc0ee65f..1a7f65102343 100644
--- a/drivers/hwmon/adm1025.c
+++ b/drivers/hwmon/adm1025.c
@@ -12,7 +12,7 @@
12 * resolution of about 0.5% of the nominal value). Temperature values are 12 * resolution of about 0.5% of the nominal value). Temperature values are
13 * reported with a 1 deg resolution and a 3 deg accuracy. Complete 13 * reported with a 1 deg resolution and a 3 deg accuracy. Complete
14 * datasheet can be obtained from Analog's website at: 14 * datasheet can be obtained from Analog's website at:
15 * http://www.onsemi.com/PowerSolutions/product.do?id=ADM1025 15 * http://www.onsemi.com/PowerSolutions/product.do?id=ADM1025
16 * 16 *
17 * This driver also supports the ADM1025A, which differs from the ADM1025 17 * This driver also supports the ADM1025A, which differs from the ADM1025
18 * only in that it has "open-drain VID inputs while the ADM1025 has 18 * only in that it has "open-drain VID inputs while the ADM1025 has
@@ -91,15 +91,16 @@ enum chips { adm1025, ne1619 };
91 91
92static const int in_scale[6] = { 2500, 2250, 3300, 5000, 12000, 3300 }; 92static const int in_scale[6] = { 2500, 2250, 3300, 5000, 12000, 3300 };
93 93
94#define IN_FROM_REG(reg,scale) (((reg) * (scale) + 96) / 192) 94#define IN_FROM_REG(reg, scale) (((reg) * (scale) + 96) / 192)
95#define IN_TO_REG(val,scale) ((val) <= 0 ? 0 : \ 95#define IN_TO_REG(val, scale) ((val) <= 0 ? 0 : \
96 (val) * 192 >= (scale) * 255 ? 255 : \ 96 (val) * 192 >= (scale) * 255 ? 255 : \
97 ((val) * 192 + (scale)/2) / (scale)) 97 ((val) * 192 + (scale) / 2) / (scale))
98 98
99#define TEMP_FROM_REG(reg) ((reg) * 1000) 99#define TEMP_FROM_REG(reg) ((reg) * 1000)
100#define TEMP_TO_REG(val) ((val) <= -127500 ? -128 : \ 100#define TEMP_TO_REG(val) ((val) <= -127500 ? -128 : \
101 (val) >= 126500 ? 127 : \ 101 (val) >= 126500 ? 127 : \
102 (((val) < 0 ? (val)-500 : (val)+500) / 1000)) 102 (((val) < 0 ? (val) - 500 : \
103 (val) + 500) / 1000))
103 104
104/* 105/*
105 * Functions declaration 106 * Functions declaration
@@ -218,7 +219,12 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
218 int index = to_sensor_dev_attr(attr)->index; 219 int index = to_sensor_dev_attr(attr)->index;
219 struct i2c_client *client = to_i2c_client(dev); 220 struct i2c_client *client = to_i2c_client(dev);
220 struct adm1025_data *data = i2c_get_clientdata(client); 221 struct adm1025_data *data = i2c_get_clientdata(client);
221 long val = simple_strtol(buf, NULL, 10); 222 long val;
223 int err;
224
225 err = kstrtol(buf, 10, &val);
226 if (err)
227 return err;
222 228
223 mutex_lock(&data->update_lock); 229 mutex_lock(&data->update_lock);
224 data->in_min[index] = IN_TO_REG(val, in_scale[index]); 230 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,
234 int index = to_sensor_dev_attr(attr)->index; 240 int index = to_sensor_dev_attr(attr)->index;
235 struct i2c_client *client = to_i2c_client(dev); 241 struct i2c_client *client = to_i2c_client(dev);
236 struct adm1025_data *data = i2c_get_clientdata(client); 242 struct adm1025_data *data = i2c_get_clientdata(client);
237 long val = simple_strtol(buf, NULL, 10); 243 long val;
244 int err;
245
246 err = kstrtol(buf, 10, &val);
247 if (err)
248 return err;
238 249
239 mutex_lock(&data->update_lock); 250 mutex_lock(&data->update_lock);
240 data->in_max[index] = IN_TO_REG(val, in_scale[index]); 251 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,
264 int index = to_sensor_dev_attr(attr)->index; 275 int index = to_sensor_dev_attr(attr)->index;
265 struct i2c_client *client = to_i2c_client(dev); 276 struct i2c_client *client = to_i2c_client(dev);
266 struct adm1025_data *data = i2c_get_clientdata(client); 277 struct adm1025_data *data = i2c_get_clientdata(client);
267 long val = simple_strtol(buf, NULL, 10); 278 long val;
279 int err;
280
281 err = kstrtol(buf, 10, &val);
282 if (err)
283 return err;
268 284
269 mutex_lock(&data->update_lock); 285 mutex_lock(&data->update_lock);
270 data->temp_min[index] = TEMP_TO_REG(val); 286 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,
280 int index = to_sensor_dev_attr(attr)->index; 296 int index = to_sensor_dev_attr(attr)->index;
281 struct i2c_client *client = to_i2c_client(dev); 297 struct i2c_client *client = to_i2c_client(dev);
282 struct adm1025_data *data = i2c_get_clientdata(client); 298 struct adm1025_data *data = i2c_get_clientdata(client);
283 long val = simple_strtol(buf, NULL, 10); 299 long val;
300 int err;
301
302 err = kstrtol(buf, 10, &val);
303 if (err)
304 return err;
284 305
285 mutex_lock(&data->update_lock); 306 mutex_lock(&data->update_lock);
286 data->temp_max[index] = TEMP_TO_REG(val); 307 data->temp_max[index] = TEMP_TO_REG(val);
@@ -343,7 +364,14 @@ static ssize_t set_vrm(struct device *dev, struct device_attribute *attr,
343 const char *buf, size_t count) 364 const char *buf, size_t count)
344{ 365{
345 struct adm1025_data *data = dev_get_drvdata(dev); 366 struct adm1025_data *data = dev_get_drvdata(dev);
346 data->vrm = simple_strtoul(buf, NULL, 10); 367 unsigned long val;
368 int err;
369
370 err = kstrtoul(buf, 10, &val);
371 if (err)
372 return err;
373
374 data->vrm = val;
347 return count; 375 return count;
348} 376}
349static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm); 377static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm);
@@ -462,14 +490,15 @@ static int adm1025_probe(struct i2c_client *client,
462 adm1025_init_client(client); 490 adm1025_init_client(client);
463 491
464 /* Register sysfs hooks */ 492 /* Register sysfs hooks */
465 if ((err = sysfs_create_group(&client->dev.kobj, &adm1025_group))) 493 err = sysfs_create_group(&client->dev.kobj, &adm1025_group);
494 if (err)
466 goto exit_free; 495 goto exit_free;
467 496
468 /* Pin 11 is either in4 (+12V) or VID4 */ 497 /* Pin 11 is either in4 (+12V) or VID4 */
469 config = i2c_smbus_read_byte_data(client, ADM1025_REG_CONFIG); 498 config = i2c_smbus_read_byte_data(client, ADM1025_REG_CONFIG);
470 if (!(config & 0x20)) { 499 if (!(config & 0x20)) {
471 if ((err = sysfs_create_group(&client->dev.kobj, 500 err = sysfs_create_group(&client->dev.kobj, &adm1025_group_in4);
472 &adm1025_group_in4))) 501 if (err)
473 goto exit_remove; 502 goto exit_remove;
474 } 503 }
475 504
@@ -506,7 +535,7 @@ static void adm1025_init_client(struct i2c_client *client)
506 * setting yet, we better set the high limits to the max so that 535 * setting yet, we better set the high limits to the max so that
507 * no alarm triggers. 536 * no alarm triggers.
508 */ 537 */
509 for (i=0; i<6; i++) { 538 for (i = 0; i < 6; i++) {
510 reg = i2c_smbus_read_byte_data(client, 539 reg = i2c_smbus_read_byte_data(client,
511 ADM1025_REG_IN_MAX(i)); 540 ADM1025_REG_IN_MAX(i));
512 if (reg == 0) 541 if (reg == 0)
@@ -514,7 +543,7 @@ static void adm1025_init_client(struct i2c_client *client)
514 ADM1025_REG_IN_MAX(i), 543 ADM1025_REG_IN_MAX(i),
515 0xFF); 544 0xFF);
516 } 545 }
517 for (i=0; i<2; i++) { 546 for (i = 0; i < 2; i++) {
518 reg = i2c_smbus_read_byte_data(client, 547 reg = i2c_smbus_read_byte_data(client,
519 ADM1025_REG_TEMP_HIGH(i)); 548 ADM1025_REG_TEMP_HIGH(i));
520 if (reg == 0) 549 if (reg == 0)
@@ -555,7 +584,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev)
555 int i; 584 int i;
556 585
557 dev_dbg(&client->dev, "Updating data.\n"); 586 dev_dbg(&client->dev, "Updating data.\n");
558 for (i=0; i<6; i++) { 587 for (i = 0; i < 6; i++) {
559 data->in[i] = i2c_smbus_read_byte_data(client, 588 data->in[i] = i2c_smbus_read_byte_data(client,
560 ADM1025_REG_IN(i)); 589 ADM1025_REG_IN(i));
561 data->in_min[i] = i2c_smbus_read_byte_data(client, 590 data->in_min[i] = i2c_smbus_read_byte_data(client,
@@ -563,7 +592,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev)
563 data->in_max[i] = i2c_smbus_read_byte_data(client, 592 data->in_max[i] = i2c_smbus_read_byte_data(client,
564 ADM1025_REG_IN_MAX(i)); 593 ADM1025_REG_IN_MAX(i));
565 } 594 }
566 for (i=0; i<2; i++) { 595 for (i = 0; i < 2; i++) {
567 data->temp[i] = i2c_smbus_read_byte_data(client, 596 data->temp[i] = i2c_smbus_read_byte_data(client,
568 ADM1025_REG_TEMP(i)); 597 ADM1025_REG_TEMP(i));
569 data->temp_min[i] = i2c_smbus_read_byte_data(client, 598 data->temp_min[i] = i2c_smbus_read_byte_data(client,