diff options
| -rw-r--r-- | drivers/hwmon/emc6w201.c | 2 | ||||
| -rw-r--r-- | drivers/hwmon/lm73.c | 16 |
2 files changed, 12 insertions, 6 deletions
diff --git a/drivers/hwmon/emc6w201.c b/drivers/hwmon/emc6w201.c index a98c917b5888..789bd4fb329b 100644 --- a/drivers/hwmon/emc6w201.c +++ b/drivers/hwmon/emc6w201.c | |||
| @@ -187,7 +187,7 @@ static struct emc6w201_data *emc6w201_update_device(struct device *dev) | |||
| 187 | * Sysfs callback functions | 187 | * Sysfs callback functions |
| 188 | */ | 188 | */ |
| 189 | 189 | ||
| 190 | static const u16 nominal_mv[6] = { 2500, 1500, 3300, 5000, 1500, 1500 }; | 190 | static const s16 nominal_mv[6] = { 2500, 1500, 3300, 5000, 1500, 1500 }; |
| 191 | 191 | ||
| 192 | static ssize_t show_in(struct device *dev, struct device_attribute *devattr, | 192 | static ssize_t show_in(struct device *dev, struct device_attribute *devattr, |
| 193 | char *buf) | 193 | char *buf) |
diff --git a/drivers/hwmon/lm73.c b/drivers/hwmon/lm73.c index 8fa2632cbbaf..7272176a9ec7 100644 --- a/drivers/hwmon/lm73.c +++ b/drivers/hwmon/lm73.c | |||
| @@ -49,6 +49,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da, | |||
| 49 | struct i2c_client *client = to_i2c_client(dev); | 49 | struct i2c_client *client = to_i2c_client(dev); |
| 50 | long temp; | 50 | long temp; |
| 51 | short value; | 51 | short value; |
| 52 | s32 err; | ||
| 52 | 53 | ||
| 53 | int status = kstrtol(buf, 10, &temp); | 54 | int status = kstrtol(buf, 10, &temp); |
| 54 | if (status < 0) | 55 | if (status < 0) |
| @@ -57,8 +58,8 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da, | |||
| 57 | /* Write value */ | 58 | /* Write value */ |
| 58 | value = (short) SENSORS_LIMIT(temp/250, (LM73_TEMP_MIN*4), | 59 | value = (short) SENSORS_LIMIT(temp/250, (LM73_TEMP_MIN*4), |
| 59 | (LM73_TEMP_MAX*4)) << 5; | 60 | (LM73_TEMP_MAX*4)) << 5; |
| 60 | i2c_smbus_write_word_swapped(client, attr->index, value); | 61 | err = i2c_smbus_write_word_swapped(client, attr->index, value); |
| 61 | return count; | 62 | return (err < 0) ? err : count; |
| 62 | } | 63 | } |
| 63 | 64 | ||
| 64 | static ssize_t show_temp(struct device *dev, struct device_attribute *da, | 65 | static ssize_t show_temp(struct device *dev, struct device_attribute *da, |
| @@ -66,11 +67,16 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *da, | |||
| 66 | { | 67 | { |
| 67 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); | 68 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
| 68 | struct i2c_client *client = to_i2c_client(dev); | 69 | struct i2c_client *client = to_i2c_client(dev); |
| 70 | int temp; | ||
| 71 | |||
| 72 | s32 err = i2c_smbus_read_word_swapped(client, attr->index); | ||
| 73 | if (err < 0) | ||
| 74 | return err; | ||
| 75 | |||
| 69 | /* use integer division instead of equivalent right shift to | 76 | /* use integer division instead of equivalent right shift to |
| 70 | guarantee arithmetic shift and preserve the sign */ | 77 | guarantee arithmetic shift and preserve the sign */ |
| 71 | int temp = ((s16) (i2c_smbus_read_word_swapped(client, | 78 | temp = (((s16) err) * 250) / 32; |
| 72 | attr->index))*250) / 32; | 79 | return scnprintf(buf, PAGE_SIZE, "%d\n", temp); |
| 73 | return sprintf(buf, "%d\n", temp); | ||
| 74 | } | 80 | } |
| 75 | 81 | ||
| 76 | 82 | ||
