aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm90.c
diff options
context:
space:
mode:
authorGuenter Roeck <guenter.roeck@ericsson.com>2010-10-28 14:31:42 -0400
committerJean Delvare <khali@endymion.delvare>2010-10-28 14:31:42 -0400
commit11e578129af74c4866cf559e62e981c6415fffd9 (patch)
tree50946c5c4e0d483a81bc5cf3a117964bffadddf6 /drivers/hwmon/lm90.c
parent28e7438faacbd47aaf3e3b43c3074c64be98f5be (diff)
hwmon: (lm90) Fix checkpatch errors
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/lm90.c')
-rw-r--r--drivers/hwmon/lm90.c76
1 files changed, 51 insertions, 25 deletions
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 760ef72eea56..aafed2898d95 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -387,8 +387,13 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr,
387 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 387 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
388 struct i2c_client *client = to_i2c_client(dev); 388 struct i2c_client *client = to_i2c_client(dev);
389 struct lm90_data *data = i2c_get_clientdata(client); 389 struct lm90_data *data = i2c_get_clientdata(client);
390 long val = simple_strtol(buf, NULL, 10);
391 int nr = attr->index; 390 int nr = attr->index;
391 long val;
392 int err;
393
394 err = strict_strtol(buf, 10, &val);
395 if (err < 0)
396 return err;
392 397
393 /* +16 degrees offset for temp2 for the LM99 */ 398 /* +16 degrees offset for temp2 for the LM99 */
394 if (data->kind == lm99 && attr->index == 3) 399 if (data->kind == lm99 && attr->index == 3)
@@ -442,8 +447,13 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
442 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 447 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
443 struct i2c_client *client = to_i2c_client(dev); 448 struct i2c_client *client = to_i2c_client(dev);
444 struct lm90_data *data = i2c_get_clientdata(client); 449 struct lm90_data *data = i2c_get_clientdata(client);
445 long val = simple_strtol(buf, NULL, 10);
446 int nr = attr->index; 450 int nr = attr->index;
451 long val;
452 int err;
453
454 err = strict_strtol(buf, 10, &val);
455 if (err < 0)
456 return err;
447 457
448 /* +16 degrees offset for temp2 for the LM99 */ 458 /* +16 degrees offset for temp2 for the LM99 */
449 if (data->kind == lm99 && attr->index <= 2) 459 if (data->kind == lm99 && attr->index <= 2)
@@ -469,7 +479,8 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
469 return count; 479 return count;
470} 480}
471 481
472static ssize_t show_temphyst(struct device *dev, struct device_attribute *devattr, 482static ssize_t show_temphyst(struct device *dev,
483 struct device_attribute *devattr,
473 char *buf) 484 char *buf)
474{ 485{
475 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 486 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
@@ -495,9 +506,14 @@ static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy,
495{ 506{
496 struct i2c_client *client = to_i2c_client(dev); 507 struct i2c_client *client = to_i2c_client(dev);
497 struct lm90_data *data = i2c_get_clientdata(client); 508 struct lm90_data *data = i2c_get_clientdata(client);
498 long val = simple_strtol(buf, NULL, 10); 509 long val;
510 int err;
499 int temp; 511 int temp;
500 512
513 err = strict_strtol(buf, 10, &val);
514 if (err < 0)
515 return err;
516
501 mutex_lock(&data->update_lock); 517 mutex_lock(&data->update_lock);
502 if (data->kind == adt7461) 518 if (data->kind == adt7461)
503 temp = temp_from_u8_adt7461(data, data->temp8[2]); 519 temp = temp_from_u8_adt7461(data, data->temp8[2]);
@@ -600,7 +616,12 @@ static ssize_t set_pec(struct device *dev, struct device_attribute *dummy,
600 const char *buf, size_t count) 616 const char *buf, size_t count)
601{ 617{
602 struct i2c_client *client = to_i2c_client(dev); 618 struct i2c_client *client = to_i2c_client(dev);
603 long val = simple_strtol(buf, NULL, 10); 619 long val;
620 int err;
621
622 err = strict_strtol(buf, 10, &val);
623 if (err < 0)
624 return err;
604 625
605 switch (val) { 626 switch (val) {
606 case 0: 627 case 0:
@@ -622,8 +643,10 @@ static DEVICE_ATTR(pec, S_IWUSR | S_IRUGO, show_pec, set_pec);
622 * Real code 643 * Real code
623 */ 644 */
624 645
625/* The ADM1032 supports PEC but not on write byte transactions, so we need 646/*
626 to explicitly ask for a transaction without PEC. */ 647 * The ADM1032 supports PEC but not on write byte transactions, so we need
648 * to explicitly ask for a transaction without PEC.
649 */
627static inline s32 adm1032_write_byte(struct i2c_client *client, u8 value) 650static inline s32 adm1032_write_byte(struct i2c_client *client, u8 value)
628{ 651{
629 return i2c_smbus_xfer(client->adapter, client->addr, 652 return i2c_smbus_xfer(client->adapter, client->addr,
@@ -631,20 +654,22 @@ static inline s32 adm1032_write_byte(struct i2c_client *client, u8 value)
631 I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL); 654 I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL);
632} 655}
633 656
634/* It is assumed that client->update_lock is held (unless we are in 657/*
635 detection or initialization steps). This matters when PEC is enabled, 658 * It is assumed that client->update_lock is held (unless we are in
636 because we don't want the address pointer to change between the write 659 * detection or initialization steps). This matters when PEC is enabled,
637 byte and the read byte transactions. */ 660 * because we don't want the address pointer to change between the write
638static int lm90_read_reg(struct i2c_client* client, u8 reg, u8 *value) 661 * byte and the read byte transactions.
662 */
663static int lm90_read_reg(struct i2c_client *client, u8 reg, u8 *value)
639{ 664{
640 int err; 665 int err;
641 666
642 if (client->flags & I2C_CLIENT_PEC) { 667 if (client->flags & I2C_CLIENT_PEC) {
643 err = adm1032_write_byte(client, reg); 668 err = adm1032_write_byte(client, reg);
644 if (err >= 0) 669 if (err >= 0)
645 err = i2c_smbus_read_byte(client); 670 err = i2c_smbus_read_byte(client);
646 } else 671 } else
647 err = i2c_smbus_read_byte_data(client, reg); 672 err = i2c_smbus_read_byte_data(client, reg);
648 673
649 if (err < 0) { 674 if (err < 0) {
650 dev_warn(&client->dev, "Register %#02x read failed (%d)\n", 675 dev_warn(&client->dev, "Register %#02x read failed (%d)\n",
@@ -826,16 +851,18 @@ static int lm90_probe(struct i2c_client *new_client,
826 lm90_init_client(new_client); 851 lm90_init_client(new_client);
827 852
828 /* Register sysfs hooks */ 853 /* Register sysfs hooks */
829 if ((err = sysfs_create_group(&new_client->dev.kobj, &lm90_group))) 854 err = sysfs_create_group(&new_client->dev.kobj, &lm90_group);
855 if (err)
830 goto exit_free; 856 goto exit_free;
831 if (new_client->flags & I2C_CLIENT_PEC) { 857 if (new_client->flags & I2C_CLIENT_PEC) {
832 if ((err = device_create_file(&new_client->dev, 858 err = device_create_file(&new_client->dev, &dev_attr_pec);
833 &dev_attr_pec))) 859 if (err)
834 goto exit_remove_files; 860 goto exit_remove_files;
835 } 861 }
836 if (data->kind != max6657 && data->kind != max6646) { 862 if (data->kind != max6657 && data->kind != max6646) {
837 if ((err = device_create_file(&new_client->dev, 863 err = device_create_file(&new_client->dev,
838 &sensor_dev_attr_temp2_offset.dev_attr))) 864 &sensor_dev_attr_temp2_offset.dev_attr);
865 if (err)
839 goto exit_remove_files; 866 goto exit_remove_files;
840 } 867 }
841 868
@@ -883,9 +910,8 @@ static void lm90_init_client(struct i2c_client *client)
883 * 0.125 degree resolution) and range (0x08, extend range 910 * 0.125 degree resolution) and range (0x08, extend range
884 * to -64 degree) mode for the remote temperature sensor. 911 * to -64 degree) mode for the remote temperature sensor.
885 */ 912 */
886 if (data->kind == max6680) { 913 if (data->kind == max6680)
887 config |= 0x18; 914 config |= 0x18;
888 }
889 915
890 config &= 0xBF; /* run */ 916 config &= 0xBF; /* run */
891 if (config != data->config_orig) /* Only write if changed */ 917 if (config != data->config_orig) /* Only write if changed */