diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2014-09-04 08:01:34 -0400 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2014-09-16 05:01:37 -0400 |
commit | 73b4a087ba4c0d0d52519769320fa684185c563e (patch) | |
tree | 6d691c88248949913297077e71580460c0bc1f90 /drivers/power/power_supply_sysfs.c | |
parent | 9d2410c79b5b2dd741648de26ad52ffd2ce3dc01 (diff) |
power-supply: Check for failures only when we can fail
In power_supply_show_property() routine, we call ->get_property() conditionally
and should check for failure in that case only. There is no point comparing
'ret' for errors when 'ret' is surely zero.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power/power_supply_sysfs.c')
-rw-r--r-- | drivers/power/power_supply_sysfs.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c index 7e4726d37211..62653f50a524 100644 --- a/drivers/power/power_supply_sysfs.c +++ b/drivers/power/power_supply_sysfs.c | |||
@@ -73,19 +73,20 @@ static ssize_t power_supply_show_property(struct device *dev, | |||
73 | const ptrdiff_t off = attr - power_supply_attrs; | 73 | const ptrdiff_t off = attr - power_supply_attrs; |
74 | union power_supply_propval value; | 74 | union power_supply_propval value; |
75 | 75 | ||
76 | if (off == POWER_SUPPLY_PROP_TYPE) | 76 | if (off == POWER_SUPPLY_PROP_TYPE) { |
77 | value.intval = psy->type; | 77 | value.intval = psy->type; |
78 | else | 78 | } else { |
79 | ret = psy->get_property(psy, off, &value); | 79 | ret = psy->get_property(psy, off, &value); |
80 | 80 | ||
81 | if (ret < 0) { | 81 | if (ret < 0) { |
82 | if (ret == -ENODATA) | 82 | if (ret == -ENODATA) |
83 | dev_dbg(dev, "driver has no data for `%s' property\n", | 83 | dev_dbg(dev, "driver has no data for `%s' property\n", |
84 | attr->attr.name); | 84 | attr->attr.name); |
85 | else if (ret != -ENODEV) | 85 | else if (ret != -ENODEV) |
86 | dev_err(dev, "driver failed to report `%s' property: %zd\n", | 86 | dev_err(dev, "driver failed to report `%s' property: %zd\n", |
87 | attr->attr.name, ret); | 87 | attr->attr.name, ret); |
88 | return ret; | 88 | return ret; |
89 | } | ||
89 | } | 90 | } |
90 | 91 | ||
91 | if (off == POWER_SUPPLY_PROP_STATUS) | 92 | if (off == POWER_SUPPLY_PROP_STATUS) |