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

Commit cb220d16 authored by Axel Lin's avatar Axel Lin Committed by Liam Girdwood
Browse files

regulator: Fix _regulator_get_voltage if get_voltage callback is NULL



In the case of get_voltage callback is NULL, current implementation in
_regulator_get_voltage will return -EINVAL.

Also returns proper error if ret is negative value.

Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Acked-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
parent 5ccee4ae
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -1886,12 +1886,14 @@ static int _regulator_get_voltage(struct regulator_dev *rdev)
		if (sel < 0)
			return sel;
		ret = rdev->desc->ops->list_voltage(rdev, sel);
	}
	if (rdev->desc->ops->get_voltage)
	} else if (rdev->desc->ops->get_voltage) {
		ret = rdev->desc->ops->get_voltage(rdev);
	else
	} else {
		return -EINVAL;
	}

	if (ret < 0)
		return ret;
	return ret - rdev->constraints->uV_offset;
}