Skip to content

Commit

Permalink
power-supply: Check for failures only when we can fail
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Viresh Kumar authored and Sebastian Reichel committed Sep 16, 2014
1 parent 9d2410c commit 73b4a08
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions drivers/power/power_supply_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,20 @@ static ssize_t power_supply_show_property(struct device *dev,
const ptrdiff_t off = attr - power_supply_attrs;
union power_supply_propval value;

if (off == POWER_SUPPLY_PROP_TYPE)
if (off == POWER_SUPPLY_PROP_TYPE) {
value.intval = psy->type;
else
} else {
ret = psy->get_property(psy, off, &value);

if (ret < 0) {
if (ret == -ENODATA)
dev_dbg(dev, "driver has no data for `%s' property\n",
attr->attr.name);
else if (ret != -ENODEV)
dev_err(dev, "driver failed to report `%s' property: %zd\n",
attr->attr.name, ret);
return ret;
if (ret < 0) {
if (ret == -ENODATA)
dev_dbg(dev, "driver has no data for `%s' property\n",
attr->attr.name);
else if (ret != -ENODEV)
dev_err(dev, "driver failed to report `%s' property: %zd\n",
attr->attr.name, ret);
return ret;
}
}

if (off == POWER_SUPPLY_PROP_STATUS)
Expand Down

0 comments on commit 73b4a08

Please sign in to comment.