diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-03-28 12:14:03 -0400 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2012-04-09 15:17:38 -0400 |
commit | d7ee11157f1fce02632e2f3a56b99b2afd9e5f93 (patch) | |
tree | 1dda4145ec73bd54659bf3ba7ff250d4833bc66a /drivers/hwmon/pmbus | |
parent | 1d0045ee4a220872b65147b5b290e4a4852386d9 (diff) |
hwmon: (pmbus_core) Fix compiler warning
Some configurations produce the following compiler warning:
drivers/hwmon/pmbus/pmbus_core.c: In function 'pmbus_show_boolean':
drivers/hwmon/pmbus/pmbus_core.c:752: warning: 'val' may be used uninitialized in this function
While this is a false positive, it can easily be fixed by overloading the return
value from pmbus_get_boolean with both val and error return code (val is a
boolean and thus never negative).
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Robert Coulson <robert.coulson@ericsson.com>
Diffstat (limited to 'drivers/hwmon/pmbus')
-rw-r--r-- | drivers/hwmon/pmbus/pmbus_core.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index be51037363c8..29b319db573e 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c | |||
@@ -710,13 +710,13 @@ static u16 pmbus_data2reg(struct pmbus_data *data, | |||
710 | * If a negative value is stored in any of the referenced registers, this value | 710 | * If a negative value is stored in any of the referenced registers, this value |
711 | * reflects an error code which will be returned. | 711 | * reflects an error code which will be returned. |
712 | */ | 712 | */ |
713 | static int pmbus_get_boolean(struct pmbus_data *data, int index, int *val) | 713 | static int pmbus_get_boolean(struct pmbus_data *data, int index) |
714 | { | 714 | { |
715 | u8 s1 = (index >> 24) & 0xff; | 715 | u8 s1 = (index >> 24) & 0xff; |
716 | u8 s2 = (index >> 16) & 0xff; | 716 | u8 s2 = (index >> 16) & 0xff; |
717 | u8 reg = (index >> 8) & 0xff; | 717 | u8 reg = (index >> 8) & 0xff; |
718 | u8 mask = index & 0xff; | 718 | u8 mask = index & 0xff; |
719 | int status; | 719 | int ret, status; |
720 | u8 regval; | 720 | u8 regval; |
721 | 721 | ||
722 | status = data->status[reg]; | 722 | status = data->status[reg]; |
@@ -725,7 +725,7 @@ static int pmbus_get_boolean(struct pmbus_data *data, int index, int *val) | |||
725 | 725 | ||
726 | regval = status & mask; | 726 | regval = status & mask; |
727 | if (!s1 && !s2) | 727 | if (!s1 && !s2) |
728 | *val = !!regval; | 728 | ret = !!regval; |
729 | else { | 729 | else { |
730 | long v1, v2; | 730 | long v1, v2; |
731 | struct pmbus_sensor *sensor1, *sensor2; | 731 | struct pmbus_sensor *sensor1, *sensor2; |
@@ -739,9 +739,9 @@ static int pmbus_get_boolean(struct pmbus_data *data, int index, int *val) | |||
739 | 739 | ||
740 | v1 = pmbus_reg2data(data, sensor1); | 740 | v1 = pmbus_reg2data(data, sensor1); |
741 | v2 = pmbus_reg2data(data, sensor2); | 741 | v2 = pmbus_reg2data(data, sensor2); |
742 | *val = !!(regval && v1 >= v2); | 742 | ret = !!(regval && v1 >= v2); |
743 | } | 743 | } |
744 | return 0; | 744 | return ret; |
745 | } | 745 | } |
746 | 746 | ||
747 | static ssize_t pmbus_show_boolean(struct device *dev, | 747 | static ssize_t pmbus_show_boolean(struct device *dev, |
@@ -750,11 +750,10 @@ static ssize_t pmbus_show_boolean(struct device *dev, | |||
750 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); | 750 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
751 | struct pmbus_data *data = pmbus_update_device(dev); | 751 | struct pmbus_data *data = pmbus_update_device(dev); |
752 | int val; | 752 | int val; |
753 | int err; | ||
754 | 753 | ||
755 | err = pmbus_get_boolean(data, attr->index, &val); | 754 | val = pmbus_get_boolean(data, attr->index); |
756 | if (err) | 755 | if (val < 0) |
757 | return err; | 756 | return val; |
758 | return snprintf(buf, PAGE_SIZE, "%d\n", val); | 757 | return snprintf(buf, PAGE_SIZE, "%d\n", val); |
759 | } | 758 | } |
760 | 759 | ||