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

Commit 06e4f418 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "regulator: add verbose error messages for invalid voltage requests"

parents 90f36134 46825f13
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -267,6 +267,15 @@ static int regulator_check_voltage(struct regulator_dev *rdev,
		return -EPERM;
	}

	/* check if requested voltage range actually overlaps the constraints */
	if (*max_uV < rdev->constraints->min_uV ||
	    *min_uV > rdev->constraints->max_uV) {
		rdev_err(rdev, "requested voltage range [%d, %d] does not fit within constraints: [%d, %d]\n",
			*min_uV, *max_uV, rdev->constraints->min_uV,
			rdev->constraints->max_uV);
		return -EINVAL;
	}

	if (*max_uV > rdev->constraints->max_uV)
		*max_uV = rdev->constraints->max_uV;
	if (*min_uV < rdev->constraints->min_uV)
@@ -296,6 +305,8 @@ static int regulator_check_consumers(struct regulator_dev *rdev,
{
	struct regulator *regulator;
	struct regulator_voltage *voltage;
	int init_min_uV = *min_uV;
	int init_max_uV = *max_uV;

	list_for_each_entry(regulator, &rdev->consumer_list, list) {
		voltage = &regulator->voltage[state];
@@ -306,6 +317,12 @@ static int regulator_check_consumers(struct regulator_dev *rdev,
		if (!voltage->min_uV && !voltage->max_uV)
			continue;

		if (init_max_uV < voltage->min_uV
		    || init_min_uV > voltage->max_uV)
			rdev_err(rdev, "requested voltage range [%d, %d] does not fit within previously voted range: [%d, %d]\n",
				init_min_uV, init_max_uV, voltage->min_uV,
				voltage->max_uV);

		if (*max_uV > voltage->max_uV)
			*max_uV = voltage->max_uV;
		if (*min_uV < voltage->min_uV)