Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 73b4a087 authored by Viresh Kumar's avatar Viresh Kumar Committed by Sebastian Reichel
Browse files

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: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
parent 9d2410c7
Loading
Loading
Loading
Loading
+11 −10
Original line number Diff line number Diff line
@@ -73,9 +73,9 @@ 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) {
@@ -87,6 +87,7 @@ static ssize_t power_supply_show_property(struct device *dev,
					attr->attr.name, ret);
			return ret;
		}
	}

	if (off == POWER_SUPPLY_PROP_STATUS)
		return sprintf(buf, "%s\n", status_text[value.intval]);