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

Commit 422294de authored by Axel Lin's avatar Axel Lin Committed by Mark Brown
Browse files

regulator: wm831x-dcdc: set_current_limit should select the maximum current in specific range

parent cb44cdea
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -339,16 +339,15 @@ static int wm831x_buckv_set_current_limit(struct regulator_dev *rdev,
	u16 reg = dcdc->base + WM831X_DCDC_CONTROL_2;
	int i;

	for (i = 0; i < ARRAY_SIZE(wm831x_dcdc_ilim); i++) {
	for (i = ARRAY_SIZE(wm831x_dcdc_ilim) - 1; i >= 0; i--) {
		if ((min_uA <= wm831x_dcdc_ilim[i]) &&
		    (wm831x_dcdc_ilim[i] <= max_uA))
			break;
			return wm831x_set_bits(wm831x, reg,
					       WM831X_DC1_HC_THR_MASK,
						i << WM831X_DC1_HC_THR_SHIFT);
	}
	if (i == ARRAY_SIZE(wm831x_dcdc_ilim))
		return -EINVAL;

	return wm831x_set_bits(wm831x, reg, WM831X_DC1_HC_THR_MASK,
			       i << WM831X_DC1_HC_THR_SHIFT);
	return -EINVAL;
}

static int wm831x_buckv_get_current_limit(struct regulator_dev *rdev)